Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3970707ybf; Tue, 3 Mar 2020 16:59:50 -0800 (PST) X-Google-Smtp-Source: ADFU+vsIzl6Nix5qtZ/JZFF0ejzaMw4AAc9SoOqMJ6BCPFgCWK6+O9EBKDsO/uIvS2tJS39yAeKV X-Received: by 2002:a9d:6050:: with SMTP id v16mr486198otj.151.1583283590040; Tue, 03 Mar 2020 16:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583283590; cv=none; d=google.com; s=arc-20160816; b=tBan5sF/dVp1E1XoslFsvBtE8VTH91P9buZusLAc1+T6Tp6pYgsoNJZfDjzPOuKv2+ V6Z7OwmCPX1h9RYsBWDg54CZV9up0xh47exjtveffI+8J8zcYTEetfM45NfGSdlIzNy8 sWDb1N9yWpN93NCQ7Ptw3hVcd77HqhTRT6p3D5OfH+vITrV3NQWKjUG3R9N1ZGpers5m 3dq/UVDLKpi/8gaPfyBcWOr3tPugS2dIgHIYKyJWd+m+mncPOMzgycNL/1uPNyRoBPhT zak42GEV3wedhcJmM8BTTrhWloHEGR0R9nrCeGc1obKfwzb0GBLitTyotIHLqadzGGXu oteg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9Jp3FlGBrQl0iJDNReyGqfrTGcMnoc09j7E4K1AG85k=; b=u5vwbHGoYFawyO3/sse7g4gGER1LMg8mpQPFO2EMeT1zjdcazIQQE0vGlRre59duFQ EkTI27mt3FUqsbXn2QP01t4T9V4pAIKfVoRhY3hAU9QQRayj7tX5S/ilf+NCm4YQntCC r6XSMyMDPOAckoxb5Hx1nhYfFdpYo4N/74H+975NGyr28OEBLLhT2DtZ2y78Lf8Ucltb 50mTO33gU6TLnyaLrx6ZMb1AqtQElKb+401A5B3PPpWC1yjJUxQ1AlflpfO0H4BcOAIK uZqQaNzCg1B4wweT2JfbKKYk+Kn/wz5k4FRtaEWjpE9QadceunP6eyIw8RakIUevVdGX uoyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cIEzDdbb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si178146oto.55.2020.03.03.16.59.37; Tue, 03 Mar 2020 16:59:50 -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=@kernel.org header.s=default header.b=cIEzDdbb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbgCDA7B (ORCPT + 99 others); Tue, 3 Mar 2020 19:59:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:56796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbgCDA7A (ORCPT ); Tue, 3 Mar 2020 19:59:00 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1BD420728; Wed, 4 Mar 2020 00:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583283540; bh=pBkv+zMpJnUHutM5TIKA7m+caWpqu0XAtFt3DpoXfP4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cIEzDdbbbEFjL4w0k0SH481f3kjJzoI3WEPvR42mCswUUfFd22+Q3oxT2d7i4u2YK mHchKcRaDuxTpV1oOGOBRAy5BKCrCuh4tF3L34FLQCUdwYV4k9MmoGZuJ+m0HbZ1IF DaewpvraIeBODt7TnfBWu/LovTJHb/g8NCkSLNxo= Date: Tue, 3 Mar 2020 16:58:59 -0800 From: Andrew Morton To: "Huang, Ying" Cc: 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 Message-Id: <20200303165859.7440f23d388503ca77fdb6c2@linux-foundation.org> In-Reply-To: <20200303033738.281908-1-ying.huang@intel.com> References: <20200303033738.281908-1-ying.huang@intel.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.