linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: <linux-mm@kvack.org>, Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	Hugh Dickins <hughd@google.com>,
	David Hildenbrand <david@redhat.com>,
	Yang Shi <yang@os.amperecomputing.com>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	Yu Zhao <yuzhao@google.com>, John Hubbard <jhubbard@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH v7 1/8] xarray: add xas_try_split() to split a multi-index entry.
Date: Tue, 11 Feb 2025 20:51:06 -0500	[thread overview]
Message-ID: <32DDC973-FAF8-48A8-831E-01E2ABA2966B@nvidia.com> (raw)
In-Reply-To: <3BC99886-609B-4820-B65D-FCA2E11A02F3@nvidia.com>

On 11 Feb 2025, at 19:57, Zi Yan wrote:

> On 11 Feb 2025, at 10:50, Zi Yan wrote:
>
>> It is a preparation patch for non-uniform folio split, which always split
>> a folio into half iteratively, and minimal xarray entry split.
>>
>> Currently, xas_split_alloc() and xas_split() always split all slots from a
>> multi-index entry. They cost the same number of xa_node as the to-be-split
>> slots. For example, to split an order-9 entry, which takes 2^(9-6)=8
>> slots, assuming XA_CHUNK_SHIFT is 6 (!CONFIG_BASE_SMALL), 8 xa_node are
>> needed. Instead xas_try_split() is intended to be used iteratively to split
>> the order-9 entry into 2 order-8 entries, then split one order-8 entry,
>> based on the given index, to 2 order-7 entries, ..., and split one order-1
>> entry to 2 order-0 entries. When splitting the order-6 entry and a new
>> xa_node is needed, xas_try_split() will try to allocate one if possible.
>> As a result, xas_try_split() would only need one xa_node instead of 8.
>>
>> When a new xa_node is needed during the split, xas_try_split() can try to
>> allocate one but no more. -ENOMEM will be return if a node cannot be
>> allocated. -EINVAL will be return if a sibling node is split or
>> cascade split happens, where two or more new nodes are needed, and these
>> are not supported by xas_try_split().
>>
>> 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 |
>> -----------
>>
>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>> ---
>>  Documentation/core-api/xarray.rst |  14 ++-
>>  include/linux/xarray.h            |   7 ++
>>  lib/test_xarray.c                 |  47 +++++++++++
>>  lib/xarray.c                      | 136 ++++++++++++++++++++++++++----
>>  tools/testing/radix-tree/Makefile |   1 +
>>  5 files changed, 188 insertions(+), 17 deletions(-)
>
> Hi Andrew,
>
> Do you mind folding the diff below to this one? I changed the function
> name but forgot the one in the xarray test. Thanks.

From bdf3b10f2ebcd09898ba7a277ac7107c25b8c71b Mon Sep 17 00:00:00 2001
From: Zi Yan <ziy@nvidia.com>
Date: Tue, 11 Feb 2025 20:48:55 -0500
Subject: [PATCH] correct the function name.

Signed-off-by: Zi Yan <ziy@nvidia.com>
---
 lib/test_xarray.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index 598ca38a2f5b..cc2dd325158f 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -1868,7 +1868,7 @@ static void check_split_2(struct xarray *xa, unsigned long index,
 	xa_set_mark(xa, index, XA_MARK_1);

 	xas_lock(&xas);
-	xas_try_halve(&xas, xa, order, GFP_KERNEL);
+	xas_try_split(&xas, xa, order, GFP_KERNEL);
 	if (((new_order / XA_CHUNK_SHIFT) < (order / XA_CHUNK_SHIFT)) &&
 	    new_order < order - 1) {
 		XA_BUG_ON(xa, !xas_error(&xas) || xas_error(&xas) != -EINVAL);
-- 
2.47.2



Best Regards,
Yan, Zi


  reply	other threads:[~2025-02-12  1:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11 15:50 [PATCH v7 0/8] Buddy allocator like (or non-uniform) folio split Zi Yan
2025-02-11 15:50 ` [PATCH v7 1/8] xarray: add xas_try_split() to split a multi-index entry Zi Yan
2025-02-12  0:57   ` Zi Yan
2025-02-12  1:51     ` Zi Yan [this message]
2025-02-17 21:44   ` David Hildenbrand
2025-02-17 22:05     ` Zi Yan
2025-02-18 15:44       ` David Hildenbrand
2025-02-18 16:04         ` Zi Yan
2025-02-18 16:12           ` David Hildenbrand
2025-02-11 15:50 ` [PATCH v7 2/8] mm/huge_memory: add two new (not yet used) functions for folio_split() Zi Yan
2025-02-14 21:59   ` David Hildenbrand
2025-02-14 22:03     ` Zi Yan
2025-02-14 22:06       ` David Hildenbrand
2025-02-14 22:18         ` Zi Yan
2025-02-15  1:52   ` Zi Yan
2025-02-11 15:50 ` [PATCH v7 3/8] mm/huge_memory: move folio split common code to __folio_split() Zi Yan
2025-02-11 15:50 ` [PATCH v7 4/8] mm/huge_memory: add buddy allocator like (non-uniform) folio_split() Zi Yan
2025-02-16 10:32   ` David Hildenbrand
2025-02-16 14:17     ` Zi Yan
2025-02-17 15:22       ` Zi Yan
2025-02-18  4:12         ` Andrew Morton
2025-02-18 15:23           ` Zi Yan
2025-02-11 15:50 ` [PATCH v7 5/8] mm/huge_memory: remove the old, unused __split_huge_page() Zi Yan
2025-02-11 15:50 ` [PATCH v7 6/8] mm/huge_memory: add folio_split() to debugfs testing interface Zi Yan
2025-02-11 15:50 ` [PATCH v7 7/8] mm/truncate: use buddy allocator like folio split for truncate operation Zi Yan
2025-02-11 15:50 ` [PATCH v7 8/8] selftests/mm: add tests for folio_split(), buddy allocator like split Zi Yan

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=32DDC973-FAF8-48A8-831E-01E2ABA2966B@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=jhubbard@nvidia.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=yang@os.amperecomputing.com \
    --cc=yuzhao@google.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