Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/proc/task_mmu: convert pagemap_hugetlb_range() to work on folios

Patch series "fs/proc/task_mmu: convert hugetlb functions to work on folis".

Let's convert two more functions, getting rid of two more page_mapcount()
calls.


This patch (of 2):

Let's get rid of another page_mapcount() check and simply use
folio_likely_mapped_shared(), which is precise for hugetlb folios.

While at it, also check for PMD table sharing, like we do in
smaps_hugetlb_range().

No functional change intended, except that we would now detect hugetlb
folios shared via PMD table sharing correctly.

Link: https://lkml.kernel.org/r/20240417092313.753919-1-david@redhat.com
Link: https://lkml.kernel.org/r/20240417092313.753919-2-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand and committed by
Andrew Morton
88e4e47c 122ff80e

+4 -3
+4 -3
fs/proc/task_mmu.c
··· 1578 1578 1579 1579 pte = huge_ptep_get(ptep); 1580 1580 if (pte_present(pte)) { 1581 - struct page *page = pte_page(pte); 1581 + struct folio *folio = page_folio(pte_page(pte)); 1582 1582 1583 - if (!PageAnon(page)) 1583 + if (!folio_test_anon(folio)) 1584 1584 flags |= PM_FILE; 1585 1585 1586 - if (page_mapcount(page) == 1) 1586 + if (!folio_likely_mapped_shared(folio) && 1587 + !hugetlb_pmd_shared(ptep)) 1587 1588 flags |= PM_MMAP_EXCLUSIVE; 1588 1589 1589 1590 if (huge_pte_uffd_wp(pte))