From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752727AbcG2Naq (ORCPT ); Fri, 29 Jul 2016 09:30:46 -0400 Received: from gum.cmpxchg.org ([85.214.110.215]:55140 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751449AbcG2Nan (ORCPT ); Fri, 29 Jul 2016 09:30:43 -0400 Date: Fri, 29 Jul 2016 09:30:33 -0400 From: Johannes Weiner To: Minchan Kim Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mel Gorman , Rik van Riel , Hugh Dickins Subject: Re: [PATCH] mm: move swap-in anonymous page into active list Message-ID: <20160729133033.GA2034@cmpxchg.org> References: <1469762740-17860-1-git-send-email-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1469762740-17860-1-git-send-email-minchan@kernel.org> User-Agent: Mutt/1.6.2 (2016-07-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 29, 2016 at 12:25:40PM +0900, Minchan Kim wrote: > Every swap-in anonymous page starts from inactive lru list's head. > It should be activated unconditionally when VM decide to reclaim > because page table entry for the page always usually has marked > accessed bit. Thus, their window size for getting a new referece > is 2 * NR_inactive + NR_active while others is NR_active + NR_active. > > It's not fair that it has more chance to be referenced compared > to other newly allocated page which starts from active lru list's > head. > > Signed-off-by: Minchan Kim That behavior stood out to me as well recently, but I couldn't convince myself that activation is the right thing. The page can still have a valid copy on the swap device, so prefering to reclaim that page over a fresh one could make sense. But as you point out, having it start inactive instead of active actually ends up giving it *more* LRU time, and that seems to be without justification. So this change makes sense to me. Maybe somebody else remembers a good reason for why the behavior is the way it is, but likely it has always been an oversight. Acked-by: Johannes Weiner > --- > mm/memory.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/memory.c b/mm/memory.c > index 4425b6059339..3a730b920242 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2642,6 +2642,7 @@ int do_swap_page(struct fault_env *fe, pte_t orig_pte) > if (page == swapcache) { > do_page_add_anon_rmap(page, vma, fe->address, exclusive); > mem_cgroup_commit_charge(page, memcg, true, false); > + activate_page(page); > } else { /* ksm created a completely new copy */ > page_add_new_anon_rmap(page, vma, fe->address, false); > mem_cgroup_commit_charge(page, memcg, false, false); > -- > 1.9.1