]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/mm: Remove possible false-positive warning in pte_free_defer()
authorGerald Schaefer <gerald.schaefer@linux.ibm.com>
Wed, 9 Jul 2025 18:34:30 +0000 (20:34 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 23 Jul 2025 16:06:32 +0000 (18:06 +0200)
Commit 8211dad627981 ("s390: add pte_free_defer() for pgtables sharing
page") added a warning to pte_free_defer(), on our request. It was meant
to warn if this would ever be reached for KVM guest mappings, because
the page table would be freed w/o a gmap_unlink(). THP mappings are not
allowed for KVM guests on s390, so this should never happen.

However, it is possible that the warning is triggered in a valid case as
false-positive.

s390_enable_sie() takes the mmap_lock, marks all VMAs as VM_NOHUGEPAGE and
splits possibly existing THP guest mappings. mm->context.has_pgste is set
to 1 before that, to prevent races with the mm_has_pgste() check in
MADV_HUGEPAGE.

khugepaged drops the mmap_lock for file mappings and might run in parallel,
before a vma is marked VM_NOHUGEPAGE, but after mm->context.has_pgste was
set to 1. If it finds file mappings to collapse, it will eventually call
pte_free_defer(). This will trigger the warning, but it is a valid case
because gmap is not yet set up, and the THP mappings will be split again.

Therefore, remove the warning and the comment.

Fixes: 8211dad627981 ("s390: add pte_free_defer() for pgtables sharing page")
Cc: <stable@vger.kernel.org> # 6.6+
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/mm/pgalloc.c

index b449fd2605b03ecd0435dc96fbb45d49a726cea7..d2f6f1f6d2fcb9f6dff4caabf4cbc455bdbc7bcb 100644 (file)
@@ -173,11 +173,6 @@ void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable)
        struct ptdesc *ptdesc = virt_to_ptdesc(pgtable);
 
        call_rcu(&ptdesc->pt_rcu_head, pte_free_now);
-       /*
-        * THPs are not allowed for KVM guests. Warn if pgste ever reaches here.
-        * Turn to the generic pte_free_defer() version once gmap is removed.
-        */
-       WARN_ON_ONCE(mm_has_pgste(mm));
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */