linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Donet Tom <donettom@linux.ibm.com>
To: Zi Yan <ziy@nvidia.com>
Cc: David Hildenbrand <david@redhat.com>,
	Aboorva Devarajan <aboorvad@linux.ibm.com>,
	akpm@linux-foundation.org, Liam.Howlett@oracle.com,
	lorenzo.stoakes@oracle.com, shuah@kernel.org, pfalcato@suse.de,
	baolin.wang@linux.alibaba.com, npache@redhat.com,
	ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, ritesh.list@gmail.com
Subject: Re: [PATCH v2 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
Date: Thu, 3 Jul 2025 20:00:46 +0530	[thread overview]
Message-ID: <3a99961c-6eda-434a-8721-58eaf8b989db@linux.ibm.com> (raw)
In-Reply-To: <788EBC0F-67CB-4EE2-883F-A55CD394EE21@nvidia.com>


On 7/3/25 7:51 PM, Zi Yan wrote:
> On 3 Jul 2025, at 4:58, Donet Tom wrote:
>
>> On 7/3/25 1:52 PM, David Hildenbrand wrote:
>>> On 03.07.25 08:06, Aboorva Devarajan wrote:
>>>> From: Donet Tom <donettom@linux.ibm.com>
>>>>
>>>> The split_huge_page_test fails on systems with a 64KB base page size.
>>>> This is because the order of a 2MB huge page is different:
>>>>
>>>> On 64KB systems, the order is 5.
>>>>
>>>> On 4KB systems, it's 9.
>>>>
>>>> The test currently assumes a maximum huge page order of 9, which is only
>>>> valid for 4KB base page systems. On systems with 64KB pages, attempting
>>>> to split huge pages beyond their actual order (5) causes the test to fail.
>>>>
>>>> In this patch, we calculate the huge page order based on the system's base
>>>> page size. With this change, the tests now run successfully on both 64KB
>>>> and 4KB page size systems.
>>>>
>>>> Fixes: fa6c02315f745 ("mm: huge_memory: a new debugfs interface for splitting THP tests")
>>>> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
>>>> Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
>>>> ---
>>>>    .../selftests/mm/split_huge_page_test.c       | 23 ++++++++++++++-----
>>>>    1 file changed, 17 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
>>>> index aa7400ed0e99..38296a758330 100644
>>>> --- a/tools/testing/selftests/mm/split_huge_page_test.c
>>>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>>>> @@ -514,6 +514,15 @@ void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc,
>>>>        }
>>>>    }
>>>>    +static unsigned int get_order(unsigned int pages)
>>>> +{
>>>> +    unsigned int order = 0;
>>>> +
>>>> +    while ((1U << order) < pages)
>>>> +        order++;
>>>> +    return order;
>>>> +}
>>> I think this can simply be
>>>
>>> return 32 - __builtin_clz(pages - 1);
>>>
>>> That mimics what get_order() in the kernel does for BITS_PER_LONG == 32
>>>
>>> or simpler
>>>
>>> return 31 - __builtin_clz(pages);
>>>
>>> E.g., if pages=512, you get 31-22=9
>>
>> Sure David, We will  change it.
>>
>>
>>>> +
>>>>    int main(int argc, char **argv)
>>>>    {
>>>>        int i;
>>>> @@ -523,6 +532,7 @@ int main(int argc, char **argv)
>>>>        const char *fs_loc;
>>>>        bool created_tmp;
>>>>        int offset;
>>>> +    unsigned int max_order;
>>>>          ksft_print_header();
>>>>    @@ -534,32 +544,33 @@ int main(int argc, char **argv)
>>>>        if (argc > 1)
>>>>            optional_xfs_path = argv[1];
>>>>    -    ksft_set_plan(1+8+1+9+9+8*4+2);
>>>> -
>>>>        pagesize = getpagesize();
>>>>        pageshift = ffs(pagesize) - 1;
>>>>        pmd_pagesize = read_pmd_pagesize();
>>>>        if (!pmd_pagesize)
>>>>            ksft_exit_fail_msg("Reading PMD pagesize failed\n");
>>>>    +    max_order = get_order(pmd_pagesize/pagesize);
>>>> + ksft_set_plan(1+(max_order-1)+1+max_order+max_order+(max_order-1)*4+2);
>>> Wow. Can we simplify that in any sane way?
>>
>> It is counting test by test. Let me try to simplify it and send the next version.
> Yeah, I did that (ksft_set_plan(1+8+1+9+9+8*4+2);) to count different tests
> separately and in the same order as the following tests, so that I could
> get ksft_set_plan number right when adding or removing tests. Maybe it is
> fine to just sum them up now.


Sure. Thank you


>
> Best Regards,
> Yan, Zi
>


  reply	other threads:[~2025-07-03 14:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  6:06 [PATCH v2 0/7] selftests/mm: Fix false positives and skip unsupported tests Aboorva Devarajan
2025-07-03  6:06 ` [PATCH v2 1/7] mm/selftests: Fix incorrect pointer being passed to mark_range() Aboorva Devarajan
2025-07-03  7:59   ` Dev Jain
2025-07-03  8:03   ` David Hildenbrand
2025-07-03 14:33   ` Zi Yan
2025-07-03  6:06 ` [PATCH v2 2/7] selftests/mm: Add support to test 4PB VA on PPC64 Aboorva Devarajan
2025-07-03  8:05   ` Dev Jain
2025-07-03  8:09   ` David Hildenbrand
2025-07-03 14:41   ` Zi Yan
2025-07-03 14:44     ` Dev Jain
2025-07-03 14:53       ` Zi Yan
2025-07-03 14:50     ` Donet Tom
2025-07-03  6:06 ` [PATCH v2 3/7] selftest/mm: Fix ksm_funtional_test failures Aboorva Devarajan
2025-07-03  6:06 ` [PATCH v2 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size Aboorva Devarajan
2025-07-03  8:15   ` Dev Jain
2025-07-03  8:22   ` David Hildenbrand
2025-07-03  8:58     ` Donet Tom
2025-07-03 14:21       ` Zi Yan
2025-07-03 14:30         ` Donet Tom [this message]
2025-07-03 14:30   ` Zi Yan
2025-07-03 14:52     ` Donet Tom
2025-07-03  6:06 ` [PATCH v2 5/7] selftests/mm: Fix child process exit codes in ksm_functional_tests Aboorva Devarajan
2025-07-03  8:29   ` David Hildenbrand
2025-07-03  8:33   ` David Hildenbrand
2025-07-03  8:51     ` Donet Tom
2025-07-03  9:14       ` David Hildenbrand
2025-07-03 14:31         ` Donet Tom
2025-07-03  6:06 ` [PATCH v2 6/7] selftests/mm: Skip thuge-gen if shmmax is too small or no 1G huge pages Aboorva Devarajan
2025-07-03  8:21   ` Dev Jain
2025-07-03  8:36   ` David Hildenbrand
2025-07-03 14:43   ` Zi Yan
2025-07-03  6:06 ` [PATCH v2 7/7] selftests/mm: Skip hugepage-mremap test if userfaultfd unavailable Aboorva Devarajan
2025-07-03  8:38   ` David Hildenbrand
2025-07-03 14:52     ` 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=3a99961c-6eda-434a-8721-58eaf8b989db@linux.ibm.com \
    --to=donettom@linux.ibm.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=aboorvad@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=dev.jain@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=npache@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=ritesh.list@gmail.com \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=ziy@nvidia.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