From: Alan Huang <mmpgouride@gmail.com>
To: paulmck@kernel.org
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
Alan Huang <mmpgouride@gmail.com>
Subject: [PATCH v2] rcu: Add necessary WRITE_ONCE()
Date: Tue, 20 Jun 2023 17:13:46 +0000 [thread overview]
Message-ID: <20230620171346.207076-1-mmpgouride@gmail.com> (raw)
Commit c54a2744497d("list: Add hlist_unhashed_lockless()") and
commit 860c8802ace1("rcu: Use WRITE_ONCE() for assignments to
->pprev for hlist_nulls") added various WRITE_ONCE() to pair with
the READ_ONCE() in hlist_unhashed_lockless(), but there are still
some places where WRITE_ONCE() was not added, this commit adds that.
Also add WRITE_ONCE() to pair with the READ_ONCE() in hlist_empty().
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
Changelog:
V1 -> V2:
Add WRITE_ONCE in hlist_del_init to pair with READ_ONCE in
hlist_unhashed_lockless.
include/linux/list.h | 9 +++++----
include/linux/list_nulls.h | 2 +-
include/linux/rculist_nulls.h | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/linux/list.h b/include/linux/list.h
index ac366958ea..3a29b95bfe 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -912,7 +912,7 @@ static inline void hlist_del(struct hlist_node *n)
{
__hlist_del(n);
n->next = LIST_POISON1;
- n->pprev = LIST_POISON2;
+ WRITE_ONCE(n->pprev, LIST_POISON2);
}
/**
@@ -925,7 +925,8 @@ static inline void hlist_del_init(struct hlist_node *n)
{
if (!hlist_unhashed(n)) {
__hlist_del(n);
- INIT_HLIST_NODE(n);
+ n->next = NULL;
+ WRITE_ONCE(n->pprev, NULL);
}
}
@@ -1026,8 +1027,8 @@ static inline void hlist_move_list(struct hlist_head *old,
{
new->first = old->first;
if (new->first)
- new->first->pprev = &new->first;
- old->first = NULL;
+ WRITE_ONCE(new->first->pprev, &new->first);
+ WRITE_ONCE(old->first, NULL);
}
#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h
index fa6e8471bd..b63b0589fa 100644
--- a/include/linux/list_nulls.h
+++ b/include/linux/list_nulls.h
@@ -95,7 +95,7 @@ static inline void hlist_nulls_add_head(struct hlist_nulls_node *n,
n->next = first;
WRITE_ONCE(n->pprev, &h->first);
- h->first = n;
+ WRITE_ONCE(h->first, n);
if (!is_a_nulls(first))
WRITE_ONCE(first->pprev, &n->next);
}
diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
index ba4c00dd80..c65121655b 100644
--- a/include/linux/rculist_nulls.h
+++ b/include/linux/rculist_nulls.h
@@ -138,7 +138,7 @@ static inline void hlist_nulls_add_tail_rcu(struct hlist_nulls_node *n,
if (last) {
n->next = last->next;
- n->pprev = &last->next;
+ WRITE_ONCE(n->pprev, &last->next);
rcu_assign_pointer(hlist_nulls_next_rcu(last), n);
} else {
hlist_nulls_add_head_rcu(n, h);
--
2.34.1
next reply other threads:[~2023-06-20 17:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 17:13 Alan Huang [this message]
2023-06-20 22:26 ` Paul E. McKenney
2023-06-21 2:08 ` Alan Huang
2023-06-23 5:17 ` Paul E. McKenney
2023-06-23 18:31 ` Alan Huang
2023-06-23 22:07 ` Paul E. McKenney
2023-06-26 12:22 ` Will Deacon
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=20230620171346.207076-1-mmpgouride@gmail.com \
--to=mmpgouride@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome