From: David Hildenbrand <david@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Zi Yan <ziy@nvidia.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: Tue, 2 Sep 2025 09:49:48 +0200 [thread overview]
Message-ID: <dd30710a-a210-44dc-93f9-1e7ddf096251@redhat.com> (raw)
In-Reply-To: <20250902025112.d2n3o4imeptppctd@master>
>> + /*
>> + * To challenge spitting code, we will mremap page[x] of the
>> + * thp[x] into a smaller area, and trigger the split from that
>> + * smaller area. This will end up replacing the PMD mappings in
>> + * the thp_area by PTE mappings first, leaving the THPs unsplit.
>> + */
>> + page_area = mmap(NULL, page_area_size, PROT_READ | PROT_WRITE,
>> + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
>> + if (page_area == MAP_FAILED) {
>> + ksft_test_result_fail("Fail to allocate memory: %s\n", strerror(errno));
>> + goto out;
>> + }
>> - if (i % pagesize == 0 &&
>> - !is_backed_by_folio(&pte_mapped[i], 0, pagemap_fd, kpageflags_fd))
>> - thp_size++;
>> + for (i = 0; i < nr_thps; i++) {
>> + tmp = mremap(thp_area + pmd_pagesize * i + pagesize * i,
>> + pagesize, pagesize, MREMAP_MAYMOVE|MREMAP_FIXED,
>> + page_area + pagesize * i);
>
> Would this create one hole at the beginning of each 2M range and cause
> splitting underlining THP?
Yes, it will create a hole (this also happens in the old code).
As the comment above it now states: "leaving the THPs unsplit"
There is a check verifying that after this mremap code.
--
Cheers
David / dhildenb
next prev parent reply other threads:[~2025-09-02 7:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-31 2:27 [Patch v2] selftests/mm: check content to see whether mremap corrupt data 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
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 [this message]
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=dd30710a-a210-44dc-93f9-1e7ddf096251@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;
as well as URLs for NNTP newsgroup(s).