Skip to contentSkip to conversation

Question about patch "io_uring: add submission polling"

DISCUSSION Xiaoguang Wang 2 participants 3 messages Oct 16, 2020 – Oct 19, 2020 io_uring

lore
Share & tools
lore
#0 lore raw

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

maintainer
#1 lore raw
Quoted 18 lines · Xiaoguang Wang

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);
Quoted 8 lines

-------------------------------------------------------------
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.

Signature · 1 line
Jens Axboe
#2 lore raw

hi,

Quoted 28 lines · Xiaoguang Wang
Quoted 18 lines

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);
Quoted 8 lines

-------------------------------------------------------------
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.

Quoted 4 lines

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

Quoted 1 line