diff mbox series

[10/11] io-wq: distinguish fixed worker by its name

Message ID 20230609122031.183730-11-hao.xu@linux.dev (mailing list archive)
State New
Headers show
Series fixed worker | expand

Commit Message

Hao Xu June 9, 2023, 12:20 p.m. UTC
From: Hao Xu <howeyxu@tencent.com>

Distinguish fixed workers and normal workers by their names.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
---
 io_uring/io-wq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Pavel Begunkov July 5, 2023, 1:15 p.m. UTC | #1
On 6/9/23 13:20, Hao Xu wrote:
> From: Hao Xu <howeyxu@tencent.com>
> 
> Distinguish fixed workers and normal workers by their names.
> 
> Signed-off-by: Hao Xu <howeyxu@tencent.com>
> ---
>   io_uring/io-wq.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
> index 61cf6da2c72f..7a9e5fa19b81 100644
> --- a/io_uring/io-wq.c
> +++ b/io_uring/io-wq.c
> @@ -634,10 +634,12 @@ static int io_wq_worker(void *data)
>   	struct io_wq *wq = worker->wq;
>   	bool exit_mask = false, last_timeout = false;
>   	char buf[TASK_COMM_LEN];
> +	bool fixed = is_fixed_worker(worker);
>   
>   	worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
>   
> -	snprintf(buf, sizeof(buf), "iou-wrk-%d", wq->task->pid);
> +	snprintf(buf, sizeof(buf), fixed ? "iou-fixed-%d" : "iou-wrk-%d",
> +		 wq->task->pid);

Minor nit: iou-wrk-fixed should be better, it still tells that it's
a worker and I think it should be more familiar to users.

>   	set_task_comm(current, buf);
>   
>   	while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) {
> @@ -656,7 +658,7 @@ static int io_wq_worker(void *data)
>   		 * fixed worker, they can be manually reset to cpu other than
>   		 * the cpuset indicated by io_wq_worker_affinity()
>   		 */
> -		if (!is_fixed_worker(worker) && last_timeout &&
> +		if (!fixed && last_timeout &&
>   		    (exit_mask || acct->nr_workers > 1)) {
>   			acct->nr_workers--;
>   			raw_spin_unlock(&wq->lock);
diff mbox series

Patch

diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index 61cf6da2c72f..7a9e5fa19b81 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -634,10 +634,12 @@  static int io_wq_worker(void *data)
 	struct io_wq *wq = worker->wq;
 	bool exit_mask = false, last_timeout = false;
 	char buf[TASK_COMM_LEN];
+	bool fixed = is_fixed_worker(worker);
 
 	worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
 
-	snprintf(buf, sizeof(buf), "iou-wrk-%d", wq->task->pid);
+	snprintf(buf, sizeof(buf), fixed ? "iou-fixed-%d" : "iou-wrk-%d",
+		 wq->task->pid);
 	set_task_comm(current, buf);
 
 	while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)) {
@@ -656,7 +658,7 @@  static int io_wq_worker(void *data)
 		 * fixed worker, they can be manually reset to cpu other than
 		 * the cpuset indicated by io_wq_worker_affinity()
 		 */
-		if (!is_fixed_worker(worker) && last_timeout &&
+		if (!fixed && last_timeout &&
 		    (exit_mask || acct->nr_workers > 1)) {
 			acct->nr_workers--;
 			raw_spin_unlock(&wq->lock);