Re: [PATCH 2/2] mm,swap: skip swap readahead if page was obtained instantaneously

From: Christoph Hellwig
Date: Wed Sep 23 2020 - 02:35:14 EST


On Mon, Sep 21, 2020 at 10:01:48PM -0400, Rik van Riel wrote:
> + struct page *page;
> unsigned long entry_offset = swp_offset(entry);
> unsigned long offset = entry_offset;
> unsigned long start_offset, end_offset;
> @@ -668,11 +669,18 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
> end_offset = si->max - 1;
>
> blk_start_plug(&plug);
> + /* If we read the page without waiting on IO, skip readahead. */
> + page = swap_cluster_read_one(entry, offset, gfp_mask, vma, addr, false);
> + if (page && PageUptodate(page))
> + goto skip_unplug;
> +

At least for the normal block device path the plug will prevent the
I/O submission from actually happening and thus PageUptodate from
becoming true. I think we need to split the different code paths
more cleanly.

Btw, what device type and media did you test this with? What kind of
numbers did you get on what workload?