From: "David Hildenbrand (Arm)" <david@kernel.org>
To: xu.xin16@zte.com.cn
Cc: akpm@linux-foundation.org, chengming.zhou@linux.dev,
hughd@google.com, wang.yaxin@zte.com.cn, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, ljs@kernel.org
Subject: Re: [PATCH v10 3/3] ksm: add mremap selftests for ksm_rmap_walk
Date: Thu, 2 Jul 2026 15:23:34 +0200 [thread overview]
Message-ID: <f45ac275-800e-425e-a63a-a29e2ee94487@kernel.org> (raw)
In-Reply-To: <20260629224318783u6CQwXyKLEVtR-nJLFZuq@zte.com.cn>
On 6/29/26 16:43, xu.xin16@zte.com.cn wrote:
>> I think there are various improvements and simplifications we can perform. In particular,
>> I don't think we need the errors messages or use data-> members.
>>
>> What about the following simplification, to move this over the finishing line? (untested)
>
> Agreed. Your version is cleaner and tests successfully.
>
>>
>> There is the low chance of page compaction migrating the page while we check for it. Not sure
>> if we should handle it (but it would involve retrying on PFN mismatch).
>
> It is really possible. To improve robustness, how about double-checking in range_maps_pfn() and
> rename range_maps_pfn as range_maps_the_same_pfn() which caculate the fisrt PFN itself without
> the input PFN as follows:
>
> static bool range_maps_the_same_pfn(int pagemap_fd, void *region, int nr_pages)
> {
> int i;
> int second_times = 0;
> unsigned long first_pfn;
>
> again:
> first_pfn = pagemap_get_pfn(pagemap_fd, region);
> for (i = 0; i < nr_pages; i++) {
> if (pagemap_get_pfn(pagemap_fd, region + i * getpagesize()) != first_pfn) {
> if (second_times)
> return false;
> else {
> /*
> * In case of low chance the low chance of page compaction
> * migrating the page while we check for pfn.
> */
> second_times++;
> goto again;
> }
> }
> }
>
> return true;
> }
Something like that could work. Best to retry more often (10 times?) and call
the variable "retries". Also, call the label "retry"
Simply check after the retry label
if (retries > 10)
return false;
--
Cheers,
David
next prev parent reply other threads:[~2026-07-02 13:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 9:41 KSM: performance optimizations for rmap_walk_ksm xu.xin16
2026-06-29 9:42 ` [PATCH v10 1/3] ksm: add linear_page_index into ksm_rmap_item xu.xin16
2026-06-29 9:43 ` [PATCH v10 2/3] ksm: Optimize rmap_walk_ksm by passing a suitable page index xu.xin16
2026-06-29 9:44 ` [PATCH v10 3/3] ksm: add mremap selftests for ksm_rmap_walk xu.xin16
2026-06-29 11:59 ` David Hildenbrand (Arm)
2026-06-29 14:43 ` xu.xin16
2026-07-02 13:23 ` David Hildenbrand (Arm) [this message]
2026-06-29 10:00 ` KSM: performance optimizations for rmap_walk_ksm Lorenzo Stoakes
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=f45ac275-800e-425e-a63a-a29e2ee94487@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=wang.yaxin@zte.com.cn \
--cc=xu.xin16@zte.com.cn \
/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