* [PATCH rcu 0/3] RCU misc updates for v6.12
@ 2024-08-16 7:22 Neeraj Upadhyay
2024-08-16 7:22 ` [PATCH rcu 1/3] rcu/kfree: Warn on unexpected tail state neeraj.upadhyay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Neeraj Upadhyay @ 2024-08-16 7:22 UTC (permalink / raw)
To: rcu
Cc: paulmck, joel, frederic, boqun.feng, urezki, linux-kernel,
kernel-team, rostedt, thorsten.blum
Hello,
Below are the RCU misc updates for v6.12:
1. Warn on unexpected rcu_synchronize llist's done tail state,
courtesy of Paul E. McKenney.
2. Better define "atomic" for list_replace_rcu() and hlist_replace_rcu()
list replacement functions, courtesy of Paul E. McKenney.
3. Annotate struct kvfree_rcu_bulk_data with __counted_by(),
courtesy of Thorsten Blum.
Git tree: https://git.kernel.org/pub/scm/linux/kernel/git/neeraj.upadhyay/linux-rcu.git/log/?h=misc.11.08.24a
- Neeraj
------------------------------------------------------------------------
include/linux/rculist.h | 9 +++++++--
kernel/rcu/tree.c | 7 ++++---
2 files changed, 11 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rcu 1/3] rcu/kfree: Warn on unexpected tail state
2024-08-16 7:22 [PATCH rcu 0/3] RCU misc updates for v6.12 Neeraj Upadhyay
@ 2024-08-16 7:22 ` neeraj.upadhyay
2024-08-16 7:22 ` [PATCH rcu 2/3] rcu: Better define "atomic" for list replacement neeraj.upadhyay
2024-08-16 7:22 ` [PATCH rcu 3/3] rcu: Annotate struct kvfree_rcu_bulk_data with __counted_by() neeraj.upadhyay
2 siblings, 0 replies; 4+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 7:22 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic
From: "Paul E. McKenney" <paulmck@kernel.org>
Within the rcu_sr_normal_gp_cleanup_work() function, there is an acquire
load from rcu_state.srs_done_tail, which is expected to be non-NULL.
This commit adds a WARN_ON_ONCE() to check this expectation.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
kernel/rcu/tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index e641cc681901..0f41a81138dc 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1649,7 +1649,7 @@ static void rcu_sr_normal_gp_cleanup_work(struct work_struct *work)
* the done tail list manipulations are protected here.
*/
done = smp_load_acquire(&rcu_state.srs_done_tail);
- if (!done)
+ if (WARN_ON_ONCE(!done))
return;
WARN_ON_ONCE(!rcu_sr_is_wait_head(done));
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH rcu 2/3] rcu: Better define "atomic" for list replacement
2024-08-16 7:22 [PATCH rcu 0/3] RCU misc updates for v6.12 Neeraj Upadhyay
2024-08-16 7:22 ` [PATCH rcu 1/3] rcu/kfree: Warn on unexpected tail state neeraj.upadhyay
@ 2024-08-16 7:22 ` neeraj.upadhyay
2024-08-16 7:22 ` [PATCH rcu 3/3] rcu: Annotate struct kvfree_rcu_bulk_data with __counted_by() neeraj.upadhyay
2 siblings, 0 replies; 4+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 7:22 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic
From: "Paul E. McKenney" <paulmck@kernel.org>
The kernel-doc headers for list_replace_rcu() and hlist_replace_rcu()
claim that the replacement is atomic, which it is, but only for readers.
Avoid confusion by making it clear that the atomic nature of these
functions applies only to readers, not to concurrent updaters.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
include/linux/rculist.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 3dc1e58865f7..14dfa6008467 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -191,7 +191,10 @@ static inline void hlist_del_init_rcu(struct hlist_node *n)
* @old : the element to be replaced
* @new : the new element to insert
*
- * The @old entry will be replaced with the @new entry atomically.
+ * The @old entry will be replaced with the @new entry atomically from
+ * the perspective of concurrent readers. It is the caller's responsibility
+ * to synchronize with concurrent updaters, if any.
+ *
* Note: @old should not be empty.
*/
static inline void list_replace_rcu(struct list_head *old,
@@ -519,7 +522,9 @@ static inline void hlist_del_rcu(struct hlist_node *n)
* @old : the element to be replaced
* @new : the new element to insert
*
- * The @old entry will be replaced with the @new entry atomically.
+ * The @old entry will be replaced with the @new entry atomically from
+ * the perspective of concurrent readers. It is the caller's responsibility
+ * to synchronize with concurrent updaters, if any.
*/
static inline void hlist_replace_rcu(struct hlist_node *old,
struct hlist_node *new)
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH rcu 3/3] rcu: Annotate struct kvfree_rcu_bulk_data with __counted_by()
2024-08-16 7:22 [PATCH rcu 0/3] RCU misc updates for v6.12 Neeraj Upadhyay
2024-08-16 7:22 ` [PATCH rcu 1/3] rcu/kfree: Warn on unexpected tail state neeraj.upadhyay
2024-08-16 7:22 ` [PATCH rcu 2/3] rcu: Better define "atomic" for list replacement neeraj.upadhyay
@ 2024-08-16 7:22 ` neeraj.upadhyay
2 siblings, 0 replies; 4+ messages in thread
From: neeraj.upadhyay @ 2024-08-16 7:22 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, paulmck, neeraj.upadhyay,
neeraj.upadhyay, boqun.feng, joel, urezki, frederic,
Thorsten Blum, Gustavo A. R. Silva
From: Thorsten Blum <thorsten.blum@toblux.com>
Add the __counted_by compiler attribute to the flexible array member
records to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.
Increment nr_records before adding a new pointer to the records array.
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reviewed-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Reviewed-by: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>
---
kernel/rcu/tree.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 0f41a81138dc..d5bf824159da 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3227,7 +3227,7 @@ struct kvfree_rcu_bulk_data {
struct list_head list;
struct rcu_gp_oldstate gp_snap;
unsigned long nr_records;
- void *records[];
+ void *records[] __counted_by(nr_records);
};
/*
@@ -3767,7 +3767,8 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp,
}
// Finally insert and update the GP for this page.
- bnode->records[bnode->nr_records++] = ptr;
+ bnode->nr_records++;
+ bnode->records[bnode->nr_records - 1] = ptr;
get_state_synchronize_rcu_full(&bnode->gp_snap);
atomic_inc(&(*krcp)->bulk_count[idx]);
--
2.40.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-16 7:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-16 7:22 [PATCH rcu 0/3] RCU misc updates for v6.12 Neeraj Upadhyay
2024-08-16 7:22 ` [PATCH rcu 1/3] rcu/kfree: Warn on unexpected tail state neeraj.upadhyay
2024-08-16 7:22 ` [PATCH rcu 2/3] rcu: Better define "atomic" for list replacement neeraj.upadhyay
2024-08-16 7:22 ` [PATCH rcu 3/3] rcu: Annotate struct kvfree_rcu_bulk_data with __counted_by() neeraj.upadhyay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox