Re: [PATCH v12 1/4] mm/page_owner: add print_mode filter

From: Zi Yan

Date: Tue Jul 07 2026 - 11:44:01 EST


On 7 Jul 2026, at 11:27, Vlastimil Babka (SUSE) wrote:

> On 7/7/26 13:54, Zhen Ni wrote:
>> Add a print_mode filter to page_owner that allows users to choose between
>> printing stack traces, stack handles, or both, providing flexibility for
>> different debugging and analysis scenarios.
>>
>> The filter provides three modes via page_owner:
>> - Writing "mode=stack" prints stack traces for each page (default)
>> - Writing "mode=handle" prints only the handle number
>> - Writing "mode=stack_handle" prints both stack traces and handles
>>
>> The default stack mode maintains backward compatibility with existing
>> usage, displaying complete stack traces for each page allocation.
>>
>> The handle mode dramatically reduces log size and improves performance by
>> showing only the handle number instead of the full stack trace. Testing
>> shows handle mode reduces output size by ~66% (84MB vs 244MB) and
>> improves read performance by ~4.4x compared to full stack output. The
>> mapping from handles to actual stack traces can be obtained via the
>> show_stacks_handles interface.
>>
>> The stack_handle mode prints both stack traces and handles, making it
>> easier to identify pages with the same allocation pattern by comparing
>> handle numbers instead of comparing large stack traces.
>>
>> Example usage:
>> # Using the page_owner_filter tool (recommended)
>> ./page_owner_filter -m stack # Print only stack traces (default)
>> ./page_owner_filter -m handle # Print only handles
>> ./page_owner_filter -m stack_handle # Print both stack and handles
>>
>> Sample output (handle mode):
>> Page allocated via order 0, migratetype Unmovable, gfp_mask 0x1100ca,
>> pid 1, tgid 1 (systemd), ts 123456789 ns
>> PFN 0x1000 type Unmovable Block 1 type Unmovable
>> Flags 0x3fffe800000084(referenced|lru|active|private|node=0|zone=1)
>> handle: 17432583
>> ...
>>
>> This implementation uses per-file-descriptor filter state stored in
>> file->private_data, allowing each opener to have independent filter
>> configuration.
>>
>> Signed-off-by: Zhen Ni <zhen.ni@xxxxxxxxxxxx>
>> Tested-by: Zi Yan <ziy@xxxxxxxxxx>
>
> I think in general Tested-by" can't carry from previous version due to
> (functional) changes. Andrew can remove it locally, or Zi can re-test :)

Let me do a quick retest. :)

>
>> Acked-by: Zi Yan <ziy@xxxxxxxxxx>
>
> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>


Best Regards,
Yan, Zi