Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp789712ybt; Mon, 6 Jul 2020 23:51:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCFYOIb38EKHjPxtci+A7h4IomOuAAHuQ1pzobqtrXKGjKngcL3DO/CIt1xMVAEGosoxmb X-Received: by 2002:a17:907:7290:: with SMTP id dt16mr45163166ejc.63.1594104667955; Mon, 06 Jul 2020 23:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594104667; cv=none; d=google.com; s=arc-20160816; b=dOd+IXoe1Y8TNR/73YXJ/u+LJ7N57vd2t/7kWl3O9gKPPgVis/8HSG2YFkPU7Su6ql 3YxMwTnh7qB/LoarZLAAvGGNOR01ddJbEEIo2lkRyamDEIzFl0T/Ab6a34ZFW8zmf1nT hyPVni4Whv+vO4W5d57DyZ4aG0ZAlK+g/bG90y+2jv+5SSxdzc0dDTevba84GqYvK8CR +m5u78dO97yR8JcGUIr5b25IXRk9+74aEzYcc28stWPctC+3DKL9uMIpqZ/9Lxp/PdkJ GMckk8k7wiGvnT2nYTIiU1WyN/TR80SRz6IQSte4o2RJpumstIB8R2tT4KILnJKr+gwD WwFA== 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 :dkim-signature; bh=n7kYjYT1GDLHz0rXoq2e/7ueTDOykN8dItWVPG3hu+I=; b=IUTa8FIpXDNNAcHWgZPvt2oT08wW2askGJUm4WOK49YF4xke9RM4JolECZfmAFTn5t 9eavWUZyJCKnfWWEVLNFCplxbe8LFvINt/EtXGZXBbR+WyLRmNQ/rjSzpkVmin/UQWCG ZkK14xCsqrMtMcOg8o6ZQ1MJHMfwsfmie7p75sFjd7eGQhtyJaDFf58neRRkDYB9deWg mcyN7GGqyE7y3rqvdIbI+p8sUJMSrGfR5fa2MFPNVGyipZtQE/dIcPCYYxqmDRrzyuyy Mg2WE+bpIzuuOVtZ2VhlMJHkX0APCBToK8O7C1rkAN3M6AQnDihm3eXxH8Th35lGaOAK LQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n9oqhgML; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt17si19055218ejc.457.2020.07.06.23.50.43; Mon, 06 Jul 2020 23:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n9oqhgML; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728224AbgGGGrt (ORCPT + 99 others); Tue, 7 Jul 2020 02:47:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:38912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGGrt (ORCPT ); Tue, 7 Jul 2020 02:47:49 -0400 Received: from kernel.org (unknown [87.71.40.38]) (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 B227C20674; Tue, 7 Jul 2020 06:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594104468; bh=BrZtIR1hwOkOoHdXGn9wxjTp5t53vI5UcpP82sif2/Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n9oqhgML7NeINidunbCuNzMC4nkPUFJTK+zTWLS4wKjrDLNngJj5Zx28lF0Flbc+q ks4LMOClE15odkf0Yuu4L7wEahLWdJszHc0CGFCxSW40KRm8MNlSoXu/ZMbJnqNRAW BMlisLXXtBM6PEjn9TlP8BagxeYgv0XOOTgqP7/4= Date: Tue, 7 Jul 2020 09:47:37 +0300 From: Mike Rapoport To: Hugh Dickins Cc: Andrea Arcangeli , linux-kernel@vger.kernel.org, Alan Cox , Andrew Morton , Andy Lutomirski , Christopher Lameter , Dave Hansen , Idan Yaniv , James Bottomley , "Kirill A. Shutemov" , Matthew Wilcox , Peter Zijlstra , "Reshetova, Elena" , Thomas Gleixner , Tycho Andersen , linux-api@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport Subject: Re: [RFC PATCH v2 1/5] mm: make HPAGE_PxD_{SHIFT,MASK,SIZE} always available Message-ID: <20200707064737.GA9449@kernel.org> References: <20200706172051.19465-1-rppt@kernel.org> <20200706172051.19465-2-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hugh, On Mon, Jul 06, 2020 at 10:07:34PM -0700, Hugh Dickins wrote: > On Mon, 6 Jul 2020, Mike Rapoport wrote: > > From: Mike Rapoport > > > > The definitions of shift, mask and size for the second and the third level > > of the leaf pages are available only when CONFIG_TRANSPARENT_HUGEPAGE is > > set. Otherwise they evaluate to BUILD_BUG(). > > > > There is no explanation neither in the code nor in the changelog why the > > usage of, e.g. HPAGE_PMD_SIZE should be only allowed with THP and forbidden > > otherwise while the definitions of HPAGE_PMD_SIZE and HPAGE_PUD_SIZE > > express the sizes better than ambiguous HPAGE_SIZE. > > > > Make HPAGE_PxD_{SHIFT,MASK,SIZE} definitions available unconditionally. > > Adding Andrea to Cc, he's the one who structured it that way, > and should be consulted. > > I'm ambivalent myself. Many's the time I've been irritated by the > BUILD_BUG() in HPAGE_etc, and it's responsible for very many #ifdef > CONFIG_TRANSPARENT_HUGEPAGEs or IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)s > that you find uglily scattered around the source. > > But that's the point of it: it's warning when you write code peculiar > to THP, that is going to bloat the build of kernels without any THP. > > So although I've often been tempted to do as you suggest, I've always > ended up respecting Andrea's intention, and worked around it instead > (sometimes with #ifdef or IS_ENABLED(), sometimes with > PMD_{SHIFT,MASK_SIZE}, sometimes with a local definition). I could do with a local definition as well, but I think HPAGE_PxD_SHIFT is better and more descriptive than ambiguous HPAGE_SHIFT and I was thinking about wider change to use "THP" defines rather than "hugetlb" defines wherever possible. In the end, HPAGE_PMD_SIZE does not have to be associated with THP and limited to it, it just says what is the size of a leaf page at PMD level. > Hugh > > > > > Signed-off-by: Mike Rapoport > > --- > > include/linux/huge_mm.h | 10 ++-------- > > 1 file changed, 2 insertions(+), 8 deletions(-) > > > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > > index 71f20776b06c..1f4b44a76e31 100644 > > --- a/include/linux/huge_mm.h > > +++ b/include/linux/huge_mm.h > > @@ -115,7 +115,6 @@ extern struct kobj_attribute shmem_enabled_attr; > > #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) > > #define HPAGE_PMD_NR (1< > > > -#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > #define HPAGE_PMD_SHIFT PMD_SHIFT > > #define HPAGE_PMD_SIZE ((1UL) << HPAGE_PMD_SHIFT) > > #define HPAGE_PMD_MASK (~(HPAGE_PMD_SIZE - 1)) > > @@ -124,6 +123,8 @@ extern struct kobj_attribute shmem_enabled_attr; > > #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) > > #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) > > > > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > > + > > extern unsigned long transparent_hugepage_flags; > > > > /* > > @@ -316,13 +317,6 @@ static inline struct list_head *page_deferred_list(struct page *page) > > } > > > > #else /* CONFIG_TRANSPARENT_HUGEPAGE */ > > -#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) > > -#define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; }) > > -#define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; }) > > - > > -#define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; }) > > -#define HPAGE_PUD_MASK ({ BUILD_BUG(); 0; }) > > -#define HPAGE_PUD_SIZE ({ BUILD_BUG(); 0; }) > > > > static inline int hpage_nr_pages(struct page *page) > > { > > -- > > 2.26.2 -- Sincerely yours, Mike.