Skip to contentSkip to conversation

route_refcnt: Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE()

PATCH Applied Junchang Wang 2 participants 2 messages Jun 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 route_refcnt: Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE()

Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE(), and updated corresponding latex file.

---
 CodeSamples/defer/route_refcnt.c | 8 ++++----
 defer/refcnt.tex                 | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
CodeSamples/defer/route_refcnt.c +4 -4
index 6f8ae65..8a48faf 100644
@@ -35,7 +35,7 @@ DEFINE_SPINLOCK(routelock);
 
 static void re_free(struct route_entry *rep)
 {
-	ACCESS_ONCE(rep->re_freed) = 1;
+	WRITE_ONCE(rep->re_freed, 1);
 	free(rep);
 }
 
@@ -56,13 +56,13 @@ retry:
 	do {
 		if (rep && atomic_dec_and_test(&rep->re_refcnt))
 			re_free(rep);
-		rep = ACCESS_ONCE(*repp);
+		rep = READ_ONCE(*repp);
 		if (rep == NULL)
 			return ULONG_MAX;
 
 		/* Acquire a reference if the count is non-zero. */
 		do {
-			if (ACCESS_ONCE(rep->re_freed))
+			if (READ_ONCE(rep->re_freed))
 				abort();
 			old = atomic_read(&rep->re_refcnt);
 			if (old <= 0)
@@ -137,7 +137,7 @@ void route_clear(void)
 
 	spin_lock(&routelock);
 	rep = route_list.re_next;
-	ACCESS_ONCE(route_list.re_next) = NULL;
+	WRITE_ONCE(route_list.re_next, NULL);
 	while (rep != NULL) {
 		rep1 = rep->re_next;
 		if (atomic_dec_and_test(&rep->re_refcnt))
defer/refcnt.tex +3 -3
index c46fa48..c231961 100644
@@ -18,7 +18,7 @@
 10
 11 static void re_free(struct route_entry *rep)
 12 {
-13   ACCESS_ONCE(rep->re_freed) = 1;
+13   WRITE_ONCE(rep->re_freed, 1);
 14   free(rep);
 15 }
 16
@@ -37,11 +37,11 @@
 29     if (rep &&
 30         atomic_dec_and_test(&rep->re_refcnt))
 31       re_free(rep);
-32     rep = ACCESS_ONCE(*repp);
+32     rep = READ_ONCE(*repp);
 33     if (rep == NULL)
 34       return ULONG_MAX;
 35     do {
-36       if (ACCESS_ONCE(rep->re_freed))
+36       if (READ_ONCE(rep->re_freed))
 37         abort();
 38       old = atomic_read(&rep->re_refcnt);
 39       if (old <= 0)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · Junchang Wang

Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE(), and updated corresponding latex file.

Queued and pushed, thank you!

Thanx, Paul

Quoted 78 lines
---
 CodeSamples/defer/route_refcnt.c | 8 ++++----
 defer/refcnt.tex                 | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
CodeSamples/defer/route_refcnt.c +4 -4
index 6f8ae65..8a48faf 100644
@@ -35,7 +35,7 @@ DEFINE_SPINLOCK(routelock);
 
 static void re_free(struct route_entry *rep)
 {
-	ACCESS_ONCE(rep->re_freed) = 1;
+	WRITE_ONCE(rep->re_freed, 1);
 	free(rep);
 }
 
@@ -56,13 +56,13 @@ retry:
 	do {
 		if (rep && atomic_dec_and_test(&rep->re_refcnt))
 			re_free(rep);
-		rep = ACCESS_ONCE(*repp);
+		rep = READ_ONCE(*repp);
 		if (rep == NULL)
 			return ULONG_MAX;
 
 		/* Acquire a reference if the count is non-zero. */
 		do {
-			if (ACCESS_ONCE(rep->re_freed))
+			if (READ_ONCE(rep->re_freed))
 				abort();
 			old = atomic_read(&rep->re_refcnt);
 			if (old <= 0)
@@ -137,7 +137,7 @@ void route_clear(void)
 
 	spin_lock(&routelock);
 	rep = route_list.re_next;
-	ACCESS_ONCE(route_list.re_next) = NULL;
+	WRITE_ONCE(route_list.re_next, NULL);
 	while (rep != NULL) {
 		rep1 = rep->re_next;
 		if (atomic_dec_and_test(&rep->re_refcnt))
defer/refcnt.tex +3 -3
index c46fa48..c231961 100644
@@ -18,7 +18,7 @@
 10
 11 static void re_free(struct route_entry *rep)
 12 {
-13   ACCESS_ONCE(rep->re_freed) = 1;
+13   WRITE_ONCE(rep->re_freed, 1);
 14   free(rep);
 15 }
 16
@@ -37,11 +37,11 @@
 29     if (rep &&
 30         atomic_dec_and_test(&rep->re_refcnt))
 31       re_free(rep);
-32     rep = ACCESS_ONCE(*repp);
+32     rep = READ_ONCE(*repp);
 33     if (rep == NULL)
 34       return ULONG_MAX;
 35     do {
-36       if (ACCESS_ONCE(rep->re_freed))
+36       if (READ_ONCE(rep->re_freed))
 37         abort();
 38       old = atomic_read(&rep->re_refcnt);
 39       if (old <= 0)
Signature · 6 lines
2.7.4

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