<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/tools/vm, branch linus/master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/tools/vm?h=linus%2Fmaster</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/tools/vm?h=linus%2Fmaster'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2022-05-10T01:20:44Z</updated>
<entry>
<title>mm/page-flags: reuse PG_mappedtodisk as PG_anon_exclusive for PageAnon() pages</title>
<updated>2022-05-10T01:20:44Z</updated>
<author>
<name>David Hildenbrand</name>
<email>david@redhat.com</email>
</author>
<published>2022-05-10T01:20:44Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=78fbe906cc900b33ce078102e13e0e99b5b8c406'/>
<id>urn:sha1:78fbe906cc900b33ce078102e13e0e99b5b8c406</id>
<content type='text'>
The basic question we would like to have a reliable and efficient answer
to is: is this anonymous page exclusive to a single process or might it be
shared?  We need that information for ordinary/single pages, hugetlb
pages, and possibly each subpage of a THP.

Introduce a way to mark an anonymous page as exclusive, with the ultimate
goal of teaching our COW logic to not do "wrong COWs", whereby GUP pins
lose consistency with the pages mapped into the page table, resulting in
reported memory corruptions.

Most pageflags already have semantics for anonymous pages, however,
PG_mappedtodisk should never apply to pages in the swapcache, so let's
reuse that flag.

As PG_has_hwpoisoned also uses that flag on the second tail page of a
compound page, convert it to PG_error instead, which is marked as
PF_NO_TAIL, so never used for tail pages.

Use custom page flag modification functions such that we can do additional
sanity checks.  The semantics we'll put into some kernel doc in the future
are:

"
  PG_anon_exclusive is *usually* only expressive in combination with a
  page table entry. Depending on the page table entry type it might
  store the following information:

       Is what's mapped via this page table entry exclusive to the
       single process and can be mapped writable without further
       checks? If not, it might be shared and we might have to COW.

  For now, we only expect PTE-mapped THPs to make use of
  PG_anon_exclusive in subpages. For other anonymous compound
  folios (i.e., hugetlb), only the head page is logically mapped and
  holds this information.

  For example, an exclusive, PMD-mapped THP only has PG_anon_exclusive
  set on the head page. When replacing the PMD by a page table full
  of PTEs, PG_anon_exclusive, if set on the head page, will be set on
  all tail pages accordingly. Note that converting from a PTE-mapping
  to a PMD mapping using the same compound page is currently not
  possible and consequently doesn't require care.

  If GUP wants to take a reliable pin (FOLL_PIN) on an anonymous page,
  it should only pin if the relevant PG_anon_exclusive is set. In that
  case, the pin will be fully reliable and stay consistent with the pages
  mapped into the page table, as the bit cannot get cleared (e.g., by
  fork(), KSM) while the page is pinned. For anonymous pages that
  are mapped R/W, PG_anon_exclusive can be assumed to always be set
  because such pages cannot possibly be shared.

  The page table lock protecting the page table entry is the primary
  synchronization mechanism for PG_anon_exclusive; GUP-fast that does
  not take the PT lock needs special care when trying to clear the
  flag.

  Page table entry types and PG_anon_exclusive:
  * Present: PG_anon_exclusive applies.
  * Swap: the information is lost. PG_anon_exclusive was cleared.
  * Migration: the entry holds this information instead.
               PG_anon_exclusive was cleared.
  * Device private: PG_anon_exclusive applies.
  * Device exclusive: PG_anon_exclusive applies.
  * HW Poison: PG_anon_exclusive is stale and not changed.

  If the page may be pinned (FOLL_PIN), clearing PG_anon_exclusive is
  not allowed and the flag will stick around until the page is freed
  and folio-&gt;mapping is cleared.
"

We won't be clearing PG_anon_exclusive on destructive unmapping (i.e.,
zapping) of page table entries, page freeing code will handle that when
also invalidate page-&gt;mapping to not indicate PageAnon() anymore.  Letting
information about exclusivity stick around will be an important property
when adding sanity checks to unpinning code.

