IO-Uring Archive on lore.kernel.org
 help / color / Atom feed
* Question about patch "io_uring: add submission polling"
@ 2020-10-16  8:55 Xiaoguang Wang
  2020-10-16 13:27 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Xiaoguang Wang @ 2020-10-16  8:55 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, Pavel Begunkov, Stefano Garzarella

hi,

I have questions about below code comments, which was included in patch
"io_uring: add submission polling",
------------------------------------------------------------
     /*
      * Drop cur_mm before scheduling, we can't hold it for
      * long periods (or over schedule()). Do this before
      * adding ourselves to the waitqueue, as the unuse/drop
      * may sleep.
      */
     if (cur_mm) {
             unuse_mm(cur_mm);
             mmput(cur_mm);
             cur_mm = NULL;
     }

     prepare_to_wait(&ctx->sqo_wait, &wait, TASK_INTERRUPTIBLE);
-------------------------------------------------------------
Stefano submited a patch "io_uring: prevent sq_thread from spinning when it should stop",
I understand what issue Stefano fixed, but don't understand below comments.

Can anyone help to explain why we need to rop cur_mm before scheduling, or
why we can't hold it for long periods (or over schedule()), and if we
unuse/drop mm after adding ourselves to the waitqueue, what issue will
happen when unuse/drop sleeps, thanks.

Regards,
Xiaoguang Wang

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

* Re: Question about patch "io_uring: add submission polling"
  2020-10-16  8:55 Question about patch "io_uring: add submission polling" Xiaoguang Wang
@ 2020-10-16 13:27 ` Jens Axboe
  2020-10-19  2:52   ` Xiaoguang Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-10-16 13:27 UTC (permalink / raw)
  To: Xiaoguang Wang, io-uring; +Cc: Pavel Begunkov, Stefano Garzarella

On 10/16/20 2:55 AM, Xiaoguang Wang wrote:
> hi,
> 
> I have questions about below code comments, which was included in patch
> "io_uring: add submission polling",
> ------------------------------------------------------------
>      /*
>       * Drop cur_mm before scheduling, we can't hold it for
>       * long periods (or over schedule()). Do this before
>       * adding ourselves to the waitqueue, as the unuse/drop
>       * may sleep.
>       */
>      if (cur_mm) {
>              unuse_mm(cur_mm);
>              mmput(cur_mm);
>              cur_mm = NULL;
>      }
> 
>      prepare_to_wait(&ctx->sqo_wait, &wait, TASK_INTERRUPTIBLE);
> -------------------------------------------------------------
> Stefano submited a patch "io_uring: prevent sq_thread from spinning when it should stop",
> I understand what issue Stefano fixed, but don't understand below comments.
> 
> Can anyone help to explain why we need to rop cur_mm before scheduling, or
> why we can't hold it for long periods (or over schedule()), and if we
> unuse/drop mm after adding ourselves to the waitqueue, what issue will
> happen when unuse/drop sleeps, thanks.

The not holding it too long it just trying to be nice. But we can't drop
it after we've done prepare_to_wait(), as that sets our task runstate to
a non-running state. This conflicts with with mmput(), which might
sleep.

-- 
Jens Axboe


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

* Re: Question about patch "io_uring: add submission polling"
  2020-10-16 13:27 ` Jens Axboe
@ 2020-10-19  2:52   ` Xiaoguang Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Xiaoguang Wang @ 2020-10-19  2:52 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: Pavel Begunkov, Stefano Garzarella

hi,

> On 10/16/20 2:55 AM, Xiaoguang Wang wrote:
>> hi,
>>
>> I have questions about below code comments, which was included in patch
>> "io_uring: add submission polling",
>> ------------------------------------------------------------
>>       /*
>>        * Drop cur_mm before scheduling, we can't hold it for
>>        * long periods (or over schedule()). Do this before
>>        * adding ourselves to the waitqueue, as the unuse/drop
>>        * may sleep.
>>        */
>>       if (cur_mm) {
>>               unuse_mm(cur_mm);
>>               mmput(cur_mm);
>>               cur_mm = NULL;
>>       }
>>
>>       prepare_to_wait(&ctx->sqo_wait, &wait, TASK_INTERRUPTIBLE);
>> -------------------------------------------------------------
>> Stefano submited a patch "io_uring: prevent sq_thread from spinning when it should stop",
>> I understand what issue Stefano fixed, but don't understand below comments.
>>
>> Can anyone help to explain why we need to rop cur_mm before scheduling, or
>> why we can't hold it for long periods (or over schedule()), and if we
>> unuse/drop mm after adding ourselves to the waitqueue, what issue will
>> happen when unuse/drop sleeps, thanks.
> 
> The not holding it too long it just trying to be nice. But we can't drop
> it after we've done prepare_to_wait(), as that sets our task runstate to
> a non-running state. This conflicts with with mmput(), which might
> sleep.
I see, thanks.
Now I'm trying to improve io_sq_thread a bit and will send patches soon.

Regards,
Xiaoguang Wang
> 

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16  8:55 Question about patch "io_uring: add submission polling" Xiaoguang Wang
2020-10-16 13:27 ` Jens Axboe
2020-10-19  2:52   ` Xiaoguang Wang

IO-Uring Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/io-uring/0 io-uring/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 io-uring io-uring/ https://lore.kernel.org/io-uring \
		io-uring@vger.kernel.org
	public-inbox-index io-uring

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.io-uring


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git