Skip to contentSkip to conversation

io-wq: fix 'task->pi_lock' spin lock protect

PATCH In review [email protected] 2 participants 2 messages Oct 23, 2020

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

PATCH 1/1 io-wq: fix 'task->pi_lock' spin lock protect

From: Zqiang <[email protected]>

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.

---
 fs/io-wq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/io-wq.c +4 -2
index d3165ce339c2..6ea3e0224e63 100644
@@ -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;
 }
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 5 lines · On 10/23/20 12:20 AM, [email protected] wrote:

From: Zqiang <[email protected]>

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.

Thanks, I'm going to fold this one.

Signature · 1 line
Jens Axboe