Update page_owner.rst to document process and cgroup filtering support in page_owner_filter tool. Add usage examples for PID, TGID, COMM (with wildcard support), and cgroup filters along with their respective limits. Signed-off-by: Zhen Ni --- Documentation/mm/page_owner.rst | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Documentation/mm/page_owner.rst b/Documentation/mm/page_owner.rst index a6bd3fe6423a..c8a7e6c242c5 100644 --- a/Documentation/mm/page_owner.rst +++ b/Documentation/mm/page_owner.rst @@ -283,7 +283,7 @@ page_owner supports filtering output at the kernel level before reading, which reduces the amount of data that needs to be processed in userspace. The page_owner_filter tool provides a convenient interface for this filtering -capability. It supports two types of filters: +capability. It supports the following types of filters: 1. **print_mode filter**: Control what information is printed for each page - ``stack``: Print full stack traces (default, compatible with existing usage) @@ -300,6 +300,16 @@ capability. It supports two types of filters: - Ranges: ``-n 0-3`` - Mixed format: ``-n 0,2-3,5`` +3. **Process filters**: Filter pages by process identifiers + - Filter by process ID: ``-p PID_LIST`` (comma-separated, max 16) + - Filter by thread group ID: ``-t TGID_LIST`` (comma-separated, max 16) + - Filter by task command name: ``-c COMM_LIST`` (comma-separated, max 8) + - Name matching supports wildcards: ``*``, ``?``, ``[a-z]`` + +4. **Cgroup (memcg) filter**: Filter pages by memory cgroup + - Filter by cgroup path: ``-g CGROUP`` + - Useful for containerized environments and multi-tenant systems + Usage examples:: # Filter by print mode @@ -310,9 +320,19 @@ Usage examples:: ./page_owner_filter -n 0 ./page_owner_filter -n 0-3 + # Filter by process + ./page_owner_filter -p 1234 + ./page_owner_filter -t 1,2,3 + ./page_owner_filter -c python* + + # Filter by cgroup + ./page_owner_filter -g system.slice + ./page_owner_filter -g kubepods/besteffort/pod123 + # Combined filters ./page_owner_filter -m stack -n 0,1,2 ./page_owner_filter -m handle -n 0,2-3 + ./page_owner_filter -g user.slice -c bash -n 0 # Save to file ./page_owner_filter -m handle -o filtered_output.txt @@ -323,6 +343,9 @@ reduce output size by ~66% (84MB vs 244MB) and improve read performance by ~4.4x compared to full stack output. The NUMA node filter is useful for NUMA-aware memory allocation analysis and debugging. +Process filters help isolate memory allocations for specific processes or tasks. +The cgroup filter is essential for containerized environments where you need to +analyze memory usage per container or service. Behind the scenes, page_owner_filter opens /sys/kernel/debug/page_owner and writes filter commands before reading the filtered output. The filtering uses -- 2.20.1