• Peter Xu's avatar
    mm/shmem: unconditionally set pte dirty in mfill_atomic_install_pte · 9ae0f87d
    Peter Xu authored
    Patch series "mm: A few cleanup patches around zap, shmem and uffd", v4.
    
    IMHO all of them are very nice cleanups to existing code already,
    they're all small and self-contained.  They'll be needed by uffd-wp
    coming series.
    
    This patch (of 4):
    
    It was conditionally done previously, as there's one shmem special case
    that we use SetPageDirty() instead.  However that's not necessary and it
    should be easier and cleaner to do it unconditionally in
    mfill_atomic_install_pte().
    
    The most recent discussion about this is here, where Hugh explained the
    history of SetPageDirty() and why it's possible that it's not required
    at all:
    
    https://lore.kernel.org/lkml/alpine.LSU.2.11.2104121657050.1097@eggly.anvils/
    
    Currently mfill_atomic_install_pte() has three callers:
    
            1. shmem_mfill_atomic_pte
            2. mcopy_atomic_pte
            3. mcontinue_atomic_pte
    
    After the change: case (1) should have its SetPageDirty replaced by the
    dirty bit on pte (so we unify them together, finally), case (2) should
    have no functional change at all as it has page_in_cache==false, case
    (3) may add a dirty bit to the pte.  However since case (3) is
    UFFDIO_CONTINUE for shmem, it's merely 100% sure the page is dirty after
    all because UFFDIO_CONTINUE normally requires another process to modify
    the page cache and kick the faulted thread, so should not make a real
    difference either.
    
    This should make it much easier to follow on which case will set dirty
    for uffd, as we'll simply set it all now for all uffd related ioctls.
    Meanwhile, no special handling of SetPageDirty() if there's no need.
    
    Link: https://lkml.kernel.org/r/20210915181456.10739-1-peterx@redhat.com
    Link: https://lkml.kernel.org/r/20210915181456.10739-2-peterx@redhat.comSigned-off-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarAxel Rasmussen <axelrasmussen@google.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Liam Howlett <liam.howlett@oracle.com>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: "Kirill A . Shutemov" <kirill@shutemov.name>
    Cc: Jerome Glisse <jglisse@redhat.com>
    Cc: Alistair Popple <apopple@nvidia.com>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    9ae0f87d
shmem.c 108 KB