diff options
author | Vinayak Menon <vinmenon@codeaurora.org> | 2015-02-25 19:43:59 +0530 |
---|---|---|
committer | Simon Shields <keepcalm444@gmail.com> | 2016-06-12 21:20:18 +1000 |
commit | a6ce37fb73dce407da9d7d1d03408602be84177c (patch) | |
tree | 85ca3a46532a4f2683cb4eab40130ad5707a094e /include/linux/swap.h | |
parent | d997b41417d94c22baaabd8d84a6a4f1e2e93fb9 (diff) | |
download | kernel_samsung_smdk4412-a6ce37fb73dce407da9d7d1d03408602be84177c.tar.gz kernel_samsung_smdk4412-a6ce37fb73dce407da9d7d1d03408602be84177c.tar.bz2 kernel_samsung_smdk4412-a6ce37fb73dce407da9d7d1d03408602be84177c.zip |
mm: swap: don't delay swap free for fast swap devices
There are couple of issues with swapcache usage when ZRAM is used
as swap device.
1) Kernel does a swap readahead which can be around 6 to 8 pages
depending on total ram, which is not required for zram since
accesses are fast.
2) Kernel delays the freeing up of swapcache expecting a later hit,
which again is useless in the case of zram.
3) This is not related to swapcache, but zram usage itself.
As mentioned in (2) kernel delays freeing of swapcache, but along with
that it delays zram compressed page free also. i.e. there can be 2 copies,
though one is compressed.
This patch addresses these issues using two new flags
QUEUE_FLAG_FAST and SWP_FAST, to indicate that accesses to the device
will be fast and cheap, and instructs the swap layer to free up
swap space agressively, and not to do read ahead.
Change-Id: I5d2d5176a5f9420300bb2f843f6ecbdb25ea80e4
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: D. Andrei Măceș <dmaces@nd.edu>
Conflicts:
include/linux/blkdev.h
include/linux/swap.h
mm/swap_state.c
mm/swapfile.c
Conflicts:
include/linux/blkdev.h
Diffstat (limited to 'include/linux/swap.h')
-rw-r--r-- | include/linux/swap.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index e73799d3b1c..be5eecc2bad 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -150,6 +150,7 @@ enum { SWP_BLKDEV = (1 << 6), /* its a block device */ /* add others here before... */ SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ + SWP_FAST = (1 << 9), /* blkdev access is fast and cheap */ }; #define SWAP_CLUSTER_MAX 32 @@ -201,9 +202,6 @@ struct swap_list_t { int next; /* swapfile to be used next */ }; -/* Swap 50% full? Release swapcache more aggressively.. */ -#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages) - /* linux/mm/page_alloc.c */ extern unsigned long totalram_pages; extern unsigned long totalreserve_pages; @@ -320,6 +318,21 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t, /* linux/mm/swapfile.c */ extern long nr_swap_pages; extern long total_swap_pages; +extern bool is_swap_fast(swp_entry_t entry); + +/* Swap 50% full? Release swapcache more aggressively.. */ +static inline bool vm_swap_full(struct swap_info_struct *si) +{ + /* + * If the swap device is fast, return true + * not to delay swap free. + */ + if (si->flags & SWP_FAST) + return true; + + return nr_swap_pages*2 < total_swap_pages; +} + extern void si_swapinfo(struct sysinfo *); extern swp_entry_t get_swap_page(void); extern swp_entry_t get_swap_page_of_type(int); @@ -379,6 +392,7 @@ static inline void mem_cgroup_uncharge_swap(swp_entry_t ent) #define nr_swap_pages 0L #define total_swap_pages 0L #define total_swapcache_pages 0UL +#define vm_swap_full(si) 0 #define si_swapinfo(val) \ do { (val)->freeswap = (val)->totalswap = 0; } while (0) |