From: Junchang Wang <junchangwang@gmail.com>
To: perfbook@vger.kernel.org, paulmck@linux.vnet.ibm.com
Cc: Junchang Wang <junchangwang@gmail.com>
Subject: [PATCH 2/4] route_hazptr: Switch from ACCESS_ONCE() to READ_ONCE()/WRITE_ONCE()
Date: Sat, 10 Jun 2017 22:28:29 +0800 [thread overview]
Message-ID: <1497104910-4596-3-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_hazptr.c | 10 +++++-----
defer/hazptr.tex | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/CodeSamples/defer/route_hazptr.c b/CodeSamples/defer/route_hazptr.c
index 590ba4d..49e6e4a 100644
--- a/CodeSamples/defer/route_hazptr.c
+++ b/CodeSamples/defer/route_hazptr.c
@@ -49,7 +49,7 @@ unsigned long route_lookup(unsigned long addr)
retry:
repp = &route_list.re_next;
do {
- rep = ACCESS_ONCE(*repp);
+ rep = READ_ONCE(*repp);
if (rep == NULL)
return ULONG_MAX;
if (rep == (struct route_entry *)HAZPTR_POISON)
@@ -61,13 +61,13 @@ retry:
smp_mb(); /* Force pointer loads in order. */
/* Recheck the hazard pointer against the original. */
- if (ACCESS_ONCE(*repp) != rep)
+ if (READ_ONCE(*repp) != rep)
goto 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();
return rep->iface;
}
@@ -129,7 +129,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;
rep->re_next = (struct route_entry *)HAZPTR_POISON;
@@ -157,7 +157,7 @@ void hazptr_free(void *p)
{
struct route_entry *rep = p;
- ACCESS_ONCE(rep->re_freed) = 1;
+ WRITE_ONCE(rep->re_freed, 1);
free(p);
}
diff --git a/defer/hazptr.tex b/defer/hazptr.tex
index 10ae7a1..b45f5b6 100644
--- a/defer/hazptr.tex
+++ b/defer/hazptr.tex
@@ -201,7 +201,7 @@ and in other publications~\cite{ThomasEHart2007a,McKenney:2013:SDS:2483852.24838
18 retry:
19 repp = &route_list.re_next;
20 do {
-21 rep = ACCESS_ONCE(*repp);
+21 rep = READ_ONCE(*repp);
22 if (rep == NULL)
23 return ULONG_MAX;
24 if (rep == (struct route_entry *)HAZPTR_POISON)
@@ -209,11 +209,11 @@ and in other publications~\cite{ThomasEHart2007a,McKenney:2013:SDS:2483852.24838
26 my_hazptr[offset].p = &rep->hh;
27 offset = !offset;
28 smp_mb();
-29 if (ACCESS_ONCE(*repp) != rep)
+29 if (READ_ONCE(*repp) != rep)
30 goto retry;
31 repp = &rep->re_next;
32 } while (rep->addr != addr);
-33 if (ACCESS_ONCE(rep->re_freed))
+33 if (READ_ONCE(rep->re_freed))
34 abort();
35 return rep->iface;
36 }
--
2.7.4
next prev 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 ` Junchang Wang [this message]
2017-06-10 14:28 ` [PATCH 3/4] route_seqlock: " Junchang Wang
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-3-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.