Note that we properly clear the flag in free_pages_prepare() via
PAGE_FLAGS_CHECK_AT_PREP for each individual subpage of a compound page,
so there is no need to manually clear the flag.

Link: https://lkml.kernel.org/r/20220428083441.37290-12-david@redhat.com
Signed-off-by: David Hildenbrand &lt;david@redhat.com&gt;
Acked-by: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Cc: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Don Dutile &lt;ddutile@redhat.com&gt;
Cc: Hugh Dickins &lt;hughd@google.com&gt;
Cc: Jan Kara &lt;jack@suse.cz&gt;
Cc: Jann Horn &lt;jannh@google.com&gt;
Cc: Jason Gunthorpe &lt;jgg@nvidia.com&gt;
Cc: John Hubbard &lt;jhubbard@nvidia.com&gt;
Cc: Khalid Aziz &lt;khalid.aziz@oracle.com&gt;
Cc: "Kirill A. Shutemov" &lt;kirill.shutemov@linux.intel.com&gt;
Cc: Liang Zhang &lt;zhangliang5@huawei.com&gt;
Cc: "Matthew Wilcox (Oracle)" &lt;willy@infradead.org&gt;
Cc: Michal Hocko &lt;mhocko@kernel.org&gt;
Cc: Mike Kravetz &lt;mike.kravetz@oracle.com&gt;
Cc: Mike Rapoport &lt;rppt@linux.ibm.com&gt;
Cc: Nadav Amit &lt;namit@vmware.com&gt;
Cc: Oded Gabbay &lt;oded.gabbay@gmail.com&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Pedro Demarchi Gomes &lt;pedrodemargomes@gmail.com&gt;
Cc: Peter Xu &lt;peterx@redhat.com&gt;
Cc: Rik van Riel &lt;riel@surriel.com&gt;
Cc: Roman Gushchin &lt;guro@fb.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Yang Shi &lt;shy828301@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: avoid repeated judgments</title>
<updated>2022-04-29T06:15:57Z</updated>
<author>
<name>Yixuan Cao</name>
<email>caoyixuan2019@email.szu.edu.cn</email>
</author>
<published>2022-04-29T06:15:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=c7c4ab859642830a14c45785ca7866659b65fc44'/>
<id>urn:sha1:c7c4ab859642830a14c45785ca7866659b65fc44</id>
<content type='text'>
I noticed a detail that needs to be adjusted.  When judging whether a page
is allocated by vmalloc, the value of the variable "tmp" was repeatedly
judged, so the code was adjusted.

This work is coauthored by Yinan Zhang, Jiajian Ye, Shenghong Han, Chongxi
Zhao, Yuhong Feng and Yongqiang Liu.

Link: https://lkml.kernel.org/r/20220414042744.13896-1-caoyixuan2019@email.szu.edu.cn
Signed-off-by: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Haowen Bai &lt;baihaowen@meizu.com&gt;
Cc: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: provide allocator labelling and update --cull and --sort options</title>
<updated>2022-04-29T06:15:57Z</updated>
<author>
<name>Yixuan Cao</name>
<email>caoyixuan2019@email.szu.edu.cn</email>
</author>
<published>2022-04-29T06:15:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=f09654bb88127473b4baf3bc0b68d4d4695aca7b'/>
<id>urn:sha1:f09654bb88127473b4baf3bc0b68d4d4695aca7b</id>
<content type='text'>
An application is suspected of having memory leak when its memory
consumption is high and keeps increasing.  There are several commonly used
memory allocators: slab, cma, vmalloc, etc.  The memory leak
identification can be sped up if the page information allocated by an
allocator can be analyzed separately.

This patch provides supports for memory allocator labelling for slab,
vmalloc, and cma.  The pages allocated by slab and cma can be confirmed
from the "PFN" line according to the kernel codes, and the label of the
vmalloc allocator can be obtained by analyzing the stack trace.  Thanks
for Vlastimil Babka's constructive suggestions.

