RCU misc updates for v6.12
Neeraj Upadhyay
maintainercover RCU misc updates for v6.12
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(-)
[email protected]
maintainerPATCH 1/3 rcu/kfree: Warn on unexpected tail state
From: "Paul E. McKenney" <[email protected]>
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.
--- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
@@ -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));
Signature · 1 line
2.40.1
[email protected]
maintainerPATCH 2/3 rcu: Better define "atomic" for list replacement
In reply to Neeraj UpadhyayFrom: "Paul E. McKenney" <[email protected]>
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.
--- include/linux/rculist.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/rculist.h +7 -2
@@ -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)
Signature · 1 line
2.40.1
[email protected]
maintainerPATCH 3/3 rcu: Annotate struct kvfree_rcu_bulk_data with __counted_by()
In reply to Neeraj UpadhyayFrom: Thorsten Blum <[email protected]>
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.
--- kernel/rcu/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +3 -2
@@ -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]);
Signature · 1 line
2.40.1