From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751618AbdBMFGl (ORCPT ); Mon, 13 Feb 2017 00:06:41 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:56564 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbdBMFGk (ORCPT ); Mon, 13 Feb 2017 00:06:40 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.223.161 X-Original-MAILFROM: minchan@kernel.org Date: Mon, 13 Feb 2017 14:06:36 +0900 From: Minchan Kim To: Shaohua Li Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Kernel-team@fb.com, danielmicay@gmail.com, mhocko@suse.com, hughd@google.com, hannes@cmpxchg.org, riel@redhat.com, mgorman@techsingularity.net, akpm@linux-foundation.org Subject: Re: [PATCH V2 3/7] mm: reclaim MADV_FREE pages Message-ID: <20170213050636.GB27544@bbox> References: <9426fa2cf9fe320a15bfb20744c451eb6af1710a.1486163864.git.shli@fb.com> <20170210065839.GD25078@bbox> <20170210174307.GC86050@shli-mbp.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170210174307.GC86050@shli-mbp.local> 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 On Fri, Feb 10, 2017 at 09:43:07AM -0800, Shaohua Li wrote: < snip > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index 947ab6f..b304a84 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -864,7 +864,7 @@ static enum page_references page_check_references(struct page *page, > > > return PAGEREF_RECLAIM; > > > > > > if (referenced_ptes) { > > > - if (PageSwapBacked(page)) > > > + if (PageSwapBacked(page) || PageAnon(page)) > > > > If anyone accesses MADV_FREEed range with load op, not store, > > why shouldn't we discard that pages? > > Don't have strong opinion about this, userspace probably shouldn't do this. I'm > ok to delete it if you insist. Yes, I prefer to removing unnecessary code unless there is a some reaason. > > > > return PAGEREF_ACTIVATE; > > > /* > > > * All mapped pages start out with page table < snip > > > > @@ -971,7 +971,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, > > > int may_enter_fs; > > > enum page_references references = PAGEREF_RECLAIM_CLEAN; > > > bool dirty, writeback; > > > - bool lazyfree = false; > > > + bool lazyfree; > > > int ret = SWAP_SUCCESS; > > > > > > cond_resched(); > > > @@ -986,6 +986,8 @@ static unsigned long shrink_page_list(struct list_head *page_list, > > > > > > sc->nr_scanned++; > > > > > > + lazyfree = page_is_lazyfree(page); > > > + > > > if (unlikely(!page_evictable(page))) > > > goto cull_mlocked; > > > > > > @@ -993,7 +995,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, > > > goto keep_locked; > > > > > > /* Double the slab pressure for mapped and swapcache pages */ > > > - if (page_mapped(page) || PageSwapCache(page)) > > > + if ((page_mapped(page) || PageSwapCache(page)) && !lazyfree) > > > sc->nr_scanned++; > > > > In this phase, we cannot know whether lazyfree marked page is discarable > > or not. If it is freeable and mapped, this logic makes sense. However, > > if the page is dirty? > > I think this doesn't matter. If the page is dirty, it will go to reclaim in > next round and swap out. At that time, we will add nr_scanned there. If the lazyfree page in LRU comes around again into this, it's true but the page could be freed before that. Having said that, I don't know how critical it is and what kinds of rationale was to push slab reclaim so I don't insist on it. Thanks.