Based on Yinan Zhang's study, the call chain of vmalloc() is vmalloc() -&gt;
...  -&gt; __vmalloc_node_range() -&gt; __vmalloc_area_node(). 
__vmalloc_area_node() requests memory through the interface of buddy
allocation system.  In the current version, __vmalloc_area_node() uses
four interfaces: alloc_pages_bulk_array_mempolicy(),
alloc_pages_bulk_array_node(), alloc_pages() and alloc_pages_node().  By
disassembling the code, we find that __vmalloc_area_node() is expanded in
__vmalloc_node_range().  So __vmalloc_area_node is not in the stack trace.

On the test machine, the stack trace of pages allocated by vmalloc has the
following four forms:

__alloc_pages_bulk+0x230/0x6a0
__vmalloc_node_range+0x19c/0x598

alloc_pages_bulk_array_mempolicy+0xbc/0x278
__vmalloc_node_range+0x1e8/0x598

__alloc_pages+0x160/0x2b0
__vmalloc_node_range+0x234/0x598

alloc_pages+0xac/0x150
__vmalloc_node_range+0x44c/0x598

Therefore, in two consecutive lines of stacktrace, if the first line
contains the word "alloc_pages" and the second line contains the word
"__vmalloc_node_range", it can be determined that the page is allocated by
vmalloc.  And the function offset and size are not the same on different
machines, so there is no need to match them.

At the same time, this patch updates the --cull and --sort options to
support allocator-based merge statistics and sorting.  The added functions
are fully compatible with the original work.  When using, you can use
"allocator", or abbreviated as "ator".  Relevant updates have also been
made in the documentation(Documentation/vm/page_owner.rst).

Example:
./page_owner_sort &lt;input&gt; &lt;output&gt; --cull=st,pid,name,allocator
./page_owner_sort &lt;input&gt; &lt;output&gt; --sort=ator,pid,name

This work is coauthored by Jiajian Ye, Yinan Zhang, Shenghong Han,
Chongxi Zhao, Yuhong Feng and Yongqiang Liu.

Link: https://lkml.kernel.org/r/20220410132932.9402-1-caoyixuan2019@email.szu.edu.cn
Signed-off-by: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Haowen Bai &lt;baihaowen@meizu.com&gt;
Cc: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner: support debug log to avoid huge log print</title>
<updated>2022-04-29T06:15:57Z</updated>
<author>
<name>Haowen Bai</name>
<email>baihaowen@meizu.com</email>
</author>
<published>2022-04-29T06:15:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=a72469aa593881c2a5ad3a38cfb3e7871c50f169'/>
<id>urn:sha1:a72469aa593881c2a5ad3a38cfb3e7871c50f169</id>
<content type='text'>
As normal usage, tool will print huge parser log and spend a lot of time
printing, so it would be preferable add "-d" debug control to avoid this
problem.

Link: https://lkml.kernel.org/r/1649672446-5685-1-git-send-email-baihaowen@meizu.com
Signed-off-by: Haowen Bai &lt;baihaowen@meizu.com&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: support sorting blocks by multiple keys</title>
<updated>2022-04-29T06:15:57Z</updated>
<author>
<name>Jiajian Ye</name>
<email>yejiajian2018@email.szu.edu.cn</email>
</author>
<published>2022-04-29T06:15:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=ebbeae36387ccf1326c896167872c3acf6c3c956'/>
<id>urn:sha1:ebbeae36387ccf1326c896167872c3acf6c3c956</id>
<content type='text'>
When viewing page owner information, we may want to sort blocks of
information by multiple keys, since one single key does not uniquely
identify a block. Therefore, following adjustments are made:

1. Add a new --sort option to support sorting blocks of information by
multiple keys.

	./page_owner_sort &lt;input&gt; &lt;output&gt; --sort=&lt;order&gt;
	./page_owner_sort &lt;input&gt; &lt;output&gt; --sort &lt;order&gt;

&lt;order&gt; is a single argument in the form of a comma-separated list,
which offers a way to specify sorting order.

Sorting syntax is [+|-]key[,[+|-]key[,...]]. The ascending or descending
order can be specified by adding the + (ascending, default) or - (descend
-ing) prefix to the key:

	./page_owner_sort &lt;input&gt; &lt;output&gt; [option] --sort -key1,+key2,key3...

For example, to sort the blocks first by task command name in lexicographic
order and then by pid in ascending numerical order, use the following:

	./page_owner_sort &lt;input&gt; &lt;output&gt; --sort=name,+pid

To sort the blocks first by pid in ascending order and then by timestamp
of the page when it is allocated in descending order, use the following:

	./page_owner_sort &lt;input&gt; &lt;output&gt; --sort=pid,-alloc_ts

2. Add explanations of a newly added --sort option in the function usage()
and the document(Documentation/vm/page_owner.rst).

This work is coauthored by
	Yixuan Cao
	Shenghong Han
	Yinan Zhang
	Chongxi Zhao
	Yuhong Feng
	Yongqiang Liu

Link: https://lkml.kernel.org/r/20220401024856.767-3-yejiajian2018@email.szu.edu.cn
Signed-off-by: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Cc: Haowen Bai &lt;baihaowen@meizu.com&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: support for multi-value selection in single argument</title>
<updated>2022-04-29T06:15:56Z</updated>
<author>
<name>Jiajian Ye</name>
<email>yejiajian2018@email.szu.edu.cn</email>
</author>
<published>2022-04-29T06:15:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=75382a2dca0e9e9e57e88b479cf537549461a934'/>
<id>urn:sha1:75382a2dca0e9e9e57e88b479cf537549461a934</id>
<content type='text'>
When viewing page owner information, we may want to select blocks whose
PID/TGID/TASK_COMM_NAME appears in a user-specified list for data analysis
and aggregation.  But currently page_owner_sort only supports selecting
blocks associated with only one specified PID/TGID/TASK_COMM_NAME.

Therefore, following adjustments are made to fix the problem:

1. Enhance selecting function to support the selection of multiple
   PIDs/TGIDs/TASK_COMM_NAMEs.

The enhanced usages are as follows:

--pid &lt;pidlist&gt;         Select by pid. This selects the blocks whose PID
                        numbers appear in &lt;pidlist&gt;.
--tgid &lt;tgidlist&gt;       Select by tgid. This selects the blocks whose
                        TGID numbers appear in &lt;tgidlist&gt;.
--name &lt;cmdlist&gt;        Select by task command name. This selects the
                        blocks whose task command name appear in &lt;cmdlist&gt;.

Where &lt;pidlist&gt;, &lt;tgidlist&gt;, &lt;cmdlist&gt; are single arguments in the form of
a comma-separated list,which offers a way to specify individual selecting
rules.

For example, if you want to select blocks whose tgids are 1, 2 or 3, you
have to use 4 commands as follows:

        ./page_owner_sort &lt;input&gt; &lt;output1&gt; --tgid=1
        ./page_owner_sort &lt;input&gt; &lt;output2&gt; --tgid=2
        ./page_owner_sort &lt;input&gt; &lt;output3&gt; --tgid=3
        cat &lt;output1&gt; &lt;output2&gt; &lt;output3&gt; &gt; &lt;output&gt;

With this patch, you can use only 1 command to obtain the same result as
above:

        ./page_owner_sort &lt;input&gt; &lt;output1&gt; --tgid=1,2,3

2. Update explanations of --pid, --tgid and --name in the function
   usage() and the document(Documents/vm/page_owner.rst).

This work is coauthored by
        Yixuan Cao
        Shenghong Han
        Yinan Zhang
        Chongxi Zhao
        Yuhong Feng
        Yongqiang Liu

Link: https://lkml.kernel.org/r/20220401024856.767-2-yejiajian2018@email.szu.edu.cn
Signed-off-by: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Cc: Haowen Bai &lt;baihaowen@meizu.com&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: use fprintf() to send error messages to stderr</title>
<updated>2022-04-29T06:15:56Z</updated>
<author>
<name>Jiajian Ye</name>
<email>yejiajian2018@email.szu.edu.cn</email>
</author>
<published>2022-04-29T06:15:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=329687a03d18143f491b535d22be1cccc291bb58'/>
<id>urn:sha1:329687a03d18143f491b535d22be1cccc291bb58</id>
<content type='text'>
Error messages should be send to stderr using fprintf() instead of
printf().

This work is coauthored by
        Yixuan Cao
        Shenghong Han
        Yinan Zhang
        Chongxi Zhao
        Yuhong Feng
        Yongqiang Liu

Link: https://lkml.kernel.org/r/20220401024856.767-1-yejiajian2018@email.szu.edu.cn
Signed-off-by: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Haowen Bai &lt;baihaowen@meizu.com&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: remove -c option</title>
<updated>2022-04-01T18:46:09Z</updated>
<author>
<name>Yinan Zhang</name>
<email>zhangyinan2019@email.szu.edu.cn</email>
</author>
<published>2022-04-01T18:28:48Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=d8b7b3fa9f9b2dc67fa1df29c4ce98eb10d62824'/>
<id>urn:sha1:d8b7b3fa9f9b2dc67fa1df29c4ce98eb10d62824</id>
<content type='text'>
The -c option is used to cull by stacktrace.  Now, --cull option has
been Added in page_owner_sort.c.  Culling by stacktrace is one of the
function of "--cull".  No need to set an extra parameter.  So remove -c
option.

Remove parsing of -c when parse parameter and remove "-c" from usage.

This work is coauthored by
        Shenghong Han
        Yixuan Cao
        Chongxi Zhao
        Jiajian Ye
        Yuhong Feng
        Yongqiang Liu

Link: https://lkml.kernel.org/r/20220326085920.1470081-1-zhangyinan2019@email.szu.edu.cn
Signed-off-by: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Georgi Djakov &lt;georgi.djakov@linaro.org&gt;
Cc: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Jonathan Corbet &lt;corbet@lwn.net&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Cc: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Cc: Tang Bin &lt;tangbin@cmss.chinamobile.com&gt;
Cc: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Yongqiang Liu &lt;liuyongqiang13@huawei.com&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Cc: Zhenliang Wei &lt;weizhenliang@huawei.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: support for user-defined culling rules</title>
<updated>2022-03-25T02:06:45Z</updated>
<author>
<name>Jiajian Ye</name>
<email>yejiajian2018@email.szu.edu.cn</email>
</author>
<published>2022-03-25T01:09:38Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=9c8a0a8e599f4a949ef18207ba495fb557dd1016'/>
<id>urn:sha1:9c8a0a8e599f4a949ef18207ba495fb557dd1016</id>
<content type='text'>
When viewing page owner information, we may want to cull blocks of
information with our own rules.  So it is important to enhance culling
function to provide the support for customizing culling rules.
Therefore, following adjustments are made:

1. Add --cull option to support the culling of blocks of information
   with user-defined culling rules.

	./page_owner_sort &lt;input&gt; &lt;output&gt; --cull=&lt;rules&gt;
	./page_owner_sort &lt;input&gt; &lt;output&gt; --cull &lt;rules&gt;

  &lt;rules&gt; is a single argument in the form of a comma-separated list to
  specify individual culling rules, by the sequence of keys k1,k2, ....
  Mixed use of abbreviated and complete-form of keys is allowed.

  For reference, please see the document(Documentation/vm/page_owner.rst).

Now, assuming two blocks in the input file are as follows:

	Page allocated via order 0, mask xxxx, pid 1, tgid 1 (task_name_demo)
	PFN xxxx
	 prep_new_page+0xd0/0xf8
	 get_page_from_freelist+0x4a0/0x1290
	 __alloc_pages+0x168/0x340
	 alloc_pages+0xb0/0x158

	Page allocated via order 0, mask xxxx, pid 32, tgid 32 (task_name_demo)
	PFN xxxx
	 prep_new_page+0xd0/0xf8
	 get_page_from_freelist+0x4a0/0x1290
	 __alloc_pages+0x168/0x340
	 alloc_pages+0xb0/0x158

If we want to cull the blocks by stacktrace and task command name, we can
use this command:

	./page_owner_sort &lt;input&gt; &lt;output&gt; --cull=stacktrace,name

The output would be like:

	2 times, 2 pages, task_comm_name: task_name_demo
	 prep_new_page+0xd0/0xf8
	 get_page_from_freelist+0x4a0/0x1290
	 __alloc_pages+0x168/0x340
	 alloc_pages+0xb0/0x158

As we can see, these two blocks are culled successfully, for they share
the same pid and task command name.

However, if we want to cull the blocks by pid, stacktrace and task command
name, we can this command:

	./page_owner_sort &lt;input&gt; &lt;output&gt; --cull=stacktrace,name,pid

The output would be like:

	1 times, 1 pages, PID 1, task_comm_name: task_name_demo
	 prep_new_page+0xd0/0xf8
	 get_page_from_freelist+0x4a0/0x1290
	 __alloc_pages+0x168/0x340
	 alloc_pages+0xb0/0x158

	1 times, 1 pages, PID 32, task_comm_name: task_name_demo
	 prep_new_page+0xd0/0xf8
	 get_page_from_freelist+0x4a0/0x1290
	 __alloc_pages+0x168/0x340
	 alloc_pages+0xb0/0x158

As we can see, these two blocks are failed to cull, for their PIDs are
different.

2. Add explanations of --cull options to the document.

This work is coauthored by
	Yixuan Cao
	Shenghong Han
	Yinan Zhang
	Chongxi Zhao
	Yuhong Feng

Link: https://lkml.kernel.org/r/20220312145834.624-1-yejiajian2018@email.szu.edu.cn
Signed-off-by: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;
Cc: Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;
Cc: Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;
Cc: Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;
Cc: Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;
Cc: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>tools/vm/page_owner_sort.c: support for selecting by PID, TGID or task command name</title>
<updated>2022-03-25T02:06:45Z</updated>
<author>
<name>Jiajian Ye</name>
<email>yejiajian2018@email.szu.edu.cn</email>
</author>
<published>2022-03-25T01:09:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=8ea8613a616aff184df9e3ea2d3ec39d90832867'/>
<id>urn:sha1:8ea8613a616aff184df9e3ea2d3ec39d90832867</id>
<content type='text'>
When viewing page owner information, we may also need to select the blocks
by PID, TGID or task command name, which helps to get more accurate page
allocation information as needed.

Therefore, following adjustments are made:

1. Add three new options, including --pid, --tgid and --name, to support
   the selection of information blocks by a specific pid, tgid and task
   command name. In addtion, multiple options are allowed to be used at
   the same time.

	./page_owner_sort [input] [output] --pid &lt;PID&gt;
	./page_owner_sort [input] [output] --tgid &lt;TGID&gt;
	./page_owner_sort [input] [output] --name &lt;TASK_COMMAND_NAME&gt;

   Assuming a scenario when a multi-threaded program, ./demo (PID =
   5280), is running, and ./demo creates a child process (PID = 5281).

	$ps
	PID   TTY        TIME   CMD
	5215  pts/0    00:00:00  bash
	5280  pts/0    00:00:00  ./demo
	5281  pts/0    00:00:00  ./demo
	5282  pts/0    00:00:00  ps

   It would be better to filter out the records with tgid=5280 and the
   task name "demo" when debugging the parent process, and the specific
   usage is

	./page_owner_sort [input] [output] --tgid 5280 --name demo

2. Add explanations of three new options, including --pid, --tgid and
   --name, to the document.

This work is coauthored by
	Shenghong Han &lt;hanshenghong2019@email.szu.edu.cn&gt;,
	Yixuan Cao &lt;caoyixuan2019@email.szu.edu.cn&gt;,
	Yinan Zhang &lt;zhangyinan2019@email.szu.edu.cn&gt;,
	Chongxi Zhao &lt;zhaochongxi2019@email.szu.edu.cn&gt;,
	Yuhong Feng &lt;yuhongf@szu.edu.cn&gt;.

Link: https://lkml.kernel.org/r/1646835223-7584-1-git-send-email-yejiajian2018@email.szu.edu.cn
Signed-off-by: Jiajian Ye &lt;yejiajian2018@email.szu.edu.cn&gt;
Cc: Sean Anderson &lt;seanga2@gmail.com&gt;
Cc: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Cc: Zhenliang Wei &lt;weizhenliang@huawei.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
