From: Junchang Wang <junchangwang@gmail.com>
To: paulmck@linux.ibm.com, akiyks@gmail.com
Cc: perfbook@vger.kernel.org, Junchang Wang <junchangwang@gmail.com>
Subject: [PATCH v2 1/3] rcu: Use READ_ONCE() and WRITE_ONCE() for shared variable rcu_gp_ctr
Date: Thu, 25 Apr 2019 16:29:52 +0800 [thread overview]
Message-ID: <1556180994-16131-2-git-send-email-junchangwang@gmail.com> (raw)
In-Reply-To: <1556180994-16131-1-git-send-email-junchangwang@gmail.com>
Signed-off-by: Junchang Wang <junchangwang@gmail.com>
Reviewed-by: Akira Yokosawa <akiyks@gmail.com>
---
CodeSamples/defer/rcu.c | 2 +-
CodeSamples/defer/rcu.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/CodeSamples/defer/rcu.c b/CodeSamples/defer/rcu.c
index 4b868cc..66792e5 100644
--- a/CodeSamples/defer/rcu.c
+++ b/CodeSamples/defer/rcu.c
@@ -35,7 +35,7 @@ void synchronize_rcu(void)
/* Advance to a new grace-period number, enforce ordering. */
- rcu_gp_ctr += 2;
+ WRITE_ONCE(rcu_gp_ctr, rcu_gp_ctr + 2);
smp_mb();
/*
diff --git a/CodeSamples/defer/rcu.h b/CodeSamples/defer/rcu.h
index f493f8b..b49ab14 100644
--- a/CodeSamples/defer/rcu.h
+++ b/CodeSamples/defer/rcu.h
@@ -41,7 +41,7 @@ static inline void rcu_read_lock(void)
* periodic per-thread processing.)
*/
- __get_thread_var(rcu_reader_gp) = rcu_gp_ctr + 1;
+ __get_thread_var(rcu_reader_gp) = READ_ONCE(rcu_gp_ctr) + 1;
smp_mb();
}
@@ -55,7 +55,7 @@ static inline void rcu_read_unlock(void)
*/
smp_mb();
- __get_thread_var(rcu_reader_gp) = rcu_gp_ctr;
+ __get_thread_var(rcu_reader_gp) = READ_ONCE(rcu_gp_ctr);
}
extern void synchronize_rcu(void);
--
2.7.4
next prev parent reply other threads:[~2019-04-25 8:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 8:29 [PATCH v2 0/3] Toyrcu: replace plain accesses with READ_ONCE() and Junchang Wang
2019-04-25 8:29 ` Junchang Wang [this message]
2019-04-25 8:29 ` [PATCH v2 2/3] rcu_nest: Use READ_ONCE() and WRITE_ONCE() for shared variable rcu_gp_ctr Junchang Wang
2019-04-25 8:29 ` [PATCH v2 3/3] rcu_qs: Use READ_ONCE() AND " Junchang Wang
2019-04-25 15:38 ` [PATCH v2 0/3] Toyrcu: replace plain accesses with READ_ONCE() and Akira Yokosawa
2019-04-26 8:15 ` Junchang Wang
2019-04-26 13:43 ` Paul E. McKenney
2019-04-27 14:27 ` Akira Yokosawa
2019-04-28 14:57 ` Junchang Wang
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=1556180994-16131-2-git-send-email-junchangwang@gmail.com \
--to=junchangwang@gmail.com \
--cc=akiyks@gmail.com \
--cc=paulmck@linux.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.