From: Zi Yan <ziy@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>, <linux-mm@kvack.org>,
<linux-fsdevel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Kairui Song <kasong@tencent.com>,
Miaohe Lin <linmiaohe@huawei.com>, <linux-kernel@vger.kernel.org>,
Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH 0/2] Minimize xa_node allocation during xarry split
Date: Wed, 12 Feb 2025 22:46:27 -0500 [thread overview]
Message-ID: <324AA2B9-418E-423E-80B3-D75A19D52A4C@nvidia.com> (raw)
In-Reply-To: <20250213034355.516610-1-ziy@nvidia.com>
On 12 Feb 2025, at 22:43, Zi Yan wrote:
> Hi all,
>
> When splitting a multi-index entry in XArray from order-n to order-m,
> existing xas_split_alloc()+xas_split() approach requires
> 2^(n % XA_CHUNK_SHIFT) xa_node allocations. But its callers,
> __filemap_add_folio() and shmem_split_large_entry(), use at most 1 xa_node.
> To minimize xa_node allocation and remove the limitation of no split from
> order-12 (or above) to order-0 (or anything between 0 and 5)[1],
> xas_try_split() was added[2], which allocates
> (n / XA_CHUNK_SHIFT - m / XA_CHUNK_SHIFT) xa_node. It is used
> for non-uniform folio split, but can be used by __filemap_add_folio()
> and shmem_split_large_entry().
>
> xas_split_alloc() and xas_split() split an order-9 to order-0:
>
> ---------------------------------
> | | | | | | | | |
> | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
> | | | | | | | | |
> ---------------------------------
> | | | |
> ------- --- --- -------
> | | ... | |
> V V V V
> ----------- ----------- ----------- -----------
> | xa_node | | xa_node | ... | xa_node | | xa_node |
> ----------- ----------- ----------- -----------
>
> xas_try_split() splits an order-9 to order-0:
> ---------------------------------
> | | | | | | | | |
> | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
> | | | | | | | | |
> ---------------------------------
> |
> |
> V
> -----------
> | xa_node |
> -----------
>
> xas_try_split() is designed to be called iteratively with n = m + 1.
> xas_try_split_mini_order() is added to minmize the number of calls to
> xas_try_split() by telling the caller the next minimal order to split to
> instead of n - 1. Splitting order-n to order-m when m= l * XA_CHUNK_SHIFT
> does not require xa_node allocation and requires 1 xa_node
> when n=l * XA_CHUNK_SHIFT and m = n - 1, so it is OK to use
> xas_try_split() with n > m + 1 when no new xa_node is needed.
>
> xfstests quick group test passed on xfs and tmpfs.
>
> Let me know your comments.
The patch is on top of mm-everything-2025-02-13-02-18.
>
>
> [1] https://lore.kernel.org/linux-mm/Z6YX3RznGLUD07Ao@casper.infradead.org/
> [2] https://lore.kernel.org/linux-mm/20250211155034.268962-2-ziy@nvidia.com/
>
> Zi Yan (2):
> mm/filemap: use xas_try_split() in __filemap_add_folio().
> mm/shmem: use xas_try_split() in shmem_split_large_entry().
>
> include/linux/xarray.h | 7 +++++++
> lib/xarray.c | 25 +++++++++++++++++++++++
> mm/filemap.c | 46 +++++++++++++++++-------------------------
> mm/shmem.c | 43 +++++++++++++++------------------------
> 4 files changed, 67 insertions(+), 54 deletions(-)
>
> --
> 2.47.2
Best Regards,
Yan, Zi
prev parent reply other threads:[~2025-02-13 3:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 3:43 Zi Yan
2025-02-13 3:43 ` [PATCH 1/2] mm/filemap: use xas_try_split() in __filemap_add_folio() Zi Yan
2025-02-13 3:43 ` [PATCH 2/2] mm/shmem: use xas_try_split() in shmem_split_large_entry() Zi Yan
2025-02-13 3:46 ` Zi Yan [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=324AA2B9-418E-423E-80B3-D75A19D52A4C@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=hughd@google.com \
--cc=kasong@tencent.com \
--cc=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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