linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: qiang.zhang@windriver.com
To: axboe@kernel.dk
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] io-wq: fix 'task->pi_lock' spin lock protect
Date: Fri, 23 Oct 2020 14:20:03 +0800	[thread overview]
Message-ID: <20201023062003.3353-1-qiang.zhang@windriver.com> (raw)

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

The set CPU affinity func 'do_set_cpus_allowed' may be operate
'task_rq', need add rq lock protect, replace 'pi_lock' spinlock
protect with task_rq_lock func.

Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
 fs/io-wq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/io-wq.c b/fs/io-wq.c
index d3165ce339c2..6ea3e0224e63 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -1209,11 +1209,13 @@ static bool io_wq_worker_affinity(struct io_worker *worker, void *data)
 {
 	struct task_struct *task = worker->task;
 	unsigned long flags;
+	struct rq_flags rf;
+	struct rq *rq;
 
-	raw_spin_lock_irqsave(&task->pi_lock, flags);
+	rq = task_rq_lock(task, &rf);
 	do_set_cpus_allowed(task, cpumask_of_node(worker->wqe->node));
 	task->flags |= PF_NO_SETAFFINITY;
-	raw_spin_unlock_irqrestore(&task->pi_lock, flags);
+	task_rq_unlock(rq, task, &rf);
 	return false;
 }
 
-- 
2.17.1


             reply	other threads:[~2020-10-23  6:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  6:20 qiang.zhang [this message]
2020-10-23 13:23 ` [PATCH] io-wq: fix 'task->pi_lock' spin lock protect Jens Axboe

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=20201023062003.3353-1-qiang.zhang@windriver.com \
    --to=qiang.zhang@windriver.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).