• Barry Song's avatar
    mm: extend rmap flags arguments for folio_add_new_anon_rmap · 15bde4ab
    Barry Song authored
    Patch series "mm: clarify folio_add_new_anon_rmap() and
    __folio_add_anon_rmap()", v2.
    
    This patchset is preparatory work for mTHP swapin.
    
    folio_add_new_anon_rmap() assumes that new anon rmaps are always
    exclusive.  However, this assumption doesn’t hold true for cases like
    do_swap_page(), where a new anon might be added to the swapcache and is
    not necessarily exclusive.
    
    The patchset extends the rmap flags to allow folio_add_new_anon_rmap() to
    handle both exclusive and non-exclusive new anon folios.  The
    do_swap_page() function is updated to use this extended API with rmap
    flags.  Consequently, all new anon folios now consistently use
    folio_add_new_anon_rmap().  The special case for !folio_test_anon() in
    __folio_add_anon_rmap() can be safely removed.
    
    In conclusion, new anon folios always use folio_add_new_anon_rmap(),
    regardless of exclusivity.  Old anon folios continue to use
    __folio_add_anon_rmap() via folio_add_anon_rmap_pmd() and
    folio_add_anon_rmap_ptes().
    
    
    This patch (of 3):
    
    In the case of a swap-in, a new anonymous folio is not necessarily
    exclusive.  This patch updates the rmap flags to allow a new anonymous
    folio to be treated as either exclusive or non-exclusive.  To maintain the
    existing behavior, we always use EXCLUSIVE as the default setting.
    
    [akpm@linux-foundation.org: cleanup and constifications per David and akpm]
    [v-songbaohua@oppo.com: fix missing doc for flags of folio_add_new_anon_rmap()]
      Link: https://lkml.kernel.org/r/20240619210641.62542-1-21cnbao@gmail.com
    [v-songbaohua@oppo.com: enhance doc for extend rmap flags arguments for folio_add_new_anon_rmap]
      Link: https://lkml.kernel.org/r/20240622030256.43775-1-21cnbao@gmail.com
    Link: https://lkml.kernel.org/r/20240617231137.80726-1-21cnbao@gmail.com
    Link: https://lkml.kernel.org/r/20240617231137.80726-2-21cnbao@gmail.comSigned-off-by: default avatarBarry Song <v-songbaohua@oppo.com>
    Suggested-by: default avatarDavid Hildenbrand <david@redhat.com>
    Tested-by: default avatarShuai Yuan <yuanshuai@oppo.com>
    Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
    Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
    Cc: Chris Li <chrisl@kernel.org>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Ryan Roberts <ryan.roberts@arm.com>
    Cc: Suren Baghdasaryan <surenb@google.com>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: Yosry Ahmed <yosryahmed@google.com>
    Cc: Yu Zhao <yuzhao@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    15bde4ab
migrate_device.c 26.9 KB