Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752544AbbLKTeN (ORCPT ); Fri, 11 Dec 2015 14:34:13 -0500 Received: from gum.cmpxchg.org ([85.214.110.215]:49220 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751064AbbLKTeM (ORCPT ); Fri, 11 Dec 2015 14:34:12 -0500 Date: Fri, 11 Dec 2015 14:33:58 -0500 From: Johannes Weiner To: Vladimir Davydov Cc: Andrew Morton , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/7] mm: free swap cache aggressively if memcg swap is full Message-ID: <20151211193358.GE3773@cmpxchg.org> References: <2c7ac3a5c2a2fb9b1c5136d8409652ed7ecc260f.1449742561.git.vdavydov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2c7ac3a5c2a2fb9b1c5136d8409652ed7ecc260f.1449742561.git.vdavydov@virtuozzo.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1332 Lines: 36 On Thu, Dec 10, 2015 at 02:39:19PM +0300, Vladimir Davydov wrote: > Swap cache pages are freed aggressively if swap is nearly full (>50% > currently), because otherwise we are likely to stop scanning anonymous > when we near the swap limit even if there is plenty of freeable swap > cache pages. We should follow the same trend in case of memory cgroup, > which has its own swap limit. > > Signed-off-by: Vladimir Davydov Acked-by: Johannes Weiner One note: > @@ -5839,6 +5839,29 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg) > return nr_swap_pages; > } > > +bool mem_cgroup_swap_full(struct page *page) > +{ > + struct mem_cgroup *memcg; > + > + VM_BUG_ON_PAGE(!PageLocked(page), page); > + > + if (vm_swap_full()) > + return true; > + if (!do_swap_account || !PageSwapCache(page)) > + return false; The callers establish PageSwapCache() under the page lock, which makes sense since they only inquire about the swap state when deciding what to do with a swapcache page at hand. So this check seems unnecessary. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/