* [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries
@ 2019-10-23 1:57 Jackie Liu
2019-10-23 18:42 ` Jeff Moyer
0 siblings, 1 reply; 5+ messages in thread
From: Jackie Liu @ 2019-10-23 1:57 UTC (permalink / raw)
To: axboe; +Cc: linux-block, liuyun01
If cq_entries is smaller than sq_entries, it will cause a lot of overflow
to appear. when customizing cq_entries, at least let him be no smaller than
sq_entries.
Fixes: 95d8765bd9f2 ("io_uring: allow application controlled CQ ring size")
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
fs/io_uring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index b64cd2c..dfa9731 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3784,7 +3784,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
* to a power-of-two, if it isn't already. We do NOT impose
* any cq vs sq ring sizing.
*/
- if (!p->cq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
+ if (p->cq_entries < p->sq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
return -EINVAL;
p->cq_entries = roundup_pow_of_two(p->cq_entries);
} else {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries
2019-10-23 1:57 [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries Jackie Liu
@ 2019-10-23 18:42 ` Jeff Moyer
2019-10-23 19:41 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Moyer @ 2019-10-23 18:42 UTC (permalink / raw)
To: Jackie Liu; +Cc: axboe, linux-block
Jackie Liu <liuyun01@kylinos.cn> writes:
> If cq_entries is smaller than sq_entries, it will cause a lot of overflow
> to appear. when customizing cq_entries, at least let him be no smaller than
> sq_entries.
>
> Fixes: 95d8765bd9f2 ("io_uring: allow application controlled CQ ring size")
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
> fs/io_uring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index b64cd2c..dfa9731 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -3784,7 +3784,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
> * to a power-of-two, if it isn't already. We do NOT impose
> * any cq vs sq ring sizing.
> */
> - if (!p->cq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
> + if (p->cq_entries < p->sq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
What if they're both zero? I think you want to keep that check.
-Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries
2019-10-23 18:42 ` Jeff Moyer
@ 2019-10-23 19:41 ` Jens Axboe
2019-10-24 0:22 ` Jackie Liu
0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2019-10-23 19:41 UTC (permalink / raw)
To: Jeff Moyer, Jackie Liu; +Cc: linux-block
On 10/23/19 12:42 PM, Jeff Moyer wrote:
> Jackie Liu <liuyun01@kylinos.cn> writes:
>
>> If cq_entries is smaller than sq_entries, it will cause a lot of overflow
>> to appear. when customizing cq_entries, at least let him be no smaller than
>> sq_entries.
>>
>> Fixes: 95d8765bd9f2 ("io_uring: allow application controlled CQ ring size")
>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
>> ---
>> fs/io_uring.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index b64cd2c..dfa9731 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -3784,7 +3784,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
>> * to a power-of-two, if it isn't already. We do NOT impose
>> * any cq vs sq ring sizing.
>> */
>> - if (!p->cq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
>> + if (p->cq_entries < p->sq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
>
> What if they're both zero? I think you want to keep that check.
sq_entries being zero is already checked and failed at this point.
So I think the patch looks fine from that perspective.
Is there really a strong reason to disallow this? Yes, it could
cause overflows, but it's just doing what was asked for. The
normal case is of course cq_entries being much larger than
sq_entries.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries
2019-10-23 19:41 ` Jens Axboe
@ 2019-10-24 0:22 ` Jackie Liu
2019-10-24 3:26 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Jackie Liu @ 2019-10-24 0:22 UTC (permalink / raw)
To: Jens Axboe; +Cc: Jeff Moyer, linux-block
> 2019年10月24日 03:41,Jens Axboe <axboe@kernel.dk> 写道:
>
> On 10/23/19 12:42 PM, Jeff Moyer wrote:
>> Jackie Liu <liuyun01@kylinos.cn> writes:
>>
>>> If cq_entries is smaller than sq_entries, it will cause a lot of overflow
>>> to appear. when customizing cq_entries, at least let him be no smaller than
>>> sq_entries.
>>>
>>> Fixes: 95d8765bd9f2 ("io_uring: allow application controlled CQ ring size")
>>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
>>> ---
>>> fs/io_uring.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>>> index b64cd2c..dfa9731 100644
>>> --- a/fs/io_uring.c
>>> +++ b/fs/io_uring.c
>>> @@ -3784,7 +3784,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
>>> * to a power-of-two, if it isn't already. We do NOT impose
>>> * any cq vs sq ring sizing.
>>> */
>>> - if (!p->cq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
>>> + if (p->cq_entries < p->sq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
>>
>> What if they're both zero? I think you want to keep that check.
>
> sq_entries being zero is already checked and failed at this point.
> So I think the patch looks fine from that perspective.
>
> Is there really a strong reason to disallow this? Yes, it could
> cause overflows, but it's just doing what was asked for. The
> normal case is of course cq_entries being much larger than
> sq_entries.
>
There are actually no other stronger reasons. I think it would be better to do a
print job in liburing, but the kernel should still make a limit. Too many overflows
will cause less efficiency.
--
Jackie Liu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries
2019-10-24 0:22 ` Jackie Liu
@ 2019-10-24 3:26 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2019-10-24 3:26 UTC (permalink / raw)
To: Jackie Liu; +Cc: Jeff Moyer, linux-block
On 10/23/19 6:22 PM, Jackie Liu wrote:
>
>
>> 2019年10月24日 03:41,Jens Axboe <axboe@kernel.dk> 写道:
>>
>> On 10/23/19 12:42 PM, Jeff Moyer wrote:
>>> Jackie Liu <liuyun01@kylinos.cn> writes:
>>>
>>>> If cq_entries is smaller than sq_entries, it will cause a lot of overflow
>>>> to appear. when customizing cq_entries, at least let him be no smaller than
>>>> sq_entries.
>>>>
>>>> Fixes: 95d8765bd9f2 ("io_uring: allow application controlled CQ ring size")
>>>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
>>>> ---
>>>> fs/io_uring.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>>>> index b64cd2c..dfa9731 100644
>>>> --- a/fs/io_uring.c
>>>> +++ b/fs/io_uring.c
>>>> @@ -3784,7 +3784,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p)
>>>> * to a power-of-two, if it isn't already. We do NOT impose
>>>> * any cq vs sq ring sizing.
>>>> */
>>>> - if (!p->cq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
>>>> + if (p->cq_entries < p->sq_entries || p->cq_entries > IORING_MAX_CQ_ENTRIES)
>>>
>>> What if they're both zero? I think you want to keep that check.
>>
>> sq_entries being zero is already checked and failed at this point.
>> So I think the patch looks fine from that perspective.
>>
>> Is there really a strong reason to disallow this? Yes, it could
>> cause overflows, but it's just doing what was asked for. The
>> normal case is of course cq_entries being much larger than
>> sq_entries.
>>
>
> There are actually no other stronger reasons. I think it would be better to do a
> print job in liburing, but the kernel should still make a limit. Too many overflows
> will cause less efficiency.
Taken to the extreme, it's clearly an issue. You could setup sq 128
entries, with 1 cq entry. That'd work as long as you never drive more
than 1 sq entry, but it makes very little sense.
Since we used to have cq == 2 * sq (and still do, by default), I think
the change to ensure that cq >= sq makes sense. I'll apply it, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-24 3:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23 1:57 [PATCH] io_uring: ensure cq_entries is at least equal to or greater than sq_entries Jackie Liu
2019-10-23 18:42 ` Jeff Moyer
2019-10-23 19:41 ` Jens Axboe
2019-10-24 0:22 ` Jackie Liu
2019-10-24 3:26 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.