Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3736973pxv; Tue, 13 Jul 2021 02:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0GBzA9/mwcIIzHWyuvE7UfcPn8DUnxGa4xzz7nWTzq8/R5uagzMFuJp90W/ur0sOM7Onl X-Received: by 2002:a5d:8b03:: with SMTP id k3mr2487376ion.203.1626168706520; Tue, 13 Jul 2021 02:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626168706; cv=none; d=google.com; s=arc-20160816; b=ug1vBbB9J2awCCUufpvbv4NIcNztQ4TFlR9TTC5dZs5zRw1Ll5LaAfm51Oq86f6sH+ pCd/VHZxs61Z+Y6hiPxJAfjUaDOk4rBML+PQAEOV3J22L6f3qx5B34dGUe4srAiU+c1z tOoX5aX+mwdqyW1Ybw310lMi1/+9n004NU7weKWDkPESHaKdHYNbmASfgUTUzOAEPnrI 2qKidd6w7dESqkR5Lv3HArRdvKBWdJJeC9grfWGKwFiYkJrilzAA3bq4ZoJ+ZC64AZzf HxsFiclbYWlLpGNEcFSOlDdFJbwYMa+qupPrVr5D+mVmz3DYD6lriDKVnfV6w8oWJxN9 UxQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JcCPjDcrvfzpmzaVzS7nNSr2ItgjCbZj3DsU2BMBR/E=; b=gysZzPbnB5zBZVUN695lJJvaXrmJ0nrdHKVuNaKwlQwGZKfeF5K7qU84xP8qZSafIl sN7crMSvNiMSYCXDFOO9mz2yG1psF6wfG5Kpptd/KezKJwP8vSlyW/BHC8pvzx2mjlkb ZEvqMBN/SEmcMK27wCS1PnOHG0chDTMZTiFiL/+f9Xg+8an/p6nS4JHzcIZMB+55mvjd mCSP4yth7cWyiEJ2PwdhOAgOA0oYdJe4cT3WRDrlthn7kONYJXv05W1wtmr4ldMB/orn coUdl1GIoehZSGpx2j8OG4xI3LEDX7/2CWzmnOjwF/ZYhr79lKnoSc5CsQhl9s0+v600 O4rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=a3jdJE7s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si6496284ilk.49.2021.07.13.02.31.33; Tue, 13 Jul 2021 02:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=a3jdJE7s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235302AbhGMJc7 (ORCPT + 99 others); Tue, 13 Jul 2021 05:32:59 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:43046 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235282AbhGMJc5 (ORCPT ); Tue, 13 Jul 2021 05:32:57 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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