public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH tools/io_uring] tools/io_uring: correctly set "ret" for sq_poll case
@ 2023-02-21  7:37 Ziyang Zhang
  2023-02-23  3:46 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Ziyang Zhang @ 2023-02-21  7:37 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, linux-kernel, Ziyang Zhang

For sq_poll case, "ret" is not initialized or cleared/set. In this way,
output of this test program is incorrect and we can not even stop this
program by pressing CTRL-C.

Reset "ret" to zero in each submission/completion round, and assign
"ret" to "this_reap".

Signed-off-by: Ziyang Zhang <[email protected]>
---
 tools/io_uring/io_uring-bench.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/io_uring/io_uring-bench.c b/tools/io_uring/io_uring-bench.c
index 7703f0118385..3c0feb48f6f6 100644
--- a/tools/io_uring/io_uring-bench.c
+++ b/tools/io_uring/io_uring-bench.c
@@ -289,6 +289,7 @@ static void *submitter_fn(void *data)
 	do {
 		int to_wait, to_submit, this_reap, to_prep;
 
+		ret = 0;
 		if (!prepped && s->inflight < DEPTH) {
 			to_prep = min(DEPTH - s->inflight, BATCH_SUBMIT);
 			prepped = prep_more_ios(s, to_prep);
@@ -334,6 +335,8 @@ static void *submitter_fn(void *data)
 				this_reap += r;
 		} while (sq_thread_poll && this_reap < to_wait);
 		s->reaps += this_reap;
+		if (sq_thread_poll)
+			ret = this_reap;
 
 		if (ret >= 0) {
 			if (!ret) {
-- 
2.18.4


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

* Re: [PATCH tools/io_uring] tools/io_uring: correctly set "ret" for sq_poll case
  2023-02-21  7:37 [PATCH tools/io_uring] tools/io_uring: correctly set "ret" for sq_poll case Ziyang Zhang
@ 2023-02-23  3:46 ` Jens Axboe
  2023-02-24  2:25   ` Ziyang Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2023-02-23  3:46 UTC (permalink / raw)
  To: Ziyang Zhang, asml.silence; +Cc: io-uring, linux-kernel

On 2/21/23 12:37?AM, Ziyang Zhang wrote:
> For sq_poll case, "ret" is not initialized or cleared/set. In this way,
> output of this test program is incorrect and we can not even stop this
> program by pressing CTRL-C.
> 
> Reset "ret" to zero in each submission/completion round, and assign
> "ret" to "this_reap".

Can you check if this issue also exists in the fio copy of this, which
is t/io_uring.c in:

git://git.kernel.dk/fio

The copy in the kernel is pretty outdated at this point, and should
probably get removed. But if the bug is in the above main version, then
we should fix it there and then ponder if we want to remove the one in
the kernel or just get it updated to match the upstream version.

-- 
Jens Axboe


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

* Re: [PATCH tools/io_uring] tools/io_uring: correctly set "ret" for sq_poll case
  2023-02-23  3:46 ` Jens Axboe
@ 2023-02-24  2:25   ` Ziyang Zhang
  2023-02-24  2:29     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Ziyang Zhang @ 2023-02-24  2:25 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, linux-kernel, asml.silence

On 2023/2/23 11:46, Jens Axboe wrote:
> On 2/21/23 12:37?AM, Ziyang Zhang wrote:
>> For sq_poll case, "ret" is not initialized or cleared/set. In this way,
>> output of this test program is incorrect and we can not even stop this
>> program by pressing CTRL-C.
>>
>> Reset "ret" to zero in each submission/completion round, and assign
>> "ret" to "this_reap".
> 
> Can you check if this issue also exists in the fio copy of this, which
> is t/io_uring.c in:
> 
> git://git.kernel.dk/fio
> 
> The copy in the kernel is pretty outdated at this point, and should
> probably get removed. But if the bug is in the above main version, then
> we should fix it there and then ponder if we want to remove the one in
> the kernel or just get it updated to match the upstream version.
> 

Hi Jens,

I have checked t/io_uring.c and the code is correct with sq_poll.

Regards,
Zhang

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

* Re: [PATCH tools/io_uring] tools/io_uring: correctly set "ret" for sq_poll case
  2023-02-24  2:25   ` Ziyang Zhang
@ 2023-02-24  2:29     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2023-02-24  2:29 UTC (permalink / raw)
  To: Ziyang Zhang; +Cc: io-uring, linux-kernel, asml.silence

On 2/23/23 7:25 PM, Ziyang Zhang wrote:
> On 2023/2/23 11:46, Jens Axboe wrote:
>> On 2/21/23 12:37?AM, Ziyang Zhang wrote:
>>> For sq_poll case, "ret" is not initialized or cleared/set. In this way,
>>> output of this test program is incorrect and we can not even stop this
>>> program by pressing CTRL-C.
>>>
>>> Reset "ret" to zero in each submission/completion round, and assign
>>> "ret" to "this_reap".
>>
>> Can you check if this issue also exists in the fio copy of this, which
>> is t/io_uring.c in:
>>
>> git://git.kernel.dk/fio
>>
>> The copy in the kernel is pretty outdated at this point, and should
>> probably get removed. But if the bug is in the above main version, then
>> we should fix it there and then ponder if we want to remove the one in
>> the kernel or just get it updated to match the upstream version.
>>
> 
> Hi Jens,
> 
> I have checked t/io_uring.c and the code is correct with sq_poll.

OK good, I'll attempt a sync with the kernel copy...

-- 
Jens Axboe



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

end of thread, other threads:[~2023-02-24  2:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-21  7:37 [PATCH tools/io_uring] tools/io_uring: correctly set "ret" for sq_poll case Ziyang Zhang
2023-02-23  3:46 ` Jens Axboe
2023-02-24  2:25   ` Ziyang Zhang
2023-02-24  2:29     ` Jens Axboe

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