From: David Hildenbrand <david@redhat.com>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] fs/proc/task_mmu: fix PAGE_IS_PFNZERO detection for the huge zero folio
Date: Mon, 30 Jun 2025 09:55:15 +0200 [thread overview]
Message-ID: <2409b6e5-ee02-4cb6-abc8-5b821f58f540@redhat.com> (raw)
In-Reply-To: <416514a7-0e0d-4cc8-912e-bcdd2bac5c2e@collabora.com>
On 30.06.25 07:18, Muhammad Usama Anjum wrote:
> On 6/17/25 7:35 PM, David Hildenbrand wrote:
>> is_zero_pfn() does not work for the huge zero folio. Fix it by using
>> is_huge_zero_pmd().
>>
>> Found by code inspection.
>>
>> Fixes: 52526ca7fdb9 ("fs/proc/task_mmu: implement IOCTL to get and optionally clear info about PTEs")
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>
>> Probably we should Cc stable, thoughts?
>>
>> We should also extend the pagemap_ioctl selftest to cover this case, but I
>> don't have time for that right now. @Muhammad ?
> Currently, we don't have any test case covering zero pfn. I'm trying to write
> a few test cases. But I'm not able to get ZERO PFN. I've tried to allocate a
> read only memory and then read it. Is there a trick to how to create ZERO PFN
> memory from userspace?
You need a MAP_ANON | MAP_PRIVATE mapping and have to make sure that the
compiler does not optimize out the read.
E.g.,
char *mem = mmap(...);
char tmp = *mem;
asm volatile("" : "+r" (tmp))
or
char *mem = mmap(...);
*(volatile char *)mem;
To get the shared huge zero folio, you need a suitably aligned VMA. See
run_with_huge_zeropage() in in tools/testing/selftests/mm/cow.c as one
example.
--
Cheers,
David / dhildenb
prev parent reply other threads:[~2025-06-30 7:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 14:35 David Hildenbrand
2025-06-17 23:34 ` Andrew Morton
2025-06-18 8:56 ` David Hildenbrand
2025-06-30 5:18 ` Muhammad Usama Anjum
2025-06-30 7:55 ` David Hildenbrand [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=2409b6e5-ee02-4cb6-abc8-5b821f58f540@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=usama.anjum@collabora.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
all inboxes | Powered by JetHome®