2024-05-07 15:10:11

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH v2] io_uring/io-wq: Use set_bit() and test_bit() at worker->flags

On 5/7/24 9:05 AM, Breno Leitao wrote:
> @@ -631,7 +631,7 @@ static int io_wq_worker(void *data)
> bool exit_mask = false, last_timeout = false;
> char buf[TASK_COMM_LEN];
>
> - worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
> + set_mask_bits(&worker->flags, 0, IO_WORKER_F_UP | IO_WORKER_F_RUNNING);

This takes a mask, no? I think this should be:

set_mask_bits(&worker->flags, 0, BIT(IO_WORKER_F_UP) | BIT(IO_WORKER_F_RUNNING);

Hmm?

--
Jens Axboe



2024-05-07 17:12:16

by Christophe JAILLET

[permalink] [raw]
Subject: Re: [PATCH v2] io_uring/io-wq: Use set_bit() and test_bit() at worker->flags

Le 07/05/2024 à 17:09, Jens Axboe a écrit :
> On 5/7/24 9:05 AM, Breno Leitao wrote:
>> @@ -631,7 +631,7 @@ static int io_wq_worker(void *data)
>> bool exit_mask = false, last_timeout = false;
>> char buf[TASK_COMM_LEN];
>>
>> - worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
>> + set_mask_bits(&worker->flags, 0, IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
>
> This takes a mask, no? I think this should be:
>
> set_mask_bits(&worker->flags, 0, BIT(IO_WORKER_F_UP) | BIT(IO_WORKER_F_RUNNING);
>
> Hmm?
>

Because of that:

enum {
- IO_WORKER_F_UP = 1, /* up and active */
- IO_WORKER_F_RUNNING = 2, /* account as running */
- IO_WORKER_F_FREE = 4, /* worker on free list */
- IO_WORKER_F_BOUND = 8, /* is doing bounded work */
+ IO_WORKER_F_UP = 0, /* up and active */
+ IO_WORKER_F_RUNNING = 1, /* account as running */
+ IO_WORKER_F_FREE = 2, /* worker on free list */
+ IO_WORKER_F_BOUND = 3, /* is doing bounded work */
};

yes, now, BIT() is needed.


CJ