Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3994086ybf; Tue, 3 Mar 2020 17:27:45 -0800 (PST) X-Google-Smtp-Source: ADFU+vsphYtfihucTQG4m31nrHrGxCUsX10+t71kCncrt0ZlzMFxzd/rgTF6EK8q60nv0OArqpSo X-Received: by 2002:aca:b02:: with SMTP id 2mr203922oil.25.1583285265538; Tue, 03 Mar 2020 17:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583285265; cv=none; d=google.com; s=arc-20160816; b=UmOlN/GtvhDAvkeiWNEFUbp2d0D0T1DrC9QuOOYSipzmp2x0cPwZTe6tkMMnMTHhr0 PxaBnyjc2Bkxh7bRGX93PeTWrXzFYwQcZ5Pd7jJAS5V7cUHBM5SYqcspQdv6CaBSKBVp MjxtGkE8iOV6Ov3+BolM4uJg50GmRJ5GmXT2HzuZ68XnhJQB9Xmm7r8Sv/fOGd9VgqUM /A2gi1LZvA40fcWa2RF+zqvBoC3H9IPTtoUgbDngJaHX6acglfSJZeGg4sbqiMpdwfvc QIBVemcNMfEHhsJX6IhTQiLQ4uXFu9t+LbCF4xzJnr6O6l/hZ3PIC5YrBwJHzd+IkXLT Cg4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=7j1JY1w6KY3dIJ58LiQwYJdhyGzQgFJSnbbwSZ5yqSA=; b=o2OufzdpFBxVWYNRottewlcGmW1WFIe7ejL1jfQewmRXXpqnYfmAmQ40OQnijgcNuD o00pD7/teaGRvddnYrWomNRNAGylpQbEUEa3ese7h6vaEfO2W2tCJk3Me5w+6zCn8lhr ufr4S7AThGEUlwC8m5KwfOJriURHK2D/cDEnzHVZtblmkleDFQwdH00h1BonlMo3zxUv yATYiEP6Ig5GziApWkiE8ZayQavOjGpWMyEl7MHL4EnJ2JY8t7g+WEhiYXzSRp2ozzza z1DIHvvR/wHpXr8OwTJAbP8mFCOt+hneuhLYXsUIiwHjy0Q4H/QZHCznTplttmK/wNkU mbNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OgANEZL1; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si192482otq.194.2020.03.03.17.27.33; Tue, 03 Mar 2020 17:27:45 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=OgANEZL1; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387502AbgCDB1I (ORCPT + 99 others); Tue, 3 Mar 2020 20:27:08 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43765 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387398AbgCDB1H (ORCPT ); Tue, 3 Mar 2020 20:27:07 -0500 Received: by mail-pl1-f196.google.com with SMTP id x17so238050plm.10 for ; Tue, 03 Mar 2020 17:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=7j1JY1w6KY3dIJ58LiQwYJdhyGzQgFJSnbbwSZ5yqSA=; b=OgANEZL1C13kZ2ZvZHUkXeJc1JPQuFIyEno7NDIjvhkPUtiM/TWxgwb6N3dKz9D5pG +8pVMlMcuIH/5q/sRDWZKsIanU3M4ZF9HwukOAli+C4cJXzkGbWKXjJ130jQEuWKrtPj W8VRtisrdg6LnTk9Pzc7VGCa0EbxHdtWq4gGeJeuEJ20SnXNf3AXjHxlsrf4APrqeRTl PtLJ0XRk38J2Z4KeBB6L+9Ic7Q3kEdGeZU/EgjwzPKZc3j/eGKV+9ZkRr8Pew3+RfyL3 31O+q/0C+XlUbTSDs5Elcx0XlkkKFY7tzUjliMAZKCM/JpUAQL4JYeh2w8KZv/xmlRlA PzTw== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=7j1JY1w6KY3dIJ58LiQwYJdhyGzQgFJSnbbwSZ5yqSA=; b=WNLfLFFvB/rE7UTk4vGGRa0pq2kNAsYNtYb1QCmBDJGxoD65wZbLvQyuKB113QYzis LLkDBj5GISxJUgLAb25D4ay0k6HNaNXHh/Z37k+TBK1GfL1jCOZXrz0BOHF/7+7FbNRM YYVGNHQSIhXYcPRrCjCcsu9SsnGQROQScWR6W+FGyUrH9cGDoM1rGz2PF60J1JLB5wZZ 0XMoHCzUg8yHBfUpmDXiLO2FCdEimMr5AWeWiM/0bYoK1HXUL5bfJl1iC5eRdRtwtqbE l4sI/SNHZO7Yyi4PyK/1dYFCQA9giDMOdsAri3PEkjnrFfhqLZi0xW2ZkKj+Zh6sWPPt 20oA== X-Gm-Message-State: ANhLgQ3nbLVripGljoN4fIyDyH8ZokjzhwplhhEctCOA3nxywH1hZ2o0 6oXHglwx3ATiqXQw3AUGrAT/OA== X-Received: by 2002:a17:902:341:: with SMTP id 59mr720350pld.29.1583285226487; Tue, 03 Mar 2020 17:27:06 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id r13sm25824743pgf.1.2020.03.03.17.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 17:27:05 -0800 (PST) Date: Tue, 3 Mar 2020 17:27:05 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: "Huang, Ying" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , David Hildenbrand , Mel Gorman , Vlastimil Babka , Zi Yan , Michal Hocko , Peter Zijlstra , Minchan Kim , Johannes Weiner , Hugh Dickins Subject: Re: [PATCH] mm: Add PageLayzyFree() helper functions for MADV_FREE In-Reply-To: <20200303165859.7440f23d388503ca77fdb6c2@linux-foundation.org> Message-ID: References: <20200303033738.281908-1-ying.huang@intel.com> <20200303165859.7440f23d388503ca77fdb6c2@linux-foundation.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Mar 2020, Andrew Morton wrote: > On Tue, 3 Mar 2020 11:37:38 +0800 "Huang, Ying" wrote: > > > From: Huang Ying > > > > Now PageSwapBacked() is used as the helper function to check whether > > pages have been freed lazily via MADV_FREE. This isn't very obvious. > > So Dave suggested to add PageLazyFree() family helper functions to > > improve the code readability. > > > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -498,6 +498,31 @@ static __always_inline int PageKsm(struct page *page) > > TESTPAGEFLAG_FALSE(Ksm) > > #endif > > > > +/* > > + * For pages freed lazily via MADV_FREE. lazyfree pages are clean > > + * anonymous pages. They have SwapBacked flag cleared to distinguish > > + * with normal anonymous pages > > + */ > > +static __always_inline int PageLazyFree(struct page *page) > > +{ > > + page = compound_head(page); > > + return PageAnon(page) && !PageSwapBacked(page); > > +} > > + > > +static __always_inline void SetPageLazyFree(struct page *page) > > +{ > > + VM_BUG_ON_PAGE(PageTail(page), page); > > + VM_BUG_ON_PAGE(!PageAnon(page), page); > > + ClearPageSwapBacked(page); > > +} > > + > > +static __always_inline void ClearPageLazyFree(struct page *page) > > +{ > > + VM_BUG_ON_PAGE(PageTail(page), page); > > + VM_BUG_ON_PAGE(!PageAnon(page), page); > > + SetPageSwapBacked(page); > > +} > > These BUG_ONs aren't present in the current code and are > unchangelogged. > Yeah, as well as the implicit conversion to check compound_head().