2021-01-27 06:02:46

by Zhang, Qiang

[permalink] [raw]
Subject: [PATCH] sched/core: add rcu_read_lock/unlock() protection

From: Zqiang <[email protected]>

Due to for_each_process_thread belongs to RCU read operation,
need to add rcu_read_lock/unlock() protection.

Signed-off-by: Zqiang <[email protected]>
---
kernel/sched/core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8c5481077c9c..c3f0103fdf53 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7738,6 +7738,7 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)
lockdep_assert_held(&rq->lock);

printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
+ rcu_read_lock();
for_each_process_thread(g, p) {
if (task_cpu(p) != cpu)
continue;
@@ -7747,6 +7748,7 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)

printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
}
+ rcu_read_unlock();
}

int sched_cpu_dying(unsigned int cpu)
--
2.17.1


2021-01-27 06:13:06

by Zhang, Qiang

[permalink] [raw]
Subject: 回复: [PATCH] sched/core: add rcu_read_lock/u nlock() protection



________________________________________
??????: Zhang, Qiang <[email protected]>
????ʱ??: 2021??1??26?? 16:29
?ռ???: [email protected]
????: [email protected]; [email protected]
????: [PATCH] sched/core: add rcu_read_lock/unlock() protection

>From: Zqiang <[email protected]>

>Due to for_each_process_thread belongs to RCU read operation,
>need to add rcu_read_lock/unlock() protection.

Sorry to disturb you
I find it's already in the RCU critical zone
Please ignore this change


>Signed-off-by: Zqiang <[email protected]>
>---
> kernel/sched/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>index 8c5481077c9c..c3f0103fdf53 100644
>--- a/kernel/sched/core.c
>+++ b/kernel/sched/core.c
>@@ -7738,6 +7738,7 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)
> lockdep_assert_held(&rq->lock);
>
> printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
>+ rcu_read_lock();
> for_each_process_thread(g, p) {
> if (task_cpu(p) != cpu)
> continue;
>@@ -7747,6 +7748,7 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)
>
> printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
> }
>+ rcu_read_unlock();
> }
>
> int sched_cpu_dying(unsigned int cpu)
--
2.17.1