Skip to contentSkip to conversation

rcu/kvfree: Invoke debug_rcu_bhead_unqueue() with check bnode->snap is done

PATCH Applied Zqiang 3 participants 3 messages Apr 5, 2023 RCU

lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH 1/1 rcu/kvfree: Invoke debug_rcu_bhead_unqueue() with check bnode->snap is done

This commit make debug_rcu_bhead_unqueue() be invoked with check the bnode structure's->snap is done in kvfree_rcu_bulk().

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index 3461fc2640b9..17b5d115aec1 100644
@@ -2943,8 +2943,8 @@ kvfree_rcu_bulk(struct kfree_rcu_cpu *krcp,
 	unsigned long flags;
 	int i;
 
-	debug_rcu_bhead_unqueue(bnode);
 	if (!WARN_ON_ONCE(!poll_state_synchronize_rcu_full(&bnode->gp_snap))) {
+		debug_rcu_bhead_unqueue(bnode);
 		rcu_lock_acquire(&rcu_callback_map);
 		if (idx == 0) { // kmalloc() / kfree().
 			trace_rcu_invoke_kfree_bulk_callback(
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Zqiang

This commit make debug_rcu_bhead_unqueue() be invoked with check the bnode structure's->snap is done in kvfree_rcu_bulk().

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index 3461fc2640b9..17b5d115aec1 100644
@@ -2943,8 +2943,8 @@ kvfree_rcu_bulk(struct kfree_rcu_cpu *krcp,
 	unsigned long flags;
 	int i;
 
-	debug_rcu_bhead_unqueue(bnode);
 	if (!WARN_ON_ONCE(!poll_state_synchronize_rcu_full(&bnode->gp_snap))) {
+		debug_rcu_bhead_unqueue(bnode);
 		rcu_lock_acquire(&rcu_callback_map);
 		if (idx == 0) { // kmalloc() / kfree().
 			trace_rcu_invoke_kfree_bulk_callback(
Signature · 1 line
2.32.0

Since we leak, looks like correct to me:

--
Uladzislau Rezki

maintainer Applied
#2 lore raw
Quoted 28 lines · Uladzislau Rezki
Quoted 25 lines · Zqiang

This commit make debug_rcu_bhead_unqueue() be invoked with check the bnode structure's->snap is done in kvfree_rcu_bulk().

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index 3461fc2640b9..17b5d115aec1 100644
@@ -2943,8 +2943,8 @@ kvfree_rcu_bulk(struct kfree_rcu_cpu *krcp,
 	unsigned long flags;
 	int i;
 
-	debug_rcu_bhead_unqueue(bnode);
 	if (!WARN_ON_ONCE(!poll_state_synchronize_rcu_full(&bnode->gp_snap))) {
+		debug_rcu_bhead_unqueue(bnode);
 		rcu_lock_acquire(&rcu_callback_map);
 		if (idx == 0) { // kmalloc() / kfree().
 			trace_rcu_invoke_kfree_bulk_callback(
Signature · 1 line
2.32.0

Since we leak, looks like correct to me:

Quoted 1 line

Queued for v6.5, thank you both!

Thanx, Paul