Skip to contentSkip to conversation

rcu/srcutiny: don't return before reenabling preemption

PATCH Applied Michal Schmidt 3 participants 3 messages Oct 7, 2024 – Oct 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu/srcutiny: don't return before reenabling preemption

Code after the return statement is dead. Enable preemption before returning from srcu_drive_gp().

This will be important when/if PREEMPT_AUTO (lazy resched) gets merged.

Fixes 65b4a59557f6 ("srcu: Make Tiny SRCU explicitly disable preemption")
---
 kernel/rcu/srcutiny.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/srcutiny.c +1 -1
index 549c03336ee9..4dcbf8aa80ff 100644
@@ -122,8 +122,8 @@ void srcu_drive_gp(struct work_struct *wp)
 	ssp = container_of(wp, struct srcu_struct, srcu_work);
 	preempt_disable();  // Needed for PREEMPT_AUTO
 	if (ssp->srcu_gp_running || ULONG_CMP_GE(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max))) {
-		return; /* Already running or nothing to do. */
 		preempt_enable();
+		return; /* Already running or nothing to do. */
 	}
 
 	/* Remove recently arrived callbacks and wait for readers. */
Signature · 1 line
2.46.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Michal Schmidt

Code after the return statement is dead. Enable preemption before returning from srcu_drive_gp().

This will be important when/if PREEMPT_AUTO (lazy resched) gets merged.

Fixes 65b4a59557f6 ("srcu: Make Tiny SRCU explicitly disable preemption")

Good catch!

Quoted 21 lines
---
 kernel/rcu/srcutiny.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/srcutiny.c +1 -1
index 549c03336ee9..4dcbf8aa80ff 100644
@@ -122,8 +122,8 @@ void srcu_drive_gp(struct work_struct *wp)
 	ssp = container_of(wp, struct srcu_struct, srcu_work);
 	preempt_disable();  // Needed for PREEMPT_AUTO
 	if (ssp->srcu_gp_running || ULONG_CMP_GE(ssp->srcu_idx, READ_ONCE(ssp->srcu_idx_max))) {
-		return; /* Already running or nothing to do. */
 		preempt_enable();
+		return; /* Already running or nothing to do. */
 	}
 
 	/* Remove recently arrived callbacks and wait for readers. */
Signature · 1 line
2.46.2
maintainer Applied
#2 lore raw
Quoted 4 lines · Paul E. McKenney
Quoted 3 lines · Michal Schmidt

Code after the return statement is dead. Enable preemption before returning from srcu_drive_gp().

Quoted 8 lines
Quoted 4 lines

This will be important when/if PREEMPT_AUTO (lazy resched) gets merged.

Fixes 65b4a59557f6 ("srcu: Make Tiny SRCU explicitly disable preemption")

Good catch!

Applied!

Thanks.