• David Hildenbrand's avatar
    mm/nommu: factor out check for NOMMU shared mappings into is_nommu_shared_mapping() · fc4f4be9
    David Hildenbrand authored
    Patch series "mm/nommu: don't use VM_MAYSHARE for MAP_PRIVATE mappings".
    
    Trying to reduce the confusion around VM_SHARED and VM_MAYSHARE first
    requires !CONFIG_MMU to stop using VM_MAYSHARE for MAP_PRIVATE mappings. 
    CONFIG_MMU only sets VM_MAYSHARE for MAP_SHARED mappings.
    
    This paves the way for further VM_MAYSHARE and VM_SHARED cleanups: for
    example, renaming VM_MAYSHARED to VM_MAP_SHARED to make it cleaner what is
    actually means.
    
    Let's first get the weird case out of the way and not use VM_MAYSHARE in
    MAP_PRIVATE mappings, using a new VM_MAYOVERLAY flag instead.
    
    
    This patch (of 3):
    
    We want to stop using VM_MAYSHARE in private mappings to pave the way for
    clarifying the semantics of VM_MAYSHARE vs.  VM_SHARED and reduce the
    confusion.  While CONFIG_MMU uses VM_MAYSHARE to represent MAP_SHARED,
    !CONFIG_MMU also sets VM_MAYSHARE for selected R/O private file mappings
    that are an effective overlay of a file mapping.
    
    Let's factor out all relevant VM_MAYSHARE checks in !CONFIG_MMU code into
    is_nommu_shared_mapping() first.
    
    Note that whenever VM_SHARED is set, VM_MAYSHARE must be set as well
    (unless there is a serious BUG).  So there is not need to test for
    VM_SHARED manually.
    
    No functional change intended.
    
    Link: https://lkml.kernel.org/r/20230102160856.500584-1-david@redhat.com
    Link: https://lkml.kernel.org/r/20230102160856.500584-2-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Nicolas Pitre <nico@fluxnic.net>
    Cc: Pavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    fc4f4be9
io_uring.c 110 KB