Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1E4BC11F66 for ; Tue, 13 Jul 2021 09:30:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0950E6120A for ; Tue, 13 Jul 2021 09:30:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0950E6120A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DC0A76B008C; Tue, 13 Jul 2021 05:30:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D49B66B0095; Tue, 13 Jul 2021 05:30:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC2EF6B0096; Tue, 13 Jul 2021 05:30:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 91D966B008C for ; Tue, 13 Jul 2021 05:30:09 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 95ECA82AEF1C for ; Tue, 13 Jul 2021 09:30:08 +0000 (UTC) X-FDA: 78357043296.08.954272B Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf17.hostedemail.com (Postfix) with ESMTP id 1A617F0003A5 for ; Tue, 13 Jul 2021 09:30:07 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C7CCC2007E; Tue, 13 Jul 2021 09:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1626168606; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JcCPjDcrvfzpmzaVzS7nNSr2ItgjCbZj3DsU2BMBR/E=; b=a3jdJE7sy8Ewp0X+SdC/k03tAwBJsCPyelubwU2+vA+YxTWuDWROkohFZ3JvBVivUgabr5 l+BPrZglKPsK3AH3rzuKqbjCE/oQz0vEjyQMKA1IGluU9QimBfpWCAB60WyT2zB7mJbZtB MCAGswAVEraxGxhOcFa6mIHyBfmrP94= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 305EEA3B8C; Tue, 13 Jul 2021 09:30:03 +0000 (UTC) Date: Tue, 13 Jul 2021 11:30:02 +0200 From: Michal Hocko To: Miaohe Lin Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, vbabka@suse.cz, axboe@kernel.dk, iamjoonsoo.kim@lge.com, alexs@kernel.org, apopple@nvidia.com, willy@infradead.org, minchan@kernel.org, david@redhat.com, shli@fb.com, hillf.zj@alibaba-inc.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] mm/vmscan: put the redirtied MADV_FREE pages back to anonymous LRU list Message-ID: References: <20210710100329.49174-1-linmiaohe@huawei.com> <20210710100329.49174-2-linmiaohe@huawei.com> <9409189e-44f7-2608-68af-851629b6d453@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9409189e-44f7-2608-68af-851629b6d453@huawei.com> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1A617F0003A5 X-Stat-Signature: rehy99g9a9t5w8mf78bbm5as1uwdjw3g Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=a3jdJE7s; spf=pass (imf17.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-HE-Tag: 1626168607-675469 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 12-07-21 19:03:39, Miaohe Lin wrote: > On 2021/7/12 15:22, Michal Hocko wrote: > > On Sat 10-07-21 18:03:25, Miaohe Lin wrote: > >> If the MADV_FREE pages are redirtied before they could be reclaimed, put > >> the pages back to anonymous LRU list by setting SwapBacked flag and the > >> pages will be reclaimed in normal swapout way. Otherwise MADV_FREE pages > >> won't be reclaimed as expected. > > > > Could you describe problem which you are trying to address? What does it > > mean that pages won't be reclaimed as expected? > > > > In fact, this is not a bug and harmless. Fixes tag is then misleading and the changelog should be more clear about this as well. > But it looks buggy as it didn't perform > the expected ops from code view. Lazyfree (MADV_FREE) pages are clean anonymous > pages. They have SwapBacked flag cleared to distinguish normal anonymous pages. yes. > When the MADV_FREE pages are redirtied before they could be reclaimed, the pages > should be put back to anonymous LRU list by setting SwapBacked flag, thus the > pages will be reclaimed in normal swapout way. Agreed. But the question is why this needs an explicit handling here when we already do handle this case when trying to unmap the page. Please make sure to document the behavior you are observing, why it is not desirable. > Many thanks for review and reply. > > > Also why is SetPageSwapBacked in shrink_page_list insufficient? Sorry I meant to say try_to_unmap path here > >> Fixes: 802a3a92ad7a ("mm: reclaim MADV_FREE pages") > >> Signed-off-by: Miaohe Lin > >> --- > >> mm/vmscan.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/mm/vmscan.c b/mm/vmscan.c > >> index a7602f71ec04..6483fe0e2065 100644 > >> --- a/mm/vmscan.c > >> +++ b/mm/vmscan.c > >> @@ -1628,6 +1628,7 @@ static unsigned int shrink_page_list(struct list_head *page_list, > >> if (!page_ref_freeze(page, 1)) > >> goto keep_locked; > >> if (PageDirty(page)) { > >> + SetPageSwapBacked(page); > >> page_ref_unfreeze(page, 1); > >> goto keep_locked; > >> } > >> -- > >> 2.23.0 > > -- Michal Hocko SUSE Labs