Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3990138ybf; Tue, 3 Mar 2020 17:22:23 -0800 (PST) X-Google-Smtp-Source: ADFU+vtdzsQj5YF0dyULx9fRKvSUBaCIMblZbvx+Jzzjoigu4nqOQAGshOvrFJZpB28mk5UR8zkh X-Received: by 2002:aca:b187:: with SMTP id a129mr189293oif.175.1583284943788; Tue, 03 Mar 2020 17:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583284943; cv=none; d=google.com; s=arc-20160816; b=VmYI1vyab2/EbZgM1xw1Oqz7y4P3sAmm9UQJyKYkXIWEUrPQjQn7kmfRfNNoiYu47J ajV7nKeYvNBc5S2JZ/2Z93aMZW6z9PQmcjIVi1eonjYQKkQvqH/YG7cYKPP21a/u0WuB SgntC62iPHschLwKh74O0Q/x1THALRY8MvrQEhPT9v5129mN1lPyXQlihJ+dqL5+XNQx O/o87neVEVN+XlEpOPdTTjCgCxem33ccdimppV77Kbnt4PczcEFGN+xfktqtZAHfiEbm drqHdLkBeDfdwZn365zxQQB9qB/eoScCAI7DpZYm/KSmqMyoYulBlUb/pc0bfKmxfcQS KfVQ== 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:message-id :in-reply-to:date:references:subject:cc:to:from; bh=SS4tnVtA4TElD6P5/ZG7JplK55m6k6MGchDzWuw9hxo=; b=xN8XJkuEtoXll/CAD0gWC3HBXjRuXnJLuZxNnyGy62cS9LPGJNyemAzBuTj6SR7sYK FTVReB5LVjWZ6c3IadSrDkGIqpa9L7g3RlpP/04azcyhybBYma1mmwyg6qrlVpRWVp4g CMQqrGxAejuYxf2cm7/rWtPlVFpCnvSX6G055mTdi8QwGOkhnzO9Z0nG+g8d5rEEPmM0 HQccBjZfDTR38QoPdpDPUIV+Lqd+7SMPxRLOzSSYVZ6977XyLtrOyRBOZAhl8p3QP6dx 9E6TtQNHniVn95cePQgLvc8dY8aUpxdL/E7RJD7jatuEwMZLQDoqbvXfMXGpndOdGLaA vipg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si183114oto.221.2020.03.03.17.22.11; Tue, 03 Mar 2020 17:22:23 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387402AbgCDBUz (ORCPT + 99 others); Tue, 3 Mar 2020 20:20:55 -0500 Received: from mga03.intel.com ([134.134.136.65]:50660 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbgCDBUz (ORCPT ); Tue, 3 Mar 2020 20:20:55 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2020 17:20:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,511,1574150400"; d="scan'208";a="287177752" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by FMSMGA003.fm.intel.com with ESMTP; 03 Mar 2020 17:20:51 -0800 From: "Huang\, Ying" To: Andrew Morton Cc: , , 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 References: <20200303033738.281908-1-ying.huang@intel.com> <20200303165859.7440f23d388503ca77fdb6c2@linux-foundation.org> Date: Wed, 04 Mar 2020 09:20:51 +0800 In-Reply-To: <20200303165859.7440f23d388503ca77fdb6c2@linux-foundation.org> (Andrew Morton's message of "Tue, 3 Mar 2020 16:58:59 -0800") Message-ID: <87o8tc3ogc.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Andrew, Andrew Morton writes: > 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. > > And they aren't free! > > before: > > q:/usr/src/25> size -t mm/rmap.o mm/swap.o mm/vmscan.o > text data bss dec hex filename > 41580 4211 192 45983 b39f mm/rmap.o > 50684 9259 1184 61127 eec7 mm/swap.o > 117728 46775 128 164631 28317 mm/vmscan.o > 209992 60245 1504 271741 4257d (TOTALS) > > after: > > text data bss dec hex filename > 42035 4299 192 46526 b5be mm/rmap.o > 51091 9347 1184 61622 f0b6 mm/swap.o > 118132 46775 128 165035 284ab mm/vmscan.o > 211258 60421 1504 273183 42b1f (TOTALS) > > ALso, if they actually trigger, Linus goes berserk. > > If you have some special reason to add these assertions, please do it > as a (changelogged!) followup patch and I'll keep it as a linux-next only thing. Sorry, originally I thought that VM_BUG_ON_PAGE() will not be used in the production kernel, so it's cheap. But it seems that people do care about its usage. I will send v2 to fix this. Best Regards, Huang, Ying