]> www.infradead.org Git - nvme.git/commitdiff
swap: remove remnants of polling from read_swap_cache_async
authorSuren Baghdasaryan <surenb@google.com>
Fri, 30 Jun 2023 21:19:52 +0000 (14:19 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 24 Aug 2023 23:20:16 +0000 (16:20 -0700)
Patch series "Per-VMA lock support for swap and userfaults", v7.

When per-VMA locks were introduced in [1] several types of page faults
would still fall back to mmap_lock to keep the patchset simple.  Among
them are swap and userfault pages.  The main reason for skipping those
cases was the fact that mmap_lock could be dropped while handling these
faults and that required additional logic to be implemented.  Implement
the mechanism to allow per-VMA locks to be dropped for these cases.

First, change handle_mm_fault to drop per-VMA locks when returning
VM_FAULT_RETRY or VM_FAULT_COMPLETED to be consistent with the way
mmap_lock is handled.  Then change folio_lock_or_retry to accept vm_fault
and return vm_fault_t which simplifies later patches.  Finally allow swap
and uffd page faults to be handled under per-VMA locks by dropping per-VMA
and retrying, the same way it's done under mmap_lock.  Naturally, once VMA
lock is dropped that VMA should be assumed unstable and can't be used.

This patch (of 6):

Commit [1] introduced IO polling support duding swapin to reduce swap read
latency for block devices that can be polled.  However later commit [2]
removed polling support.  Therefore it seems safe to remove do_poll
parameter in read_swap_cache_async and always call swap_readpage with
synchronous=false waiting for IO completion in folio_lock_or_retry.

[1] commit 23955622ff8d ("swap: add block io poll in swapin path")
[2] commit 9650b453a3d4 ("block: ignore RWF_HIPRI hint for sync dio")

Link: https://lkml.kernel.org/r/20230630211957.1341547-1-surenb@google.com
Link: https://lkml.kernel.org/r/20230630211957.1341547-2-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Laurent Dufour <ldufour@linux.ibm.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michel Lespinasse <michel@lespinasse.org>
Cc: Minchan Kim <minchan@google.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Punit Agrawal <punit.agrawal@bytedance.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/madvise.c
mm/swap.h
mm/swap_state.c

index b1f53a95e3a53c84ba4eb2a2934f95717324c01f..4dded5d27e7eaa7c109663059d6077211335e542 100644 (file)
@@ -217,7 +217,7 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
                ptep = NULL;
 
                page = read_swap_cache_async(entry, GFP_HIGHUSER_MOVABLE,
-                                            vma, addr, false, &splug);
+                                            vma, addr, &splug);
                if (page)
                        put_page(page);
        }
@@ -262,7 +262,7 @@ static void shmem_swapin_range(struct vm_area_struct *vma,
                rcu_read_unlock();
 
                page = read_swap_cache_async(entry, mapping_gfp_mask(mapping),
-                                            vma, addr, false, &splug);
+                                            vma, addr, &splug);
                if (page)
                        put_page(page);
 
index 7c033d793f15f581b06ec311f626a87caa5558fe..8a3c7a0ace4f0c29180f5b39ee9d363b05a2b9f6 100644 (file)
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -46,7 +46,6 @@ struct folio *filemap_get_incore_folio(struct address_space *mapping,
 struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
                                   struct vm_area_struct *vma,
                                   unsigned long addr,
-                                  bool do_poll,
                                   struct swap_iocb **plug);
 struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
                                     struct vm_area_struct *vma,
index d157862ba0a6981894058c13d9c3526e8e652b78..01f15139b7d9e52b4b4a882b130bceffc7d4be98 100644 (file)
@@ -526,15 +526,14 @@ fail_put_swap:
  */
 struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
                                   struct vm_area_struct *vma,
-                                  unsigned long addr, bool do_poll,
-                                  struct swap_iocb **plug)
+                                  unsigned long addr, struct swap_iocb **plug)
 {
        bool page_was_allocated;
        struct page *retpage = __read_swap_cache_async(entry, gfp_mask,
                        vma, addr, &page_was_allocated);
 
        if (page_was_allocated)
-               swap_readpage(retpage, do_poll, plug);
+               swap_readpage(retpage, false, plug);
 
        return retpage;
 }
@@ -629,7 +628,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
        struct swap_info_struct *si = swp_swap_info(entry);
        struct blk_plug plug;
        struct swap_iocb *splug = NULL;
-       bool do_poll = true, page_allocated;
+       bool page_allocated;
        struct vm_area_struct *vma = vmf->vma;
        unsigned long addr = vmf->address;
 
@@ -637,7 +636,6 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
        if (!mask)
                goto skip;
 
-       do_poll = false;
        /* Read a page_cluster sized and aligned cluster around offset. */
        start_offset = offset & ~mask;
        end_offset = offset | mask;
@@ -669,7 +667,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
        lru_add_drain();        /* Push any new pages onto the LRU now */
 skip:
        /* The page was likely read above, so no need for plugging here */
-       return read_swap_cache_async(entry, gfp_mask, vma, addr, do_poll, NULL);
+       return read_swap_cache_async(entry, gfp_mask, vma, addr, NULL);
 }
 
 int init_swap_address_space(unsigned int type, unsigned long nr_pages)
@@ -837,7 +835,7 @@ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask,
 skip:
        /* The page was likely read above, so no need for plugging here */
        return read_swap_cache_async(fentry, gfp_mask, vma, vmf->address,
-                                    ra_info.win == 1, NULL);
+                                    NULL);
 }
 
 /**