Re: [PATCH v1] tools/mm: page-types: flush pending idle bitmap bits after walking
From: Andrew Morton
Date: Tue Nov 24 2026 - 21:46:59 EST
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?
> if (opt_list == 1)
> flush_page_range();
>