summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin
diff options
context:
space:
mode:
authorDavid Hildenbrand (Arm) <david@kernel.org>2026-11-16 19:29:27 +0100
committerAndrew Morton <akpm@linux-foundation.org>2026-11-22 22:24:15 -0800
commit39e0ae8bf7291d0ab46b2323acb927dd132ce6ca (patch)
tree58874cbc2bc9b785138ce692d814fdc752fea9a8 /tools/perf/scripts/python/bin
parent49b51228a108b243dbe2ac41ae583ad3c7c5b848 (diff)
mm/hugetlb: fix mremap() racing with page migration
Migration of anon hugetlb folios walks the anon_vma, so the file's i_mmap_rwsem does not serialize it against move_hugetlb_page_tables(). There are various issues with that. Most importantly, move_huge_pte() releases both page table locks before the TLB is flushed. Migration can then find the destination entry and finish migration, reusing the old folio while the TLB still has entries cached. Hold the anon_vma write lock across the move and the final TLB flush. This also prevents concurrent rmap walks from missing entries moved during rollback. When we must allocate a destination page table, flush the TLB before dropping the anon_vma lock, then reacquire it after allocation. Dropping the lock only works around lockdep: hugetlb folios are not reclaimed or migrated by allocation compaction, but their anon_vmas share the lock class used by ordinary anonymous memory. Having a separate lock class for hugetlb's anon_vma (like already done for i_mmap_rwsem via hugetlbfs_i_mmap_rwsem_key) requires more thought. There is a concern that this can block page migration of anonymous folios quite a while ... which is not really different to what happens to page-cache folios today. If ever a problem, we can temporarily release the lock. So let's keep it simple for now. It is a shame that hugetlb has to implement everything core-mm implements in a different way that just screams for problems. Link: https://patch.msgid.link/20261116-fixes_hugetlb-v2-6-4dd9e94ea9ac@kernel.org Fixes: 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") Signed-off-by: David Hildenbrand (Arm) <david@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reported-by: Chris Mason <mason@kernel.org> Acked-by: Muchun Song <muchun.song@linux.dev> Tested-by: Gregory Price (Meta) <gourry@gourry.net> Link: https://lore.kernel.org/179490494079.482102.4618915344813254218.b4-reply@b4 Reviewed-by: Gregory Price (Meta) <gourry@gourry.net> Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org> Cc: Oscar Salvador <osalvador@suse.de> Cc: Naoya Horiguchi <nao.horiguchi@gmail.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Andy Whitcroft <apw@canonical.com> Cc: Miaohe Lin <linmiaohe@huawei.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Rik van Riel <riel@surriel.com> Cc: Hugh Dickins <hughd@google.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Vivek Kasireddy <vivek.kasireddy@intel.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Liam R. Howlett <liam@infradead.org> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: Mike Rapoport <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Shuah Khan <skhan@linuxfoundation.org> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Peter Xu <peterx@redhat.com> Cc: Breno Leitao <leitao@debian.org> Cc: Will Deacon <will@kernel.org> Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Josef Bacik <josef@toxicpanda.com> Cc: Daehyeon Ko <4ncienth@gmail.com> Cc: luojiajun <luojiajun3@huawei.com> Cc: Ackerley Tng <ackerleytng@google.com> Cc: <stable@vger.kernel.org> mm/hugetlb.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions