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

Configure Feed

Select the types of activity you want to include in your feed.

mm/memory: handle non-split locks correctly in zap_empty_pte_table()

While we handle pte_lockptr() == pmd_lockptr() correctly in
zap_pte_table_if_empty(), we don't handle it in zap_empty_pte_table(),
making the spin_trylock() always fail and forcing us onto the slow path.

So let's handle the scenario where pte_lockptr() == pmd_lockptr() better,
which can only happen if CONFIG_SPLIT_PTE_PTLOCKS is not set.

This is only relevant once we unlock CONFIG_PT_RECLAIM on architectures
that are not x86-64.

Link: https://lkml.kernel.org/r/20260119220708.3438514-3-david@kernel.org
Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reviewed-by: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

David Hildenbrand (Red Hat) and committed by
Andrew Morton
fb4ddf20 4c640eb4

+6 -4
+6 -4
mm/memory.c
··· 1830 1830 return details && details->reclaim_pt && (end - start >= PMD_SIZE); 1831 1831 } 1832 1832 1833 - static bool zap_empty_pte_table(struct mm_struct *mm, pmd_t *pmd, pmd_t *pmdval) 1833 + static bool zap_empty_pte_table(struct mm_struct *mm, pmd_t *pmd, 1834 + spinlock_t *ptl, pmd_t *pmdval) 1834 1835 { 1835 1836 spinlock_t *pml = pmd_lockptr(mm, pmd); 1836 1837 1837 - if (!spin_trylock(pml)) 1838 + if (ptl != pml && !spin_trylock(pml)) 1838 1839 return false; 1839 1840 1840 1841 *pmdval = pmdp_get(pmd); 1841 1842 pmd_clear(pmd); 1842 - spin_unlock(pml); 1843 + if (ptl != pml) 1844 + spin_unlock(pml); 1843 1845 return true; 1844 1846 } 1845 1847 ··· 1933 1931 * from being repopulated by another thread. 1934 1932 */ 1935 1933 if (can_reclaim_pt && direct_reclaim && addr == end) 1936 - direct_reclaim = zap_empty_pte_table(mm, pmd, &pmdval); 1934 + direct_reclaim = zap_empty_pte_table(mm, pmd, ptl, &pmdval); 1937 1935 1938 1936 add_mm_rss_vec(mm, rss); 1939 1937 lazy_mmu_mode_disable();