From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbbC3FfN (ORCPT ); Mon, 30 Mar 2015 01:35:13 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:36281 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbbC3FfK (ORCPT ); Mon, 30 Mar 2015 01:35:10 -0400 Date: Mon, 30 Mar 2015 14:35:02 +0900 From: Minchan Kim To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Johannes Weiner , Mel Gorman , Rik van Riel , Shaohua Li , Yalin.Wang@sonymobile.com Subject: Re: [PATCH 3/4] mm: move lazy free pages to inactive list Message-ID: <20150330053502.GB3008@blaptop> References: <1426036838-18154-1-git-send-email-minchan@kernel.org> <1426036838-18154-3-git-send-email-minchan@kernel.org> <20150320154358.51bcf3cbceeb8fbbdb2b58e5@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150320154358.51bcf3cbceeb8fbbdb2b58e5@linux-foundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Andrew, On Fri, Mar 20, 2015 at 03:43:58PM -0700, Andrew Morton wrote: > On Wed, 11 Mar 2015 10:20:37 +0900 Minchan Kim wrote: > > > MADV_FREE is hint that it's okay to discard pages if there is > > memory pressure and we uses reclaimers(ie, kswapd and direct reclaim) > > to free them so there is no worth to remain them in active anonymous LRU > > so this patch moves them to inactive LRU list's head. > > > > This means that MADV_FREE-ed pages which were living on the inactive list > > are reclaimed first because they are more likely to be cold rather than > > recently active pages. > > > > A arguable issue for the approach would be whether we should put it to > > head or tail in inactive list. I selected *head* because kernel cannot > > make sure it's really cold or warm for every MADV_FREE usecase but > > at least we know it's not *hot* so landing of inactive head would be > > comprimise for various usecases. > > > > This is fixing a suboptimal behavior of MADV_FREE when pages living on > > the active list will sit there for a long time even under memory > > pressure while the inactive list is reclaimed heavily. This basically > > breaks the whole purpose of using MADV_FREE to help the system to free > > memory which is might not be used. > > > > @@ -789,6 +790,23 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, > > update_page_reclaim_stat(lruvec, file, 0); > > } > > > > + > > +static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec, > > + void *arg) > > > > ... > > > > @@ -844,6 +866,18 @@ void deactivate_file_page(struct page *page) > > } > > } > > > > +void deactivate_page(struct page *page) > > +{ > > lru_deactivate_file_fn() and deactivate_file_page() are carefully > documented and lru_deactivate_fn() and deactivate_page() should > be as well. In fact it becomes more important now that we have two > similar-looking things. Sorry, I have missed this comment. Acutally, deactive_file_page was too specific on file-backed page invalidation when I implemented first time. That's why it had a lot description but deactivate_page is too general so I think short comment is enough. :) Here it goes. Thanks. >>From 1dbff1d18876962e5248346b59e41014561c09ac Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Mon, 30 Mar 2015 14:30:44 +0900 Subject: [PATCH] mm: document deactivate_page This patch adds function description for deactivate_page. Signed-off-by: Minchan Kim --- mm/swap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/swap.c b/mm/swap.c index 6b5adc7..b65fc8c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -866,6 +866,13 @@ void deactivate_file_page(struct page *page) } } +/** + * deactivate_page - deactivate a page + * @page: page to deactivate + * + * This function moves @page to inactive list if @page was on active list and + * was not unevictable page to accelerate to reclaim @page. + */ void deactivate_page(struct page *page) { if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) { -- 1.9.3 > > -- Kind regards, Minchan Kim