From 3a4b07aef2505c782e82ed5f851ac3b8782c7fe4 Mon Sep 17 00:00:00 2001 From: Vinayak Menon Date: Thu, 5 Jul 2018 17:08:26 +0530 Subject: [PATCH] mm: swap: free up swap on mm reap With the swap slots feature, the freeing up of swap space during the mm reap (kill or oom reap for e.g.) is delayed till a threshold is reached. This is done mainly to reduce the fragmentation of swap space. The caching is done per cpu. But with zram, this causes zram space consumed not being free up immediately on task kill or oom reap. Since we don't use THP swap, fragmentation is not a concern. So free up the slots without caching when the swap device is a synchronous one. Note that this does not disable the swap slots feature which can take into effect during swap slots allocation. Change-Id: I9985edfdd88723d38ae905496556e07fb8bf09af Signed-off-by: Vinayak Menon [swatsrid@codeaurora.org: Fix merge conflicts] Signed-off-by: Swathi Sridhar Signed-off-by: Isaac J. Manjarres --- mm/swap_slots.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/swap_slots.c b/mm/swap_slots.c index 63a7b4563a57..5d7f9a624ae5 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -278,9 +278,12 @@ static int refill_swap_slots_cache(struct swap_slots_cache *cache) int free_swap_slot(swp_entry_t entry) { struct swap_slots_cache *cache; + struct swap_info_struct *si; + si = swp_swap_info(entry); cache = raw_cpu_ptr(&swp_slots); - if (likely(use_swap_slot_cache && cache->slots_ret)) { + if (!(si->flags & SWP_SYNCHRONOUS_IO) && + use_swap_slot_cache && cache->slots_ret) { spin_lock_irq(&cache->free_lock); /* Swap slots cache may be deactivated before acquiring lock */ if (!use_swap_slot_cache || !cache->slots_ret) {