From: Pavel Begunkov <[email protected]>
io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
passes something opposite.
Signed-off-by: Pavel Begunkov <[email protected]>
---
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 c934f91c51e9..ffe66512ca07 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2761,7 +2761,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
if (link)
io_queue_link_head(ctx, link, &link->submit, shadow_req,
- block_for_last);
+ force_nonblock);
if (statep)
io_submit_state_end(statep);
--
2.23.0
I haven't followed the code path properly, but it looks strange to me.
Jens, could you take a look?
On 04/10/2019 11:25, Pavel Begunkov (Silence) wrote:
> From: Pavel Begunkov <[email protected]>
>
> io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
> passes something opposite.
>
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
> 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 c934f91c51e9..ffe66512ca07 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2761,7 +2761,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
>
> if (link)
> io_queue_link_head(ctx, link, &link->submit, shadow_req,
> - block_for_last);
> + force_nonblock);
> if (statep)
> io_submit_state_end(statep);
>
>
--
Yours sincerely,
Pavel Begunkov
Hi "Pavel,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc1 next-20191004]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Pavel-Begunkov-Silence/io_uring-Fix-reversed-nonblock-flag/20191004-163432
config: m68k-allyesconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>
All errors (new ones prefixed by >>):
fs/io_uring.c: In function 'io_ring_submit':
>> fs/io_uring.c:2764:6: error: 'force_nonblock' undeclared (first use in this function); did you mean 'tcf_block'?
force_nonblock);
^~~~~~~~~~~~~~
tcf_block
fs/io_uring.c:2764:6: note: each undeclared identifier is reported only once for each function it appears in
vim +2764 fs/io_uring.c
2697
2698 static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
2699 bool block_for_last)
2700 {
2701 struct io_submit_state state, *statep = NULL;
2702 struct io_kiocb *link = NULL;
2703 struct io_kiocb *shadow_req = NULL;
2704 bool prev_was_link = false;
2705 int i, submit = 0;
2706
2707 if (to_submit > IO_PLUG_THRESHOLD) {
2708 io_submit_state_start(&state, ctx, to_submit);
2709 statep = &state;
2710 }
2711
2712 for (i = 0; i < to_submit; i++) {
2713 bool force_nonblock = true;
2714 struct sqe_submit s;
2715
2716 if (!io_get_sqring(ctx, &s))
2717 break;
2718
2719 /*
2720 * If previous wasn't linked and we have a linked command,
2721 * that's the end of the chain. Submit the previous link.
2722 */
2723 if (!prev_was_link && link) {
2724 io_queue_link_head(ctx, link, &link->submit, shadow_req,
2725 force_nonblock);
2726 link = NULL;
2727 shadow_req = NULL;
2728 }
2729 prev_was_link = (s.sqe->flags & IOSQE_IO_LINK) != 0;
2730
2731 if (link && (s.sqe->flags & IOSQE_IO_DRAIN)) {
2732 if (!shadow_req) {
2733 shadow_req = io_get_req(ctx, NULL);
2734 if (unlikely(!shadow_req))
2735 goto out;
2736 shadow_req->flags |= (REQ_F_IO_DRAIN | REQ_F_SHADOW_DRAIN);
2737 refcount_dec(&shadow_req->refs);
2738 }
2739 shadow_req->sequence = s.sequence;
2740 }
2741
2742 out:
2743 s.has_user = true;
2744 s.needs_lock = false;
2745 s.needs_fixed_file = false;
2746 submit++;
2747
2748 /*
2749 * The caller will block for events after submit, submit the
2750 * last IO non-blocking. This is either the only IO it's
2751 * submitting, or it already submitted the previous ones. This
2752 * improves performance by avoiding an async punt that we don't
2753 * need to do.
2754 */
2755 if (block_for_last && submit == to_submit)
2756 force_nonblock = false;
2757
2758 io_submit_sqe(ctx, &s, statep, &link, force_nonblock);
2759 }
2760 io_commit_sqring(ctx);
2761
2762 if (link)
2763 io_queue_link_head(ctx, link, &link->submit, shadow_req,
> 2764 force_nonblock);
2765 if (statep)
2766 io_submit_state_end(statep);
2767
2768 return submit;
2769 }
2770
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi "Pavel,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc1 next-20191002]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Pavel-Begunkov-Silence/io_uring-Fix-reversed-nonblock-flag/20191004-163432
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sparc
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>
All errors (new ones prefixed by >>):
fs/io_uring.c: In function 'io_ring_submit':
>> fs/io_uring.c:2764:6: error: 'force_nonblock' undeclared (first use in this function); did you mean 'lock_pin_lock'?
force_nonblock);
^~~~~~~~~~~~~~
lock_pin_lock
fs/io_uring.c:2764:6: note: each undeclared identifier is reported only once for each function it appears in
vim +2764 fs/io_uring.c
2697
2698 static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
2699 bool block_for_last)
2700 {
2701 struct io_submit_state state, *statep = NULL;
2702 struct io_kiocb *link = NULL;
2703 struct io_kiocb *shadow_req = NULL;
2704 bool prev_was_link = false;
2705 int i, submit = 0;
2706
2707 if (to_submit > IO_PLUG_THRESHOLD) {
2708 io_submit_state_start(&state, ctx, to_submit);
2709 statep = &state;
2710 }
2711
2712 for (i = 0; i < to_submit; i++) {
2713 bool force_nonblock = true;
2714 struct sqe_submit s;
2715
2716 if (!io_get_sqring(ctx, &s))
2717 break;
2718
2719 /*
2720 * If previous wasn't linked and we have a linked command,
2721 * that's the end of the chain. Submit the previous link.
2722 */
2723 if (!prev_was_link && link) {
2724 io_queue_link_head(ctx, link, &link->submit, shadow_req,
2725 force_nonblock);
2726 link = NULL;
2727 shadow_req = NULL;
2728 }
2729 prev_was_link = (s.sqe->flags & IOSQE_IO_LINK) != 0;
2730
2731 if (link && (s.sqe->flags & IOSQE_IO_DRAIN)) {
2732 if (!shadow_req) {
2733 shadow_req = io_get_req(ctx, NULL);
2734 if (unlikely(!shadow_req))
2735 goto out;
2736 shadow_req->flags |= (REQ_F_IO_DRAIN | REQ_F_SHADOW_DRAIN);
2737 refcount_dec(&shadow_req->refs);
2738 }
2739 shadow_req->sequence = s.sequence;
2740 }
2741
2742 out:
2743 s.has_user = true;
2744 s.needs_lock = false;
2745 s.needs_fixed_file = false;
2746 submit++;
2747
2748 /*
2749 * The caller will block for events after submit, submit the
2750 * last IO non-blocking. This is either the only IO it's
2751 * submitting, or it already submitted the previous ones. This
2752 * improves performance by avoiding an async punt that we don't
2753 * need to do.
2754 */
2755 if (block_for_last && submit == to_submit)
2756 force_nonblock = false;
2757
2758 io_submit_sqe(ctx, &s, statep, &link, force_nonblock);
2759 }
2760 io_commit_sqring(ctx);
2761
2762 if (link)
2763 io_queue_link_head(ctx, link, &link->submit, shadow_req,
> 2764 force_nonblock);
2765 if (statep)
2766 io_submit_state_end(statep);
2767
2768 return submit;
2769 }
2770
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
From: Pavel Begunkov <[email protected]>
io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
passes something opposite.
v2: fix build error by test robot: Rebase from custom tree
Reported-by: kbuild test robot <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index c934f91c51e9..c909ea2b84e9 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2703,6 +2703,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
struct io_kiocb *shadow_req = NULL;
bool prev_was_link = false;
int i, submit = 0;
+ bool force_nonblock = true;
if (to_submit > IO_PLUG_THRESHOLD) {
io_submit_state_start(&state, ctx, to_submit);
@@ -2710,9 +2711,9 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
}
for (i = 0; i < to_submit; i++) {
- bool force_nonblock = true;
struct sqe_submit s;
+ force_nonblock = true;
if (!io_get_sqring(ctx, &s))
break;
@@ -2761,7 +2762,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
if (link)
io_queue_link_head(ctx, link, &link->submit, shadow_req,
- block_for_last);
+ force_nonblock);
if (statep)
io_submit_state_end(statep);
--
2.23.0
On 10/4/19 4:07 AM, Pavel Begunkov (Silence) wrote:
> From: Pavel Begunkov <[email protected]>
>
> io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
> passes something opposite.
>
> v2: fix build error by test robot: Rebase from custom tree
> Reported-by: kbuild test robot <[email protected]>
>
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
> fs/io_uring.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index c934f91c51e9..c909ea2b84e9 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2703,6 +2703,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
> struct io_kiocb *shadow_req = NULL;
> bool prev_was_link = false;
> int i, submit = 0;
> + bool force_nonblock = true;
>
> if (to_submit > IO_PLUG_THRESHOLD) {
> io_submit_state_start(&state, ctx, to_submit);
> @@ -2710,9 +2711,9 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
> }
>
> for (i = 0; i < to_submit; i++) {
> - bool force_nonblock = true;
> struct sqe_submit s;
>
> + force_nonblock = true;
> if (!io_get_sqring(ctx, &s))
> break;
>
> @@ -2761,7 +2762,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
>
> if (link)
> io_queue_link_head(ctx, link, &link->submit, shadow_req,
> - block_for_last);
> + force_nonblock);
> if (statep)
> io_submit_state_end(statep);
Shouldn't this just be:
io_queue_link_head(ctx, link, &link->submit, shadow_req,
!block_for_last);
We're outside the loop, so by definition at the end of what we need to
do. We don't need to factor in the fiddling of force_nonblock here,
it'll be false at this point anyway. Only exception is error handling,
if the caller asked for more than what was in the ring. Not a big
deal...
--
Jens Axboe
On 04/10/2019 16:05, Jens Axboe wrote:
> On 10/4/19 4:07 AM, Pavel Begunkov (Silence) wrote:
>> From: Pavel Begunkov <[email protected]>
>>
>> io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
>> passes something opposite.
>>
>> v2: fix build error by test robot: Rebase from custom tree
>> Reported-by: kbuild test robot <[email protected]>
>>
>> Signed-off-by: Pavel Begunkov <[email protected]>
>> ---
>> fs/io_uring.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index c934f91c51e9..c909ea2b84e9 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -2703,6 +2703,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
>> struct io_kiocb *shadow_req = NULL;
>> bool prev_was_link = false;
>> int i, submit = 0;
>> + bool force_nonblock = true;
>>
>> if (to_submit > IO_PLUG_THRESHOLD) {
>> io_submit_state_start(&state, ctx, to_submit);
>> @@ -2710,9 +2711,9 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
>> }
>>
>> for (i = 0; i < to_submit; i++) {
>> - bool force_nonblock = true;
>> struct sqe_submit s;
>>
>> + force_nonblock = true;
>> if (!io_get_sqring(ctx, &s))
>> break;
>>
>> @@ -2761,7 +2762,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
>>
>> if (link)
>> io_queue_link_head(ctx, link, &link->submit, shadow_req,
>> - block_for_last);
>> + force_nonblock);
>> if (statep)
>> io_submit_state_end(statep);
>
> Shouldn't this just be:
>
> io_queue_link_head(ctx, link, &link->submit, shadow_req,
> !block_for_last);
>
> We're outside the loop, so by definition at the end of what we need to
> do. We don't need to factor in the fiddling of force_nonblock here,
> it'll be false at this point anyway. Only exception is error handling,
> if the caller asked for more than what was in the ring. Not a big
> deal...
Thanks for explaining this, I'll resend.
Played safe because of breaks in the loop.
--
Yours sincerely,
Pavel Begunkov
From: Pavel Begunkov <[email protected]>
io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
passes something opposite.
v2: build error from test robot: Rebase to block-tree
v3: simplify with Jens suggestion
Reported-by: kbuild test robot <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
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 c934f91c51e9..b58c3d8594d8 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2761,7 +2761,7 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit,
if (link)
io_queue_link_head(ctx, link, &link->submit, shadow_req,
- block_for_last);
+ !block_for_last);
if (statep)
io_submit_state_end(statep);
--
2.23.0
On 10/4/19 8:01 AM, Pavel Begunkov (Silence) wrote:
> From: Pavel Begunkov <[email protected]>
>
> io_queue_link_head() accepts @force_nonblock flag, but io_ring_submit()
> passes something opposite.
>
> v2: build error from test robot: Rebase to block-tree
> v3: simplify with Jens suggestion
Thanks, looks good to me. Two minor notes that I fixed up:
1) The revision history should go below the --- line
2) I've added a Fixes tag
--
Jens Axboe