All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junchang Wang <junchangwang@gmail.com>
To: perfbook@vger.kernel.org, paulmck@linux.vnet.ibm.com
Cc: Junchang Wang <junchangwang@gmail.com>
Subject: [PATCH 3/4] route_seqlock: Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE()
Date: Sat, 10 Jun 2017 22:28:30 +0800	[thread overview]
Message-ID: <1497104910-4596-4-git-send-email-junchangwang@gmail.com> (raw)
In-Reply-To: <1497104910-4596-1-git-send-email-junchangwang@gmail.com>

Signed-off-by: Junchang Wang <junchangwang@gmail.com>
---
 CodeSamples/defer/route_seqlock.c |  6 +++---
 CodeSamples/defer/seqlock.h       |  4 ++--
 defer/seqlock.tex                 | 12 ++++++------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/CodeSamples/defer/route_seqlock.c b/CodeSamples/defer/route_seqlock.c
index 633cf05..8224682 100644
--- a/CodeSamples/defer/route_seqlock.c
+++ b/CodeSamples/defer/route_seqlock.c
@@ -47,7 +47,7 @@ retry:
 	s = read_seqbegin(&sl);
 	repp = &route_list.re_next;
 	do {
-		rep = ACCESS_ONCE(*repp);
+		rep = READ_ONCE(*repp);
 		if (rep == NULL) {
 			if (read_seqretry(&sl, s))
 				goto retry;
@@ -57,7 +57,7 @@ retry:
 		/* Advance to next. */
 		repp = &rep->re_next;
 	} while (rep->addr != addr);
-	if (ACCESS_ONCE(rep->re_freed))
+	if (READ_ONCE(rep->re_freed))
 		abort();
 	ret = rep->iface;
 	if (read_seqretry(&sl, s))
@@ -123,7 +123,7 @@ void route_clear(void)

 	write_seqlock(&sl);
 	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;
 		free(rep);
diff --git a/CodeSamples/defer/seqlock.h b/CodeSamples/defer/seqlock.h
index b210944..c994285 100644
--- a/CodeSamples/defer/seqlock.h
+++ b/CodeSamples/defer/seqlock.h
@@ -38,7 +38,7 @@ static inline unsigned long read_seqbegin(seqlock_t *slp)
 {
 	unsigned long s;

-	s = ACCESS_ONCE(slp->seq);
+	s = READ_ONCE(slp->seq);
 	smp_mb();
 	return s & ~0x1UL;
 }
@@ -48,7 +48,7 @@ static inline int read_seqretry(seqlock_t *slp, unsigned long oldseq)
 	unsigned long s;

 	smp_mb();
-	s = ACCESS_ONCE(slp->seq);
+	s = READ_ONCE(slp->seq);
 	return s != oldseq;
 }

diff --git a/defer/seqlock.tex b/defer/seqlock.tex
index ba8abfe..cb5e4e6 100644
--- a/defer/seqlock.tex
+++ b/defer/seqlock.tex
@@ -116,7 +116,7 @@ It is also used in pathname traversal to detect concurrent rename operations.
 13  {
 14    unsigned long s;
 15
-16    s = ACCESS_ONCE(slp->seq);
+16    s = READ_ONCE(slp->seq);
 17    smp_mb();
 18    return s & ~0x1UL;
 19  }
@@ -127,7 +127,7 @@ It is also used in pathname traversal to detect concurrent rename operations.
 24    unsigned long s;
 25
 26    smp_mb();
-27    s = ACCESS_ONCE(slp->seq);
+27    s = READ_ONCE(slp->seq);
 28    return s != oldseq;
 29  }
 30
@@ -211,11 +211,11 @@ in other words, that there has been no writer, and returns true if so.
 	In older versions of the Linux kernel, no.

 	In very new versions of the Linux kernel, line~16 could use
-	\co{smp_load_acquire()} instead of \co{ACCESS_ONCE()}, which
+	\co{smp_load_acquire()} instead of \co{READ_ONCE()}, which
 	in turn would allow the \co{smp_mb()} on line~17 to be dropped.
 	Similarly, line~41 could use an \co{smp_store_release()}, for
 	example, as follows: \\
-	\co{smp_store_release(&slp->seq, ACCESS_ONCE(slp->seq) + 1);} \\
+	\co{smp_store_release(&slp->seq, READ_ONCE(slp->seq) + 1);} \\
 	This would allow the \co{smp_mb()} on line~40 to be dropped.
 } \QuickQuizEnd

@@ -310,7 +310,7 @@ increment of the sequence number on line~44, then releases the lock.
 18   s = read_seqbegin(&sl);
 19   repp = &route_list.re_next;
 20   do {
-21     rep = ACCESS_ONCE(*repp);
+21     rep = READ_ONCE(*repp);
 22     if (rep == NULL) {
 23       if (read_seqretry(&sl, s))
 24         goto retry;
@@ -318,7 +318,7 @@ increment of the sequence number on line~44, then releases the lock.
 26     }
 27     repp = &rep->re_next;
 28   } while (rep->addr != addr);
-29   if (ACCESS_ONCE(rep->re_freed))
+29   if (READ_ONCE(rep->re_freed))
 30     abort();
 31   ret = rep->iface;
 32   if (read_seqretry(&sl, s))
-- 
2.7.4


  parent reply	other threads:[~2017-06-10 14:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-10 14:28 [PATCH 0/4] Update on Chapter Deferred Processing Junchang Wang
2017-06-10 14:28 ` [PATCH 1/4] Figure Storage Hazard-Pointer Storage and Erasure: Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE() Junchang Wang
2017-06-10 14:28 ` [PATCH 2/4] route_hazptr: " Junchang Wang
2017-06-10 14:28 ` Junchang Wang [this message]
2017-06-10 14:35 ` [PATCH 0/4] Update on Chapter Deferred Processing Junchang Wang
2017-06-10 17:08   ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497104910-4596-4-git-send-email-junchangwang@gmail.com \
    --to=junchangwang@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=perfbook@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.