Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbdCCQ4A (ORCPT ); Fri, 3 Mar 2017 11:56:00 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:39436 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbdCCQzY (ORCPT ); Fri, 3 Mar 2017 11:55:24 -0500 Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=fb.com; Date: Fri, 3 Mar 2017 08:02:27 -0800 From: Shaohua Li To: Minchan Kim CC: , , , , , , , Subject: Re: + mm-reclaim-madv_free-pages.patch added to -mm tree Message-ID: <20170303160226.GA35838@shli-mbp.local> References: <58b616a6.hCl1D/BVn0fPDi+K%akpm@linux-foundation.org> <20170303025237.GB3503@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170303025237.GB3503@bbox> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [2620:10d:c090:180::8db8] X-ClientProxiedBy: MWHPR11CA0020.namprd11.prod.outlook.com (10.172.48.158) To BN6PR15MB1635.namprd15.prod.outlook.com (10.175.131.9) X-MS-Office365-Filtering-Correlation-Id: 14794d28-f86d-46ef-3ec4-08d4624eb805 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR15MB1635; X-Microsoft-Exchange-Diagnostics: 1;BN6PR15MB1635;3:kTvBAma8cCxgsqURG71baG+WdRxxKvcuVg/rzMXs5i7GJL/hfCKUJlGht1lSZIveiCe5qC/WohCmIIeGCXqUKU162KkZBS5/czFvMOhKNl2eib28FvafwnV+mOzyv7bXqsouiuwY4QWuh7vMN53l9Gbx/GzNOf5fveoDkEcqRA/0xErX3da9n0PvmlUcdv9+y2x7f7coCzpoXbwX8a4VE3oXkIqDfj2vpW+nw6otKOV3ZrxHqk3Voec6K/4fkSd7+54ThU467kq9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q4KQ2zw0wuaDKnxJPoDlZ/a6BtoqYd0pShuToOFVESVKrreF3OBs6M2G+54YaVUGu7CiC8G7WqlGsmRxIwls3hJ/hw9jFFJ7raD2LZ3MTSi44N8QzB8Nq2G7sf+99LyzdMtxOS2VlvqapcJyoFr2SakbdnspUioEIdpl08k7pvBF1O18JUyH0WN6JDhj2nDKc8KOZ7Qs5D+xAObE8AmAA6Jh4umkYU4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(10436049006162)(67672495146484)(211936372134217)(42068640409301); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(6072148);SRVR:BN6PR15MB1635;BCL:0;PCL:0;RULEID:;SRVR:BN6PR15MB1635; X-Microsoft-Exchange-Diagnostics: 1;BN6PR15MB1635;4:Qu4gS3Q3W1M//b/IGLDtnbMSaiwQa0W++aGvlqCT8pt9F/1JazbggZSw7i866XSx38+YzDOmq5IQ+jLXadIieAdmGGqUxaMBWVzAg7tHTKLwhtvvrsvvIS0Z+7SCh7FYrC7f42qrtTHWwLzietOqNWpetz42/0YQQ6qot2GyyLwgnKwj3avGIf33jh5EZJ3kUQ9m2xwS/y/Et6GMOS6KBAM7mcJl4GJoptCkHEB0ayB24xSuwWON10mFDoG+Kqwx84kwhz6l6nRwtO4WTouzywDszAM/UlyYIdf9G1ZQ7harliv829Pdy1Qwma4JUJqDFPNXA+5DixTKVCgFjhAaMU65nZOIWpjVt8pASTUHrZAsx8XcSabuPQA+dx+3yPEaxrH+Q/86POEQABIw5dAmpgouNF6ZU2IxoEHOFIXTMesVniiZR3oFkFGkWXO5ncg2wws0P9Xvv7c8uzrB0FsgVaiNigkeM+el6y+ODewWANmtsu0Ma4Ba3gqPWL1UOrK1hKdPaOtW/XByAz5ev7TV8xCFLVVEBL0DLzc2N2rUuEGsoMmW3gERQ5FjoZyzswbOAu3YjnRBlJHgfsfBREAhqpLCYPbSQeHFsSxcwdGc8OBvZAluK5VKMRjAdtNvjzaRl8LURct/bzmR+TQzlKd48u/SiQTAcYj3Jzu6Kwkd4FEuDZlDwrLMEBNXmXvt3wa3B/HHXMcoSl3+A4S9cBhplDI0PhjyELtpBbdYc8Rh++/FUZDICrXV3Dk3RrGlhb8n X-Forefront-PRVS: 0235CBE7D0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(24454002)(6506006)(50466002)(8676002)(81166006)(4001350100001)(76176999)(7736002)(54356999)(229853002)(25786008)(6666003)(53546006)(305945005)(53936002)(50986999)(2950100002)(4326008)(83506001)(6916009)(86362001)(5660300001)(189998001)(55016002)(33656002)(9686003)(6306002)(230783001)(966004)(38730400002)(98436002)(42186005)(54906002)(110136004)(46406003)(6116002)(47776003)(2906002)(575784001)(6246003)(1076002)(92566002)(23726003)(97756001)(18370500001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR15MB1635;H:shli-mbp.local;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR15MB1635;23:+XYm/HrJuF3V/q6UtXH77+kZ+C83nVKCkZWd8pP3T?= =?us-ascii?Q?KNy/zoZIyR7lNt7ZV+hE0SIZPmSudKKVO2v/wlia03LYM/PwbEhYH8Jyw5+e?= =?us-ascii?Q?T/8yLTwr85M4fUKMh/aRB+51CJ0pofB3m4X1vhUSk1iL0BJwWZVAJzJ3NkqG?= =?us-ascii?Q?bd0r8iC9nfTxyN/HNkhYyBc5LX69pTfAKdwrkhfjn85T3vDDxcki4GD/rrMZ?= =?us-ascii?Q?1ykRGNnLxwlwEjew9mn08j3ApmKlAZ5SoApFPQzkfhqMEQewNOEuJrgKT2Xw?= =?us-ascii?Q?w352ENn92qxddALhqKe89F2eB/tLrEWnEbPdTc+rRXro4MTNh5MgyKHx7Fkc?= =?us-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 1;BN6PR15MB1635;6:wnV06/jpKjNHSube0i18prWEZ6BvoGiymFLhGriRBIVhegzws8zEfq61St6DygTRuaanHwMpp1Lq+d4OkdcHFvIhAGBMQxS5KRJxFZvAtaIWHAR/wzZGr1OUXHkdG4KqAeCgrQY610MEnnwj6e9Q8RMdmWqV3NXtuZzfGd17/aWviUUyOZO47lKOB3zFa6uq4FnuvPU3xPxQRRtUWQov5L0eIjnbIGcCFaB5o7nFZ/sT+YafG1Zm8XpjiLqePymFG8CaRWPneM2QC/JtQBj+8kTGqjcG8AEGMep4JHqrqIgorl/XTSFePN4xGxqWfOKEtY4+YdjAtVE4Lw8visiI9jShgyBz27qxEAej9N6g6LkAQW0ZOIpf8I0IjllYohIEibUMurhZ2I81ogqUD4aGmQ==;5:GaIeWgFvQSqS7i1hXwMNCymW/ZNSkX+62O4o9cIso4t5pEYUuemyuaK95Ia+ieUh4cTGF6vjeyFFfaALMtHjUF0L+RJ2AF5+jeRoTfEeYbgObirloGW/hneYlc+p3MhxG9j6U7R7q3F9nZiS8u+TOg==;24:VT/U3VsTNySJ+qo6aBAsCjG9/kO5qJZolCoI8jvUhC4makYo9G8NEfLzYv/xs4MAl9kOfjMI/CSReA3A1BtVKL0lCRGkSvyFs69Rv2ckjH8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR15MB1635;7:pVei73A2bCJ/RunPrea+odPCPQRiNlSzAsn/hqMXrTh3lj6yj4K1bssYIweyMcIXpjvHFqWaTgE3FxRpKBzS4buYb4lKyZ89hc1ivDbk7eFhlTRnMnjotESwpaodV8vGvAVieXavbNVF7LDJGdf5reIbbz/T+liwLfXItPwEntdRIesJ+2styosLc/YOjjhSmATM3gLwApFF7andgSOlnUsiuVS1tOimGbznl8b/5V9ChMGbvfVBnLxcYOszVswHUEsgKqrXsaMqN3HRAHVuzn8NGUNqYtjCB9vvDRxr2OfsPOe3uQ69/irZbh0VZ+yAvFbSMURFU3C8BN+NhkXEpg==;20:Rv4mSbPRueKhK0qIDdU0RZjB6tJjsXYARceM30hYLkbIU1DwD2pZUKPKS3alkUxub9c7aDEXamegEuDfbG21TcfSDmao1BfGCLyjzbZ+CA7JI5mAhPdeBNQxVNfDAZVBKpzs0HxPF0EmqP19l7DDZJeMm3klqKE3CrkzxkG70VU= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 16:02:36.6342 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1635 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-03_12:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5514 Lines: 142 On Fri, Mar 03, 2017 at 11:52:37AM +0900, Minchan Kim wrote: > Hi, > > On Tue, Feb 28, 2017 at 04:32:38PM -0800, akpm@linux-foundation.org wrote: > > > > The patch titled > > Subject: mm: reclaim MADV_FREE pages > > has been added to the -mm tree. Its filename is > > mm-reclaim-madv_free-pages.patch > > > > This patch should soon appear at > > https://urldefense.proofpoint.com/v2/url?u=http-3A__ozlabs.org_-7Eakpm_mmots_broken-2Dout_mm-2Dreclaim-2Dmadv-5Ffree-2Dpages.patch&d=DwIBAg&c=5VD0RTtNlTh3ycd41b3MUw&r=X13hAPkxmvBro1Ug8vcKHw&m=oMKTke-r00qQPnpEwo0Cn43po669gckvribhR9LQWf0&s=wzX_7IDavzBkFEMl7HDTMwrFXo1skB35mu0CjZmfFOg&e= > > and later at > > https://urldefense.proofpoint.com/v2/url?u=http-3A__ozlabs.org_-7Eakpm_mmotm_broken-2Dout_mm-2Dreclaim-2Dmadv-5Ffree-2Dpages.patch&d=DwIBAg&c=5VD0RTtNlTh3ycd41b3MUw&r=X13hAPkxmvBro1Ug8vcKHw&m=oMKTke-r00qQPnpEwo0Cn43po669gckvribhR9LQWf0&s=eUYtR1qeasKBGvuNWsZP6jE4XwoKwMb4CdKQU7OXGYM&e= > > > > Before you just go and hit "reply", please: > > a) Consider who else should be cc'ed > > b) Prefer to cc a suitable mailing list as well > > c) Ideally: find the original patch on the mailing list and do a > > reply-to-all to that, adding suitable additional cc's > > > > *** Remember to use Documentation/SubmitChecklist when testing your code *** > > > > The -mm tree is included into linux-next and is updated > > there every 3-4 working days > > > > ------------------------------------------------------ > > From: Shaohua Li > > Subject: mm: reclaim MADV_FREE pages > > > > When memory pressure is high, we free MADV_FREE pages. If the pages are > > not dirty in pte, the pages could be freed immediately. Otherwise we > > can't reclaim them. We put the pages back to anonumous LRU list (by > > setting SwapBacked flag) and the pages will be reclaimed in normal swapout > > way. > > > > We use normal page reclaim policy. Since MADV_FREE pages are put into > > inactive file list, such pages and inactive file pages are reclaimed > > according to their age. This is expected, because we don't want to > > reclaim too many MADV_FREE pages before used once pages. > > > > Based on Minchan's original patch > > > > Link: http://lkml.kernel.org/r/14b8eb1d3f6bf6cc492833f183ac8c304e560484.1487965799.git.shli@fb.com > > Signed-off-by: Shaohua Li > > Acked-by: Minchan Kim > > Acked-by: Michal Hocko > > Acked-by: Johannes Weiner > > Acked-by: Hillf Danton > > Cc: Hugh Dickins > > Cc: Rik van Riel > > Cc: Mel Gorman > > Signed-off-by: Andrew Morton > > --- > > < snip > > > > @@ -1419,11 +1413,21 @@ static int try_to_unmap_one(struct page > > VM_BUG_ON_PAGE(!PageSwapCache(page) && PageSwapBacked(page), > > page); > > > > - if (!PageDirty(page)) { > > + /* > > + * swapin page could be clean, it has data stored in > > + * swap. We can't silently discard it without setting > > + * swap entry in the page table. > > + */ > > + if (!PageDirty(page) && !PageSwapCache(page)) { > > /* It's a freeable page by MADV_FREE */ > > dec_mm_counter(mm, MM_ANONPAGES); > > - rp->lazyfreed++; > > goto discard; > > + } else if (!PageSwapBacked(page)) { > > + /* dirty MADV_FREE page */ > > + set_pte_at(mm, address, pvmw.pte, pteval); > > + ret = SWAP_DIRTY; > > + page_vma_mapped_walk_done(&pvmw); > > + break; > > } > > There is no point to make this logic complicated with clean swapin-page. > > Andrew, > Could you fold below patch into the mm-reclaim-madv_free-pages.patch > if others are not against? > > Thanks. > > From 0c28f6560fbc4e65da4f4a8cc4664ab9f7b11cf3 Mon Sep 17 00:00:00 2001 > From: Minchan Kim > Date: Fri, 3 Mar 2017 11:42:52 +0900 > Subject: [PATCH] mm: clean up lazyfree page handling > > We can make it simple to understand without need to be aware of > clean-swapin page. > This patch just clean up lazyfree page handling in try_to_unmap_one. Looks good, thanks! Reviewed-by: Shaohua Li > Signed-off-by: Minchan Kim > --- > mm/rmap.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index bb45712..f7eab40 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1413,17 +1413,17 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, > VM_BUG_ON_PAGE(!PageSwapCache(page) && PageSwapBacked(page), > page); > > - /* > - * swapin page could be clean, it has data stored in > - * swap. We can't silently discard it without setting > - * swap entry in the page table. > - */ > - if (!PageDirty(page) && !PageSwapCache(page)) { > - /* It's a freeable page by MADV_FREE */ > - dec_mm_counter(mm, MM_ANONPAGES); > - goto discard; > - } else if (!PageSwapBacked(page)) { > - /* dirty MADV_FREE page */ > + /* MADV_FREE page check */ > + if (!PageSwapBacked(page)) { > + if (!PageDirty(page)) { > + dec_mm_counter(mm, MM_ANONPAGES); > + goto discard; > + } > + > + /* > + * If the page was redirtied, it cannot be > + * discarded. Remap the page to page table. > + */ > set_pte_at(mm, address, pvmw.pte, pteval); > ret = SWAP_DIRTY; > page_vma_mapped_walk_done(&pvmw); > -- > 2.7.4 >