Re: [PATCH v1] tools/mm: page-types: flush pending idle bitmap bits after walking

From: Xuewen Wang

Date: Wed Nov 25 2026 - 04:15:46 EST




在 2026/11/25 10:46, Andrew Morton 写道:
On Wed, 18 Nov 2026 10:12:53 +0800 Xuewen Wang <wangxuewen_ky@xxxxxxx> wrote:

From: Xuewen Wang <wangxuewen@xxxxxxxxxx>

mark_page_idle() buffers bits for one 64-page bitmap word and writes
that word when a page in another word is encountered.

walk_addr_ranges() tries to flush the final word by marking PFN 0.
If the last buffered PFN is below 64, this only adds a bit to the same
word and nothing is written. Otherwise it writes the pending word but
leaves an unwanted PFN 0 bit buffered. walk_page_cache() does not flush
at all, so its final pending bits are not written.

Extract the write operation into flush_page_idle() and use it both when
changing words and after either walker returns to main(). Clear the
buffer after a successful write and skip writes when it is empty.
Place the final flush before the no-summary early return.

Use 1ULL for the bit mask so shifts by 32 through 63 are also valid
on 32-bit hosts.

...
@@ -1364,6 +1373,9 @@ int main(int argc, char *argv[])
else
walk_addr_ranges();
+ if (opt_mark_idle)
+ flush_page_idle();

Very minor, but we shouldn't exit(0) if that flush_page_idle() returned
error?
Hi Andrew,

Thanks for reviewing the patch and pointing this out. I've updated main() to return EXIT_FAILURE if the final flush_page_idle() call fails.
I'll send v2 shortly.

Thanks,
Xuewen

if (opt_list == 1)
flush_page_range();