public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: David Hildenbrand <david@redhat.com>, io-uring@vger.kernel.org
Subject: Re: [PATCH v2 1/3] io_uring/rsrc: fix folio unpinning
Date: Wed, 25 Jun 2025 21:33:57 +0100	[thread overview]
Message-ID: <faff225e-9396-40e1-9a7f-1d69010370ab@gmail.com> (raw)
In-Reply-To: <d51f982c-f487-491e-b105-cd858f39e6e3@redhat.com>

On 6/25/25 08:53, David Hildenbrand wrote:
...>>   static struct io_mapped_ubuf *io_alloc_imu(struct io_ring_ctx *ctx,
>> @@ -810,7 +813,8 @@ static struct io_rsrc_node *io_sqe_buffer_register(struct io_ring_ctx *ctx,
>>       imu->nr_bvecs = nr_pages;
>>       ret = io_buffer_account_pin(ctx, pages, nr_pages, imu, last_hpage);
>>       if (ret) {
>> -        unpin_user_pages(pages, nr_pages);
>> +        for (i = 0; i < nr_pages; i++)
>> +            unpin_user_folio(page_folio(pages[i]), 1);
>>           goto done;
>>       }
> 
> It should fix the issue, but it's a bit suboptimal in the case where we didn't coalesc, but there are folio ranges to coalesc:
> 
> unpin_user_pages() does a per-folio coalescing.
> 
> So in an ideal world, we would cleanly split both paths, and work with folios after we coalesced to use folios, and work with pages, when we didn't coalesc to use folios.

Agreed, but I'm not too much concerned, it's a slow path, users
should be mindful while registering memory. Localised hammering
on the refcount is not great but ultimately shouldn't matter much.

> Then, we can just use unpin_folios() after we coalesced.
> 
> In any case, for a fix this is good enough, but probably we can do better later.
> 
> Acked-by: David Hildenbrand <david@redhat.com>

Thanks for the report!

-- 
Pavel Begunkov


  reply	other threads:[~2025-06-25 20:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 13:40 [PATCH v2 0/3] io_uring mm related abuses Pavel Begunkov
2025-06-24 13:40 ` [PATCH v2 1/3] io_uring/rsrc: fix folio unpinning Pavel Begunkov
2025-06-25  7:53   ` David Hildenbrand
2025-06-25 20:33     ` Pavel Begunkov [this message]
2025-06-24 13:40 ` [PATCH v2 2/3] io_uring/rsrc: don't rely on user vaddr alignment Pavel Begunkov
2025-06-26  9:30   ` David Hildenbrand
2025-06-24 13:40 ` [PATCH v2 3/3] io_uring: don't assume uaddr alignment in io_vec_fill_bvec Pavel Begunkov
2025-06-25  2:52 ` [PATCH v2 0/3] io_uring mm related abuses Jens Axboe
2025-06-25 20:24   ` Pavel Begunkov
2025-06-25 22:36     ` Jens Axboe
2025-06-25  2:52 ` Jens Axboe

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=faff225e-9396-40e1-9a7f-1d69010370ab@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=david@redhat.com \
    --cc=io-uring@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox