Commit 23484337 authored by David Hildenbrand's avatar David Hildenbrand Committed by Kaixiong Yu
Browse files

fs/proc/task_mmu: indicate PM_FILE for PMD-mapped file THP

stable inclusion
from stable-v5.10.224
commit 3c6fa67023bcf6cc84c7b948db824693dc96c745
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBGU7R

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3c6fa67023bcf6cc84c7948db824693dc96c745

--------------------------------

[ Upstream commit 3f9f022e975d930709848a86a1c79775b0585202 ]

Patch series "fs/proc: move page_mapcount() to fs/proc/internal.h".

With all other page_mapcount() users in the tree gone, move
page_mapcount() to fs/proc/internal.h, rename it and extend the
documentation to prevent future (ab)use.

... of course, I find some issues while working on that code that I sort
first ;)

We'll now only end up calling page_mapcount() [now
folio_precise_page_mapcount()] on pages mapped via present page table
entries.  Except for /proc/kpagecount, that still does questionable
things, but we'll leave that legacy interface as is for now.

Did a quick sanity check.  Likely we would want some better selfestest for
/proc/$/pagemap + smaps.  I'll see if I can find some time to write some
more.

This patch (of 6):

Looks like we never taught pagemap_pmd_range() about the existence of
PMD-mapped file THPs.  Seems to date back to the times when we first added
support for non-anon THPs in the form of shmem THP.

Link: https://lkml.kernel.org/r/20240607122357.115423-1-david@redhat.com
Link: https://lkml.kernel.org/r/20240607122357.115423-2-david@redhat.com


Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Fixes: 800d8c63 ("shmem: add huge pages support")
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: default avatarLance Yang <ioworker0@gmail.com>
Reviewed-by: default avatarOscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Conflicts:
	fs/proc/task_mmu.c
[OLK-5.10 merge hulk inclusion patch c83efb0d
("arm64: mm: pagemap: Export pbha bit0 info")]
Signed-off-by: default avatarKaixiong Yu <yukaixiong@huawei.com>
parent f4c6b558
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1491,6 +1491,8 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
		if (pmd_pbha(pmd))
			flags |= PM_PBHA_BIT0;

		if (page && !PageAnon(page))
			flags |= PM_FILE;
		if (page && !migration && page_mapcount(page) == 1)
			flags |= PM_MMAP_EXCLUSIVE;