public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io-wq: Fix io_wq_worker_affinity()
@ 2021-04-08  9:44 Peter Zijlstra
  2021-04-08 19:43 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Zijlstra @ 2021-04-08  9:44 UTC (permalink / raw)
  To: Jens Axboe; +Cc: asml.silence, io-uring, linux-kernel


Do not include private headers and do not frob in internals.

On top of that, while the previous code restores the affinity, it
doesn't ensure the task actually moves there if it was running,
leading to the fun situation that it can be observed running outside
of its allowed mask for potentially significant time.

Use the proper API instead.

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
---
 fs/io-wq.c |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -17,7 +17,6 @@
 #include <linux/cpu.h>
 #include <linux/tracehook.h>
 
-#include "../kernel/sched/sched.h"
 #include "io-wq.h"
 
 #define WORKER_IDLE_TIMEOUT	(5 * HZ)
@@ -1098,14 +1097,8 @@ void io_wq_put_and_exit(struct io_wq *wq
 
 static bool io_wq_worker_affinity(struct io_worker *worker, void *data)
 {
-	struct task_struct *task = worker->task;
-	struct rq_flags rf;
-	struct rq *rq;
-
-	rq = task_rq_lock(task, &rf);
-	do_set_cpus_allowed(task, cpumask_of_node(worker->wqe->node));
-	task->flags |= PF_NO_SETAFFINITY;
-	task_rq_unlock(rq, task, &rf);
+	set_cpus_allowed_ptr(worker->task, cpumask_of_node(worker->wqe->node));
+
 	return false;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] io-wq: Fix io_wq_worker_affinity()
  2021-04-08  9:44 [PATCH] io-wq: Fix io_wq_worker_affinity() Peter Zijlstra
@ 2021-04-08 19:43 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-04-08 19:43 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: asml.silence, io-uring, linux-kernel

On 4/8/21 3:44 AM, Peter Zijlstra wrote:
> 
> Do not include private headers and do not frob in internals.
> 
> On top of that, while the previous code restores the affinity, it
> doesn't ensure the task actually moves there if it was running,
> leading to the fun situation that it can be observed running outside
> of its allowed mask for potentially significant time.
> 
> Use the proper API instead.

Applied, thanks Peter.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-08 19:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-08  9:44 [PATCH] io-wq: Fix io_wq_worker_affinity() Peter Zijlstra
2021-04-08 19:43 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox