[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170725015151.19502-4-ying.huang@intel.com>
Date: Tue, 25 Jul 2017 09:51:48 +0800
From: "Huang, Ying" <ying.huang@...el.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Huang Ying <ying.huang@...el.com>,
Johannes Weiner <hannes@...xchg.org>,
Minchan Kim <minchan@...nel.org>,
Rik van Riel <riel@...hat.com>, Shaohua Li <shli@...nel.org>,
Hugh Dickins <hughd@...gle.com>,
Fengguang Wu <fengguang.wu@...el.com>,
Tim Chen <tim.c.chen@...el.com>,
Dave Hansen <dave.hansen@...el.com>
Subject: [PATCH -mm -v3 3/6] mm, swap: Fix swap readahead marking
From: Huang Ying <ying.huang@...el.com>
In the original implementation, it is possible that the existing pages
in the swap cache (not newly readahead) could be marked as the
readahead pages. This will cause the statistics of swap readahead be
wrong and influence the swap readahead algorithm too.
This is fixed via marking a page as the readahead page only if it is
newly allocated and read from the disk.
When testing with linpack, after the fixing the swap readahead hit
rate increased from ~66% to ~86%.
Signed-off-by: "Huang, Ying" <ying.huang@...el.com>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Minchan Kim <minchan@...nel.org>
Cc: Rik van Riel <riel@...hat.com>
Cc: Shaohua Li <shli@...nel.org>
Cc: Hugh Dickins <hughd@...gle.com>
Cc: Fengguang Wu <fengguang.wu@...el.com>
Cc: Tim Chen <tim.c.chen@...el.com>
Cc: Dave Hansen <dave.hansen@...el.com>
---
mm/swap_state.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 8be7153967ed..d4d33c43ed36 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -508,7 +508,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
unsigned long start_offset, end_offset;
unsigned long mask;
struct blk_plug plug;
- bool do_poll = true;
+ bool do_poll = true, page_allocated;
mask = swapin_nr_pages(offset) - 1;
if (!mask)
@@ -524,14 +524,18 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
blk_start_plug(&plug);
for (offset = start_offset; offset <= end_offset ; offset++) {
/* Ok, do the async read-ahead now */
- page = read_swap_cache_async(swp_entry(swp_type(entry), offset),
- gfp_mask, vma, addr, false);
+ page = __read_swap_cache_async(
+ swp_entry(swp_type(entry), offset),
+ gfp_mask, vma, addr, &page_allocated);
if (!page)
continue;
- if (offset != entry_offset &&
- likely(!PageTransCompound(page))) {
- SetPageReadahead(page);
- percpu_counter_inc(&swapin_readahead_total);
+ if (page_allocated) {
+ swap_readpage(page, false);
+ if (offset != entry_offset &&
+ likely(!PageTransCompound(page))) {
+ SetPageReadahead(page);
+ percpu_counter_inc(&swapin_readahead_total);
+ }
}
put_page(page);
}
--
2.13.2
Powered by blists - more mailing lists