Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp735851ybt; Mon, 6 Jul 2020 22:08:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDlNKITCKSyipCvmeEFmSC0x2ejgoI0gPssP/wc5O/maJIePHHJuVF696LXVQ2jQVR45+6 X-Received: by 2002:a17:906:b353:: with SMTP id cd19mr38890145ejb.395.1594098537796; Mon, 06 Jul 2020 22:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594098537; cv=none; d=google.com; s=arc-20160816; b=CfZosw/AsUTP6+aqq40s2GpCPOkbKAhjcfYIeN8uYkzFZZj24EjVYbRiZjizkwMNaC IjVsuK/9infCSVBaosuYatKWdhCJzpRjFBvx4PfiynIe9Qztn70D5qsOy1uftT4Mwj4z 8IKXoeHu56nLTJ262Zf9eFdvA7n6yUFxB3/wsC9HbW49wEzW+fjWBifhUq/qqc1f/oji DBgDgo/ZSA+2+2s0+i6I7H9yIzn+wZivQ8xMc+f/n+dV8ev7EMPJWGJ1zudy0mRArZ9u rxiMpjGgaY9Cm1rBe7vU64sFtIWTVqCSfWcBe5oXwrO8SZNyeVGiLmKsx5Vg66wbERKC WhFw== 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=zAb/McZ8XV6K9mwnFmuQqAT3ttMAxvJlZ4c61ur+Pa0=; b=qHcVpmCr8GiK65ztEmWlSBhhJ/BDcAvTkKjcBnUWYWjgmoRQhl8UyD7aoR1+pqwo8G Hx8aUng+u5FExUtAvtS5c3YTlf6oGtFok8wseE6fMMVov5L6QaHudcm2Iys6qyGoAgHQ 3DNFdpf6cg+Rish6As+grrBlopSzC6zkiUZGXT0BsdnQvW+q7Niswox7G1AN3Dw2//VC 0IzHHfNOtfJx2dLCrRFhAyct6NL4AAJzepr72KQO5QCfhB2XklVEOx4wAJNCulfNQRwE JE53RLM+W+QF5XEX/rYpakmFG9FfUg+5Nmi8BjNpO0bCkiqwDGAJLmHdO+yo/R94hFI8 OIGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=D+Yof6FF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si14696524ejz.151.2020.07.06.22.08.31; Mon, 06 Jul 2020 22:08:57 -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=@google.com header.s=20161025 header.b=D+Yof6FF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbgGGFHk (ORCPT + 99 others); Tue, 7 Jul 2020 01:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbgGGFHj (ORCPT ); Tue, 7 Jul 2020 01:07:39 -0400 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77D74C061755 for ; Mon, 6 Jul 2020 22:07:39 -0700 (PDT) Received: by mail-oi1-x244.google.com with SMTP id t4so16090849oij.9 for ; Mon, 06 Jul 2020 22:07:39 -0700 (PDT) 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=zAb/McZ8XV6K9mwnFmuQqAT3ttMAxvJlZ4c61ur+Pa0=; b=D+Yof6FF8oNlsgkmvQuu9+VtHHmA9NcZHMWdtgSC/QSPt6pr1sj+AiB3zxUjck6g39 ywslF1il3kMVm/aWTK3rXKezuwLifVn5w7C3ifktqJEi2o4eOwDbGiuHK27GRm7Un1V/ uAGDZ8reGtpiSosTpJXUMmhGknY10wUjR85pjFzVX9eFUNrcCBBFnL8Yv5a8Tovk6IKf E3O8YyKBDq73PTmSGkB/uslZp7RItO6oHD4KJbDoraUxxlpQe7aAhSwYZ/1b/2XmNUE/ kxJUH9iulFf8gugSa6TU/gETmNRFstl1Sq18kRVs8wwztF+RvVtQHYR2ezRguq6oNQze mssg== 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=zAb/McZ8XV6K9mwnFmuQqAT3ttMAxvJlZ4c61ur+Pa0=; b=WGqH4kkqCdEK6ECHIkd36HcdDjmsb3rkvettVDmX729p7Pdz0lvYF/wMmIrXXFNf96 Cu8AOrbSZuy8IeRfHSUbA8urN/L3H97ilrGcIIPXSHVvdIaIB5z+ETGpgCWRmUHSLs+6 A+BZodkGT2HYsaWB21kVPknTeyYkmg1z3EReqg2OAqVCGwKzLNYmqheMdC5rknGJUV6B OuSE8uOELdn3vzLt+5aaDmzah0nppT1UsMgIElSA9Bz2q65Px9683+HP5YwIB2/u45SK FmEVvYPRS6ca+xLxG/YKSdCEfumRzLdUJNkpvEtSJTphDjXyKtGtLaWnNiaw0v9vPSs8 YVWA== X-Gm-Message-State: AOAM533qJEQMmkmdDUiooYb5IMXUFC5QCFgmO6BvogURR5FLvYUNQLZm fuFvq9yIRQKgc9vyanLICmYsFQ== X-Received: by 2002:aca:5158:: with SMTP id f85mr2097275oib.6.1594098458258; Mon, 06 Jul 2020 22:07:38 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id t187sm5490060oib.45.2020.07.06.22.07.35 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 06 Jul 2020 22:07:37 -0700 (PDT) Date: Mon, 6 Jul 2020 22:07:34 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Mike Rapoport 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 In-Reply-To: <20200706172051.19465-2-rppt@kernel.org> Message-ID: References: <20200706172051.19465-1-rppt@kernel.org> <20200706172051.19465-2-rppt@kernel.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) 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 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). 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