Skip to content
Snippets Groups Projects
Commit 6cca8f72 authored by Aristeu Rozanski's avatar Aristeu Rozanski
Browse files

mm: unmap_mapping_range_tree() with i_mmap_rwsem shared

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2083861
Tested: by me with multiple test suites
Conflicts: context due missing 6e0e99d5

commit 2c865995
Author: Hugh Dickins <hughd@google.com>
Date:   Thu Mar 24 18:14:02 2022 -0700

    mm: unmap_mapping_range_tree() with i_mmap_rwsem shared

    Revert 48ec833b ("Revert "mm/memory.c: share the i_mmap_rwsem"") to
    reinstate c8475d14 ("mm/memory.c: share the i_mmap_rwsem"): the
    unmap_mapping_range family of functions do the unmapping of user pages
    (ultimately via zap_page_range_single) without modifying the interval tree
    itself, and unmapping races are necessarily guarded by page table lock,
    thus the i_mmap_rwsem should be shared in unmap_mapping_pages() and
    unmap_mapping_folio().

    Commit 48ec833b was intended as a short-term measure, allowing the
    other shared lock changes into 3.19 final, before investigating three
    trinity crashes, one of which had been bisected to commit c8475d14:

    [1] https://lkml.org/lkml/2014/11/14/342
    https://lore.kernel.org/lkml/5466142C.60100@oracle.com/
    [2] https://lkml.org/lkml/2014/12/22/213
    https://lore.kernel.org/lkml/549832E2.8060609@oracle.com/
    [3] https://lkml.org/lkml/2014/12/9/741
    https://lore.kernel.org/lkml/5487ACC5.1010002@oracle.com/

    Two of those were Bad page states: free_pages_prepare() found PG_mlocked
    still set - almost certain to have been fixed by 4.4 commit b87537d9
    ("mm: rmap use pte lock not mmap_sem to set PageMlocked").  The NULL deref
    on rwsem in [2]: unclear, only happened once, not bisected to c8475d14.

    No change to the i_mmap_lock_write() around __unmap_hugepage_range_final()
    in unmap_single_vma(): IIRC that's a special usage, helping to serialize
    hugetlbfs page table sharing, not to be dabbled with lightly.  No change
    to other uses of i_mmap_lock_write() by hugetlbfs.

    I am not aware of any significant gains from the concurrency allowed by
    this commit: it is submitted more to resolve an ancient misunderstanding.

    Link: https://lkml.kernel.org/r/e4a5e356-6c87-47b2-3ce8-c2a95ae84e20@google.com


Signed-off-by: default avatarHugh Dickins <hughd@google.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: Sasha Levin <sashal@kernel.org>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: default avatarAristeu Rozanski <arozansk@redhat.com>
parent e1a409a7
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment