From: Pavel Begunkov <[email protected]>
To: Chenliang Li <[email protected]>, [email protected]
Cc: [email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected]
Subject: Re: [PATCH v6 2/2] io_uring/rsrc: enable multi-hugepage buffer coalescing
Date: Mon, 22 Jul 2024 14:12:48 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 7/16/24 07:08, Chenliang Li wrote:
> Add support for checking and coalescing multi-hugepage-backed fixed
> buffers. The coalescing optimizes both 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 processing later,
> also we need same size'd chunks in io_import_fixed for fast iov_iter
> adjust.
>
> Signed-off-by: Chenliang Li <[email protected]>
> ---
The series looks good apart from the comment below, I'll run some
tests this week, I think you sent something for liburing/test
> +static bool io_try_coalesce_buffer(struct page ***pages, int *nr_pages,
> + struct io_imu_folio_data *data)
> +{
> + struct page **page_array = *pages;
> + struct folio *folio = page_folio(page_array[0]);
> + unsigned int count = 1, nr_folios = 1;
> + int i;
> +
> + if (*nr_pages <= 1)
> + return false;
> +
> + data->nr_pages_mid = folio_nr_pages(folio);
> + if (data->nr_pages_mid == 1)
> + return false;
> +
> + data->folio_shift = folio_shift(folio);
> + /*
> + * Check if pages are contiguous inside a folio, and all folios have
> + * the same page count except for the head and tail.
> + */
> + for (i = 1; i < *nr_pages; i++) {
> + if (page_folio(page_array[i]) == folio &&
> + page_array[i] == page_array[i-1] + 1) {
> + count++;
> + continue;
> + }
> +
> + if (nr_folios == 1) {
> + if (folio_page_idx(folio, page_array[i-1])
> + != data->nr_pages_mid - 1)
Code style, comparison (i.e. "!=") should be on the previous line
> + return false;
> +
> + data->nr_pages_head = count;
> + } else if (count != data->nr_pages_mid) {
> + return false;
> + }
> +
> + folio = page_folio(page_array[i]);
> + if (folio_size(folio) != (1UL << data->folio_shift) ||
> + folio_page_idx(folio, page_array[i]) != 0)
> + return false;
> +
> + count = 1;
> + nr_folios++;
> + }
> + if (nr_folios == 1) {
> + if (folio_page_idx(folio, page_array[i-1])
> + != data->nr_pages_mid - 1)
That's too restrictive and would be a regression. We currently allow
registrations fully falling under a single huge page but not matching
the right side. E.g. for a [N; M) huge page, you're allowed to register
[N + 4KB, M - 4KB). We should just remove this check.
And same comment about code style.
> + return false;
> +
> + data->nr_pages_head = count;
> + }
> +
> + return io_do_coalesce_buffer(pages, nr_pages, data, nr_folios);
> +}
> +
--
Pavel Begunkov
prev parent reply other threads:[~2024-07-22 13:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240716060814epcas5p1af3b8ddba3f7bd951719854546a82278@epcas5p1.samsung.com>
2024-07-16 6:08 ` [PATCH v6 0/2] io_uring/rsrc: coalescing multi-hugepage registered buffers Chenliang Li
[not found] ` <CGME20240716060816epcas5p229d9f7083165acaf45256fff28536e40@epcas5p2.samsung.com>
2024-07-16 6:08 ` [PATCH v6 1/2] io_uring/rsrc: store folio shift and mask into imu Chenliang Li
[not found] ` <CGME20240716060819epcas5p3387922a068b65eca1b3ab65effcf586e@epcas5p3.samsung.com>
2024-07-16 6:08 ` [PATCH v6 2/2] io_uring/rsrc: enable multi-hugepage buffer coalescing Chenliang Li
2024-07-22 13:12 ` Pavel Begunkov [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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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