linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Zi Yan <ziy@nvidia.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, lorenzo.stoakes@oracle.com,
	baolin.wang@linux.alibaba.com, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [Patch v2] selftests/mm: check content to see whether mremap corrupt data
Date: Mon, 1 Sep 2025 15:03:50 +0200	[thread overview]
Message-ID: <0a0b0018-9427-4201-bf53-6aeb251bc482@redhat.com> (raw)
In-Reply-To: <61E58B7C-23D0-49FE-8D0C-CE0B672114E2@nvidia.com>

On 01.09.25 14:56, Zi Yan wrote:
> On 1 Sep 2025, at 3:22, David Hildenbrand wrote:
> 
>> On 31.08.25 04:27, Wei Yang wrote:
>>
>> Subject: "selftests/mm: verify page content after remapping PMD through PTEs"
>>
>>> After mremap(), add a check on content to see whether mremap corrupt
>>> data.
>>>
>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>>
>>> ---
>>> v2: add check on content instead of just test backed folio
>>
>> I'm confused, don't we have that exact check later in the function?
>>
>> Your v1 might have been better, unless I am missing something.
>>
>>> ---
>>>    tools/testing/selftests/mm/split_huge_page_test.c | 6 +++++-
>>>    1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
>>> index 10ae65ea032f..229b6dcabece 100644
>>> --- a/tools/testing/selftests/mm/split_huge_page_test.c
>>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>>> @@ -423,10 +423,14 @@ static void split_pte_mapped_thp(void)
>>>     	/* smap does not show THPs after mremap, use kpageflags instead */
>>>    	thp_size = 0;
>>> -	for (i = 0; i < pagesize * 4; i++)
>>> +	for (i = 0; i < pagesize * 4; i++) {
>>> +		if (pte_mapped[i] != (char)i)
>>> +			ksft_exit_fail_msg("%ld byte corrupted\n", i);
>>> +
>>>    		if (i % pagesize == 0 &&
>>>    		    is_backed_by_folio(&pte_mapped[i], pmd_order, pagemap_fd, kpageflags_fd))
>>>    			thp_size++;
>>> +	}
>>>     	if (thp_size != 4)
>>>    		ksft_exit_fail_msg("Some THPs are missing during mremap\n");
>>
>> I'm a bit confused with this test in general.
>>
>> We do a
>>
>> pte_mapped = mremap(one_page, pagesize, pagesize, MREMAP_MAYMOVE);
>>
>> which I read as a "NOP".
>>
>> Questions
>>
>> (a) Will this actually do anything? Also, maybe it does now, but can't the kernel just optimize that out in the future?
> 
> It remaps each subpage of 4 PMD THPs into a contiguous 2MB vaddr range and
> perform split on that range.

I'm afraid I am missing the "why".

I would have thought that a "split_pte_mapped_thp" test would want to pte-map THPs
to the see if they can be split.

Why is the mremap required? IOW, what exactly is the test trying to test that
exceeds "split_pte_mapped_thp" ?

-- 
Cheers

David / dhildenb



  reply	other threads:[~2025-09-01 13:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-31  2:27 Wei Yang
2025-09-01  2:08 ` wang lian
2025-09-01  7:22 ` David Hildenbrand
2025-09-01  8:11   ` wang lian
2025-09-01  8:16     ` David Hildenbrand
2025-09-01  8:34       ` wang lian
2025-09-01  8:43   ` Wei Yang
2025-09-01 12:56   ` Zi Yan
2025-09-01 13:03     ` David Hildenbrand [this message]
2025-09-01 17:04       ` Zi Yan
2025-09-01 19:10         ` David Hildenbrand
2025-09-02  2:51           ` Wei Yang
2025-09-02  7:49             ` David Hildenbrand
2025-09-02  8:13               ` Wei Yang
2025-09-02  8:23                 ` David Hildenbrand
2025-09-02  8:28                   ` Wei Yang
2025-09-02  8:16           ` Wei Yang
2025-09-02  8:26             ` David Hildenbrand
2025-09-02 14:56           ` Zi Yan
2025-09-02 15:28             ` David Hildenbrand
2025-09-02 15:39               ` Zi Yan
2025-09-02 15:40               ` David Hildenbrand
2025-09-02 15:42                 ` 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=0a0b0018-9427-4201-bf53-6aeb251bc482@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=richard.weiyang@gmail.com \
    --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