From: Chenliang Li <cliang01.li@samsung.com>
To: asml.silence@gmail.com
Cc: anuj20.g@samsung.com, axboe@kernel.dk, cliang01.li@samsung.com,
gost.dev@samsung.com, io-uring@vger.kernel.org,
joshi.k@samsung.com, kundan.kumar@samsung.com,
peiwei.li@samsung.com
Subject: Re: [PATCH v2 0/4] io_uring/rsrc: coalescing multi-hugepage registered buffers
Date: Mon, 17 Jun 2024 11:12:10 +0800 [thread overview]
Message-ID: <20240617031210.2325-1-cliang01.li@samsung.com> (raw)
In-Reply-To: <1233b470-c190-4b8f-873d-dfbf31b6874d@gmail.com>
On Sun, 16 Jun 2024 19:04:38 +0100, Pavel Begunkov wrote:
> On 5/14/24 08:54, Chenliang Li wrote:
>> Introduce helper functions to check whether a buffer can
>> be coalesced or not, and gather folio data for later use.
>>
>> The coalescing optimizes time and space consumption caused
>> by mapping and storing multi-hugepage fixed buffers.
>>
>> A coalescable multi-hugepage buffer should fully cover its folios
>> (except potentially the first and last one), and these folios should
>> have the same size. These requirements are for easier later process,
>> also we need same size'd chunks in io_import_fixed for fast iov_iter
>> adjust.
>>
>> Signed-off-by: Chenliang Li <cliang01.li@samsung.com>
>> ---
>> io_uring/rsrc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++
>> io_uring/rsrc.h | 10 +++++++
>> 2 files changed, 88 insertions(+)
>>
>> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
>> index 65417c9553b1..d08224c0c5b0 100644
>> --- a/io_uring/rsrc.c
>> +++ b/io_uring/rsrc.c
>> @@ -871,6 +871,84 @@ static int io_buffer_account_pin(struct io_ring_ctx *ctx, struct page **pages,
>> return ret;
>> }
>>
>> +static bool __io_sqe_buffer_try_coalesce(struct page **pages, int nr_pages,
>> + struct io_imu_folio_data *data)
> io_can_coalesce_buffer(), you're not actually trying to
> do it here.
Will change it.
>> +static bool io_sqe_buffer_try_coalesce(struct page **pages, int nr_pages,
>> + struct io_imu_folio_data *data)
>> +{
>> + int i, j;
>> +
>> + if (nr_pages <= 1 ||
>> + !__io_sqe_buffer_try_coalesce(pages, nr_pages, data))
>> + return false;
>> +
>> + /*
>> + * The pages are bound to the folio, it doesn't
>> + * actually unpin them but drops all but one reference,
>> + * which is usually put down by io_buffer_unmap().
>> + * Note, needs a better helper.
>> + */
>> + if (data->nr_pages_head > 1)
>> + unpin_user_pages(&pages[1], data->nr_pages_head - 1);
> Should be pages[0]. page[1] can be in another folio, and even
> though data->nr_pages_head > 1 protects against touching it,
> it's still flimsy.
But here it is unpinning the tail pages inside those coalesceable folios,
I think we only unpin pages[0] when failure, am I right? And in
__io_sqe_buffer_try_coalesce we have ensured that pages[1:nr_head_pages] are
in same folio and contiguous.
>> +
>> + j = data->nr_pages_head;
>> + nr_pages -= data->nr_pages_head;
>> + for (i = 1; i < data->nr_folios; i++) {
>> + unsigned int nr_unpin;
>> +
>> + nr_unpin = min_t(unsigned int, nr_pages - 1,
>> + data->nr_pages_mid - 1);
>> + if (nr_unpin == 0)
>> + break;
>> + unpin_user_pages(&pages[j+1], nr_unpin);
> same
>> + j += data->nr_pages_mid;
> And instead of duplicating this voodoo iteration later,
> please just assemble a new compacted ->nr_folios sized
> page array.
Indeed, a new page array would make things a lot easier.
If alloc overhead is not a concern here, then yeah I'll change it.
Thanks,
Chenliang Li
next prev parent reply other threads:[~2024-06-17 3:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240514075453epcas5p17974fb62d65a88b1a1b55b97942ee2be@epcas5p1.samsung.com>
2024-05-14 7:54 ` [PATCH v4 0/4] io_uring/rsrc: coalescing multi-hugepage registered buffers Chenliang Li
2024-05-14 7:54 ` [PATCH v4 1/4] io_uring/rsrc: add hugepage buffer coalesce helpers Chenliang Li
2024-05-16 14:07 ` Anuj gupta
2024-06-16 18:04 ` Pavel Begunkov
2024-06-17 3:12 ` Chenliang Li [this message]
2024-06-17 12:38 ` [PATCH v2 0/4] io_uring/rsrc: coalescing multi-hugepage registered buffers Pavel Begunkov
2024-06-18 3:11 ` [PATCH v4 3/4] io_uring/rsrc: add init and account functions for coalesced imus Chenliang Li
2024-05-14 7:54 ` [PATCH v4 2/4] io_uring/rsrc: store folio shift and mask into imu Chenliang Li
2024-05-16 14:08 ` Anuj gupta
2024-05-14 7:54 ` [PATCH v4 3/4] io_uring/rsrc: add init and account functions for coalesced imus Chenliang Li
2024-06-16 17:43 ` Pavel Begunkov
2024-06-17 3:16 ` [PATCH v2 0/4] io_uring/rsrc: coalescing multi-hugepage registered buffers Chenliang Li
2024-06-17 12:22 ` Pavel Begunkov
2024-06-18 3:24 ` [PATCH v4 3/4] io_uring/rsrc: add init and account functions for coalesced imus Chenliang Li
2024-05-14 7:54 ` [PATCH v4 4/4] io_uring/rsrc: enable multi-hugepage buffer coalescing Chenliang Li
2024-05-16 14:09 ` Anuj gupta
2024-05-16 14:01 ` [PATCH v4 0/4] io_uring/rsrc: coalescing multi-hugepage registered buffers Anuj gupta
2024-05-16 14:58 ` Jens Axboe
2024-05-30 5:10 ` Chenliang Li
2024-06-04 13:33 ` Anuj gupta
2024-06-13 2:49 ` Chenliang Li
2024-06-16 2:54 ` Jens Axboe
[not found] <CGME20240511055242epcas5p46612dde17997c140232207540e789a2e@epcas5p4.samsung.com>
2024-05-11 5:52 ` [PATCH v2 " Chenliang Li
2024-05-11 16:43 ` Jens Axboe
2024-05-13 2:01 ` Chenliang Li
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=20240617031210.2325-1-cliang01.li@samsung.com \
--to=cliang01.li@samsung.com \
--cc=anuj20.g@samsung.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=gost.dev@samsung.com \
--cc=io-uring@vger.kernel.org \
--cc=joshi.k@samsung.com \
--cc=kundan.kumar@samsung.com \
--cc=peiwei.li@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox