All of lore.kernel.org
 help / color / mirror / Atom feed
From: qiang.zhang@windriver.com
To: valentin.schneider@arm.com
Cc: peterz@infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sched/core: add rcu_read_lock/unlock() protection
Date: Tue, 26 Jan 2021 16:46:51 +0800	[thread overview]
Message-ID: <20210126084651.32277-1-qiang.zhang@windriver.com> (raw)

From: Zqiang <qiang.zhang@windriver.com>

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

Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
 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


             reply	other threads:[~2021-01-26 17:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26  8:46 qiang.zhang [this message]
2021-01-26  9:20 ` [PATCH] sched/core: add rcu_read_lock/unlock() protection Peter Zijlstra
2021-01-26  9:23 ` 回复: " Zhang, Qiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210126084651.32277-1-qiang.zhang@windriver.com \
    --to=qiang.zhang@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=valentin.schneider@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.