From mboxrd@z Thu Jan 1 00:00:00 1970 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=-4.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 74B9CC10F27 for ; Mon, 9 Mar 2020 12:13:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F4D0205ED for ; Mon, 9 Mar 2020 12:13:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F4D0205ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ADB766B0003; Mon, 9 Mar 2020 08:13:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8A4C6B0006; Mon, 9 Mar 2020 08:13:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9788E6B0007; Mon, 9 Mar 2020 08:13:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 7A6E46B0003 for ; Mon, 9 Mar 2020 08:13:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2AC648248047 for ; Mon, 9 Mar 2020 12:13:03 +0000 (UTC) X-FDA: 76575713046.26.goose12_8f09321577d3a X-HE-Tag: goose12_8f09321577d3a X-Filterd-Recvd-Size: 5548 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Mar 2020 12:13:02 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id p2so9967683wrw.7 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=GbfmVg7Rpc8WHWZWnw0vsejJcVr01duEignpJ21YvDwt6bVzoFJ1YyMqMKSsKBNhuV VjIi/Hqc6Jc0Zi4ASuDZkgHlbnrViXZJAH5EuQCbuvxr+04iGCxAg8ml0kRgOTajZYNN aDACXpMGrdq5QLT/Km+VeqSpd/c/6R+NIMFbna8atP737t40ibMg0vu/ouGXs0mPr562 Mn+BUE4cfnW6QR0bYc9iHlxMZWlgyapX4XXDT4Ld3Pr34Vbny5YphZ7a9kDWz40FXp7/ 6mVkl8LnqHHoghjx+QRj0UUMelyNNTsnpADxszNA7n62Py8ORq8HHS9ADuF794W9K/eI K1Ew== X-Gm-Message-State: ANhLgQ11wtKfAt2XpdjfdKmpxS6wTzSyv6veQ5FQzPW80/Aj0LxehOtD I4bajIQczcyw24JDWxP8udleuYbG X-Google-Smtp-Source: ADFU+vvEt/BD9szUjhMRtS2lUukGoSi4Lw3Gceek5PIb+EfOLdKzhiRXkB0oMfhypj8LsYWD0UjW+Q== 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> 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 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