All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org
Cc: Lin Horse <kylin.formalin@gmail.com>
Subject: Re: [PATCH for-6.1 v2] io_uring: make poll refs more robust
Date: Fri, 18 Nov 2022 15:43:42 -0700	[thread overview]
Message-ID: <0ceb5339-c84e-dbe4-2a69-9c1bc92c7221@kernel.dk> (raw)
In-Reply-To: <f95c8321-3f64-4a34-7fdd-343e4a6718d3@gmail.com>

On 11/18/22 3:39 PM, Pavel Begunkov wrote:
> On 11/18/22 20:20, Pavel Begunkov wrote:
>> poll_refs carry two functions, the first is ownership over the request.
>> The second is notifying the io_poll_check_events() that there was an
>> event but wake up couldn't grab the ownership, so io_poll_check_events()
>> should retry.
>>
>> We want to make poll_refs more robust against overflows. Instead of
>> always incrementing it, which covers two purposes with one atomic, check
>> if poll_refs is large and if so set a retry flag without attempts to
>> grab ownership. The gap between the bias check and following atomics may
>> seem racy, but we don't need it to be strict. Moreover there might only
>> be maximum 4 parallel updates: by the first and the second poll entries,
>> __io_arm_poll_handler() and cancellation. From those four, only poll wake
>> ups may be executed multiple times, but they're protected by a spin.
>>
>> Cc: stable@vger.kernel.org
>> Reported-by: Lin Horse <kylin.formalin@gmail.com>
>> Fixes: aa43477b04025 ("io_uring: poll rework")
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>> ---
> [...]
>> @@ -590,7 +624,7 @@ static int __io_arm_poll_handler(struct io_kiocb *req,
>>            * locked, kick it off for them.
>>            */
>>           v = atomic_dec_return(&req->poll_refs);
>> -        if (unlikely(v & IO_POLL_REF_MASK))
>> +        if (unlikely(v & IO_POLL_RETRY_MASK))
> 
> Still no good, this chunk is about ownership and so should use
> IO_POLL_REF_MASK as before. Jens, please drop the patch, needs
> more testing

Bummed - I dropped it for now.

-- 
Jens Axboe



      reply	other threads:[~2022-11-18 22:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 20:20 [PATCH for-6.1 v2] io_uring: make poll refs more robust Pavel Begunkov
2022-11-18 21:08 ` Jens Axboe
2022-11-18 22:39 ` Pavel Begunkov
2022-11-18 22:43   ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0ceb5339-c84e-dbe4-2a69-9c1bc92c7221@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=kylin.formalin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.