[PATCH 1/5] hazptr: Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Junchang Wang <junchangwang@xxxxxxxxx>
---
 CodeSamples/defer/hazptr.h        | 8 ++++----
 CodeSamples/defer/hazptrtorture.h | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/CodeSamples/defer/hazptr.h b/CodeSamples/defer/hazptr.h
index 391d281..48bec0e 100644
--- a/CodeSamples/defer/hazptr.h
+++ b/CodeSamples/defer/hazptr.h
@@ -65,17 +65,17 @@ static inline void *hp_record(void **p, hazard_pointer *hp)
 	hazptr_head_t *tmp;
 
 	do {
-		tmp = ACCESS_ONCE(*p);
-		ACCESS_ONCE(hp->p) = tmp;
+		tmp = READ_ONCE(*p);
+		WRITE_ONCE(hp->p, tmp);
 		smp_mb();
-	} while (tmp != ACCESS_ONCE(*p));
+	} while (tmp != READ_ONCE(*p));
 	return tmp;
 }
 
 static inline void hp_clear(hazard_pointer *hp)
 {
 	smp_mb();
-	ACCESS_ONCE(hp->p) = NULL;
+	WRITE_ONCE(hp->p, NULL);
 }
 
 #define hazptr_clean_pointer(p) ((typeof(p))((unsigned long)(p) & ~0x1UL))
diff --git a/CodeSamples/defer/hazptrtorture.h b/CodeSamples/defer/hazptrtorture.h
index 9341765..2188ec1 100644
--- a/CodeSamples/defer/hazptrtorture.h
+++ b/CodeSamples/defer/hazptrtorture.h
@@ -286,17 +286,17 @@ void *hazptr_update_stress_test(void *arg)
 		if (i >= HAZPTR_STRESS_PIPE_LEN)
 			i = 0;
 		p = &hazptr_stress_array[i];
-		if (ACCESS_ONCE(p->inuse)) {
+		if (READ_ONCE(p->inuse)) {
 			hazptr_stress_idx = i;
 			continue;
 		}
 		p->pipe_count = 0;
-		ACCESS_ONCE(p->inuse) = 1;
+		WRITE_ONCE(p->inuse, 1);
 		p->mbtest = 0;
 		smp_mb();
 		p->mbtest = 1;
 		smp_mb();
-		ACCESS_ONCE(hazptr_stress_current) =  p;
+		WRITE_ONCE(hazptr_stress_current, p);
 		hazptr_stress_idx = i;
 		for (i = 0; i < HAZPTR_STRESS_PIPE_LEN; i++)
 			if (!hazptr_stress_array[i].inuse) {
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux