Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2400999ybh; Mon, 9 Mar 2020 05:14:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtjD892F11XLb7505SelIXLvrcZrScgCKY3U19lTHdKt0dcrT4PRBq7RLAIf+HFo1RABgeq X-Received: by 2002:a05:6830:1de3:: with SMTP id b3mr9059021otj.133.1583756048488; Mon, 09 Mar 2020 05:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583756048; cv=none; d=google.com; s=arc-20160816; b=zasFN0oebFwQQF50yPNTgER9GoRUL26Yy/RIPPh3JnOk+OpcA0YeToCDjmD6fKuFar FkbMK6h1hNKy/ojTWNSDs/TuGlkU8YK6ZKtmg/hmnfa00MXyOvTnegPuDHvuxNrRgEWE wXnqVTyzrHNa8enKEq4RMuRAPB0tnLzzNEqqGNx+je1Ltp9blbiCgvgZotahwkA5DYT2 n822gEAaADg9u+YeKM3qk0MC/om35Oo+wnDFUWx8FrKZUyx/hgMZ/GjWxoHc3lZUB/Iu dcffhLCSY9RAiswCkp1nerVCLYCT4Kd0B9tA3krEOcziP0/UmRKOo5shbHMSWho6Tlhc td8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=R/AnVazJT1to75hAodEIbyCnLvch4wjuOplZ+LEerA4=; b=Q64cdu93b571cD/elqLgi2JIV221iFmEc8mcNJin75S9nBeN5nezNXRAt14qrWpdgk ibazJ79pd3rO0EyrjUObLIkHKnfYwUc2hxjxx5UQJKMZ+z2p+BrW74KAQsndYzVeBPwV JDuKnKuAO07aqwFnUPNRqFSAxzl3j+Y69sqk80rVkTHHclZt+G1xAjfqmBByNz7hyLH7 uHMjnNmGNBzQzyw0ZtQmtHNZTe1hkedX6CP+53DI0ZH2cLIoXJNyCfwpYMocpKtkIk2T p4oki/X6TpmMIuGyt9SSYY1uswREm20fiRdbJ6xhBLS7f8ip5XTd6B6siI8Ort1B0Vgp VLLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si6273538otr.27.2020.03.09.05.13.56; Mon, 09 Mar 2020 05:14:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbgCIMND (ORCPT + 99 others); Mon, 9 Mar 2020 08:13:03 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41492 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbgCIMND (ORCPT ); Mon, 9 Mar 2020 08:13:03 -0400 Received: by mail-wr1-f65.google.com with SMTP id v4so10783231wrs.8 for ; Mon, 09 Mar 2020 05:13:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=R/AnVazJT1to75hAodEIbyCnLvch4wjuOplZ+LEerA4=; b=ht449RXlmZD7/HyUc9LXYztokupP7KLhPqMQt7M9nVprdvpe5T0Zqfcvv1osNYmPRT Tlpr9Gu6pulAXJcljTKoJGT3CsXji4Jf+QiDnqfcwnHa1JzGvNoydtXkF3aKsZNNLP4P MUhbLVMOJ08sf7GGk+v/BVW8m/1uzs86vm4wzDLG/x+qUX04rQRiv1Vf5gs1WihhbGc7 79cF8J+wgjrUaJux1c6FVTTRcJPSgMYQFpjre77phcTfgqe3Mq5saQr18A7CljTADS7Y xr0FgM+jQPxbHVlMwxfgKjoQIfoLfFxZpu7PumnNlTFFmjD09xxoffkgZLZ+hM6os1w7 0ILg== X-Gm-Message-State: ANhLgQ1LYqrTGBILbR0WEMhPX8Kc2MeckEPbpJs5YAVzhVRHYkqNXjy2 wqCjSFeDHGJqa9riX1RYip0= X-Received: by 2002:adf:a2d9:: with SMTP id t25mr20488116wra.84.1583755981843; Mon, 09 Mar 2020 05:13:01 -0700 (PDT) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id j205sm25147878wma.42.2020.03.09.05.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 05:13:01 -0700 (PDT) Date: Mon, 9 Mar 2020 13:13:00 +0100 From: Michal Hocko To: David Hildenbrand Cc: "Huang, Ying" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Mel Gorman , Vlastimil Babka , Zi Yan , Peter Zijlstra , Minchan Kim , Johannes Weiner , Hugh Dickins Subject: Re: [PATCH -V3] mm: Add PageLayzyFree() helper functions for MADV_FREE Message-ID: <20200309121300.GL8447@dhcp22.suse.cz> References: <20200309021744.1309482-1-ying.huang@intel.com> <68360241-eb18-b3d8-bf6f-4dbbed258ee6@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <68360241-eb18-b3d8-bf6f-4dbbed258ee6@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 09-03-20 09:55:38, David Hildenbrand wrote: > On 09.03.20 03:17, Huang, Ying wrote: [...] > > @@ -1235,7 +1234,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, > > * Try to allocate it some swap space here. > > * Lazyfree page could be freed directly > > */ > > - if (PageAnon(page) && PageSwapBacked(page)) { > > + if (PageAnon(page) && !__PageLazyFree(page)) { > > if (!PageSwapCache(page)) { > > if (!(sc->gfp_mask & __GFP_IO)) > > goto keep_locked; > > @@ -1411,7 +1410,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, > > } > > } > > > > - if (PageAnon(page) && !PageSwapBacked(page)) { > > + if (PageLazyFree(page)) { > > /* follow __remove_mapping for reference */ > > if (!page_ref_freeze(page, 1)) > > goto keep_locked; > > > > I still prefer something like > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > index fd6d4670ccc3..7538501230bd 100644 > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -63,6 +63,10 @@ > * page_waitqueue(page) is a wait queue of all tasks waiting for the page > * to become unlocked. > * > + * PG_swapbacked used with anonymous pages (PageAnon()) indicates that a > + * page is backed by swap. Anonymous pages without PG_swapbacked are > + * pages that can be lazily freed (e.g., MADV_FREE) on demand. > + * > * PG_uptodate tells whether the page's contents is valid. When a read > * completes, the page becomes uptodate, unless a disk I/O error happened. > * > > and really don't like the use of !__PageLazyFree() instead of PageSwapBacked(). I have to say that I do not have a strong opinion about helper functions. In general I tend to be against adding them unless there is a very good reason for them. This particular patch is in a gray zone a bit. There are few places which are easier to follow but others sound like, we have a hammer let's use it. E.g. shrink_page_list path above. There is a clear comment explaining PageAnon && PageSwapBacked check being LazyFree related but do I have to know that this is LazyFree path? I believe that seeing PageSwapBacked has a more meaning to me because it tells me that anonymous pages without a backing store doesn't really need swap entry. This happens to be Lazy free related today but with a heavy overloading of our flags this might differ in the future. You have effectively made a more generic description more specific without a very good reason. On the other hand having PG_swapbacked description in page-flags.h above gives a very useful information which was previously hidden at the definition so this is a clear improvement. That being said I think that the patch is not helpful enough. I would much rather see a simply documentation update. -- Michal Hocko SUSE Labs