Skip to contentSkip to conversation

sched_ext: Remove redundant rcu_read_lock/unlock() in sysrq_handle_sched_ext_reset()

PATCH Applied Zqiang 4 participants 6 messages Apr 30 – May 7

Subsystems (2)
lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH 1/1 sched_ext: Remove redundant rcu_read_lock/unlock() in sysrq_handle_sched_ext_reset()

The sysrq_handle_sched_ext_reset() callback has already been executed in the rcu read critical section within __handle_sysrq(), this commit therefore remove redundant rcu_read_lock/unlock() in the sysrq_handle_sched_ext_reset().

---
 kernel/sched/ext.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/ext.c +0 -2
index 45a2668284bc..0f3e9d088151 100644
@@ -7953,13 +7953,11 @@ static void sysrq_handle_sched_ext_reset(u8 key)
 {
 	struct scx_sched *sch;
 
-	rcu_read_lock();
 	sch = rcu_dereference(scx_root);
 	if (likely(sch))
 		scx_disable(sch, SCX_EXIT_SYSRQ);
 	else
 		pr_info("sched_ext: BPF schedulers not loaded\n");
-	rcu_read_unlock();
 }
 
 static const struct sysrq_key_op sysrq_sched_ext_reset_op = {
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Zqiang,

Quoted 3 lines · Zqiang

The sysrq_handle_sched_ext_reset() callback has already been executed in the rcu read critical section within __handle_sysrq(), this commit therefore remove redundant rcu_read_lock/unlock() in

Nit: s/remove/removes

Looks good!

Quoted 29 lines

the sysrq_handle_sched_ext_reset().

---
 kernel/sched/ext.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/ext.c +0 -2
index 45a2668284bc..0f3e9d088151 100644
@@ -7953,13 +7953,11 @@ static void sysrq_handle_sched_ext_reset(u8 key)
 {
 	struct scx_sched *sch;
 
-	rcu_read_lock();
 	sch = rcu_dereference(scx_root);
 	if (likely(sch))
 		scx_disable(sch, SCX_EXIT_SYSRQ);
 	else
 		pr_info("sched_ext: BPF schedulers not loaded\n");
-	rcu_read_unlock();
 }
 
 static const struct sysrq_key_op sysrq_sched_ext_reset_op = {
Signature · 1 line
2.17.1
Signature · 2 lines
Cheers,
Cheng-Yang
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Zqiang

Hi Zqiang,

Quoted 6 lines · Zqiang

The sysrq_handle_sched_ext_reset() callback has already been executed in the rcu read critical section within __handle_sysrq(), this commit therefore remove redundant rcu_read_lock/unlock() in the sysrq_handle_sched_ext_reset().

Looks good to me.

Thanks,
-Andrea

Quoted 25 lines
---
 kernel/sched/ext.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/ext.c +0 -2
index 45a2668284bc..0f3e9d088151 100644
@@ -7953,13 +7953,11 @@ static void sysrq_handle_sched_ext_reset(u8 key)
 {
 	struct scx_sched *sch;
 
-	rcu_read_lock();
 	sch = rcu_dereference(scx_root);
 	if (likely(sch))
 		scx_disable(sch, SCX_EXIT_SYSRQ);
 	else
 		pr_info("sched_ext: BPF schedulers not loaded\n");
-	rcu_read_unlock();
 }
 
 static const struct sysrq_key_op sysrq_sched_ext_reset_op = {
Signature · 1 line
2.17.1
reviewer
#3 lore raw
Quoted 7 lines · Andrea Righi

Hi Zqiang,

Quoted 4 lines · Zqiang

The sysrq_handle_sched_ext_reset() callback has already been executed in the rcu read critical section within __handle_sysrq(), this commit therefore remove redundant rcu_read_lock/unlock() in the sysrq_handle_sched_ext_reset().

Actually, minor nits in the commit message:

1) s/has already been executed/is executed/
2) s/remove/removes/

Or maybe rephrase as following?

sysrq_handle_sched_ext_reset() is called from __handle_sysrq(), which already holds rcu_read_lock() while invoking the sysrq handler. Remove the redundant rcu_read_lock/unlock() pair.

Thanks,
-Andrea

Quoted 35 lines
Quoted 2 lines

Looks good to me.

Thanks,
-Andrea

Quoted 25 lines
---
 kernel/sched/ext.c | 2 --
 1 file changed, 2 deletions(-)
kernel/sched/ext.c +0 -2
index 45a2668284bc..0f3e9d088151 100644
@@ -7953,13 +7953,11 @@ static void sysrq_handle_sched_ext_reset(u8 key)
 {
 	struct scx_sched *sch;
 
-	rcu_read_lock();
 	sch = rcu_dereference(scx_root);
 	if (likely(sch))
 		scx_disable(sch, SCX_EXIT_SYSRQ);
 	else
 		pr_info("sched_ext: BPF schedulers not loaded\n");
-	rcu_read_unlock();
 }
 
 static const struct sysrq_key_op sysrq_sched_ext_reset_op = {
Signature · 1 line
2.17.1
reviewer Applied
#4 lore raw
In reply to Zqiang

Hello,

Applied to sched_ext/for-7.2 with Andrea's suggested commit message rewording and both Reviewed-by tags.

Thanks.

--
tejun

author
#5 lore raw
Quoted 5 lines

Hello,

Applied to sched_ext/for-7.2 with Andrea's suggested commit message rewording and both Reviewed-by tags.

Thanks both (Andrea's suggested commit and Cheng-Yang Chou's review) and tejun.

Thanks
Zqiang

Quoted 6 lines

Thanks.

--
tejun