summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinayak Menon <vinmenon@codeaurora.org>2015-11-20 13:37:08 +0530
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 21:13:01 -0700
commit588411ea51f10d2497c20c07c263649468a741f7 (patch)
tree4cd6bba549b6a7ec02ff3e7f93825cc4ea43c74e
parent6d7af116f255a99077867c16c5faa5c013936197 (diff)
mm: swap: fix swapcache usage for fast swap devices
1) The swap readahead algorithm need not be applied for fast swap devices like zram. 2) Code to set SWP_FAST is placed incorrectly, resulting in the flag not being set. Fix these to reduce the swapcache usage. Change-Id: I23d9af5819f4b25f90f14a12657fa19ed401fb2a Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
-rw-r--r--mm/swap_state.c5
-rw-r--r--mm/swapfile.c6
2 files changed, 5 insertions, 6 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c
index bfb0d7d6433e..4e166f1c692c 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -469,11 +469,10 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
unsigned long entry_offset = swp_offset(entry);
unsigned long offset = entry_offset;
unsigned long start_offset, end_offset;
- unsigned long mask = is_swap_fast(entry) ? 0 :
- (1UL << page_cluster) - 1;
+ unsigned long mask;
struct blk_plug plug;
- mask = swapin_nr_pages(offset) - 1;
+ mask = is_swap_fast(entry) ? 0 : swapin_nr_pages(offset) - 1;
if (!mask)
goto skip;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6522b8bbe178..c86c3fd4fc00 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2554,11 +2554,11 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
pr_err("swapon: discard_swap(%p): %d\n",
p, err);
}
-
- if (blk_queue_fast(bdev_get_queue(p->bdev)))
- p->flags |= SWP_FAST;
}
+ if (p->bdev && blk_queue_fast(bdev_get_queue(p->bdev)))
+ p->flags |= SWP_FAST;
+
mutex_lock(&swapon_mutex);
prio = -1;
if (swap_flags & SWAP_FLAG_PREFER)