From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 442B3C433DF for ; Fri, 10 Jul 2020 17:13:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F423D20674 for ; Fri, 10 Jul 2020 17:12:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="i0TSrts/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F423D20674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 96E268D0005; Fri, 10 Jul 2020 13:12:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91EEE8D0001; Fri, 10 Jul 2020 13:12:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 835C78D0005; Fri, 10 Jul 2020 13:12:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 705168D0001 for ; Fri, 10 Jul 2020 13:12:59 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2E0FE181AEF1E for ; Fri, 10 Jul 2020 17:12:59 +0000 (UTC) X-FDA: 77022811278.01.bat74_2a0ca3526ed0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id A802A1000A8766EC for ; Fri, 10 Jul 2020 17:12:58 +0000 (UTC) X-HE-Tag: bat74_2a0ca3526ed0 X-Filterd-Recvd-Size: 6052 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jul 2020 17:12:58 +0000 (UTC) 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 8C7D6206F4; Fri, 10 Jul 2020 17:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594401177; bh=D34QGhVyRFu8Zf5JdTUNPdd+yHAT1ehJ1P5X5ASJ+0Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i0TSrts/DvZ7fDUKtv84PXSOO90AWm9K5IjwtG41xrIgrzLPePWBvOe5FPFBg98o/ QAAZjIr4tdO6YLQLDMRmJhiXaTcd5JSukiWksC3LLr0o51D/HYhfOzK2e95Ru5EAKc cP7kHeBCZL9NtUHr2XZPwGuK/TaPw34L/eWZfat4= Date: Fri, 10 Jul 2020 20:12:46 +0300 From: Mike Rapoport To: Matthew Wilcox Cc: Andrea Arcangeli , Hugh Dickins , linux-kernel@vger.kernel.org, Alan Cox , Andrew Morton , Andy Lutomirski , Christopher Lameter , Dave Hansen , Idan Yaniv , James Bottomley , "Kirill A. Shutemov" , 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: <20200710171246.GA1944577@kernel.org> References: <20200706172051.19465-1-rppt@kernel.org> <20200706172051.19465-2-rppt@kernel.org> <20200710164037.GA11749@redhat.com> <20200710165746.GO12769@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710165746.GO12769@casper.infradead.org> X-Rspamd-Queue-Id: A802A1000A8766EC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jul 10, 2020 at 05:57:46PM +0100, Matthew Wilcox wrote: > On Fri, Jul 10, 2020 at 12:40:37PM -0400, Andrea Arcangeli wrote: > > Hello Hugh and Mike, > > > > On Mon, Jul 06, 2020 at 10:07:34PM -0700, Hugh Dickins wrote: > > > 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). > > > > The only other reasons that comes to mind in addition of optimizing > > the bloat away at build time is to make it easier to identify the THP > > code and to make it explicit that hugetlbfs shouldn't us it or it > > could be wrong on some arches. > > > > However for this case the BUILD_BUG() looks right and this doesn't > > look like a false positive. > > > > This patchset has nothing to do THP, so it'd be more correct to use > > MAX_ORDER whenever the fragmentation is about the buddy (doesn't look > > the case here) or PUD_SIZE/ORDER/PMD_SIZE/ORDER if the objective is > > not to unnecessarily split extra and unrelated hugepud/hugepmds in the > > direct mapping (as in this case). > > > > The real issue exposed by the BUILD_BUG is the lack of PMD_ORDER > > definition and fs/dax.c already run into and it solved it locally in the > > dax.c file: > > > > /* The order of a PMD entry */ > > #define PMD_ORDER (PMD_SHIFT - PAGE_SHIFT) > > > > The fact it's not just this patch but also dax.c that run into the > > same issue, makes me think PMD_ORDER should be defined and then you > > can use PMD_* and PUD_* for this non-THP purpose. > > We'll run into some namespace issues. > > arch/arm/kernel/head.S:#define PMD_ORDER 3 > arch/arm/kernel/head.S:#define PMD_ORDER 2 > arch/mips/include/asm/pgtable-32.h:#define PMD_ORDER aieeee_attempt_to_allocate_pmd > arch/mips/include/asm/pgtable-64.h:#define PMD_ORDER 0 > arch/parisc/include/asm/pgtable.h:#define PMD_ORDER 1 /* Number of pages per pmd */ This can be easily solved with, e.g. #define PMD_PAGE_ORDER (PMD_SHIFT - PAGE_SHIFT) or by renaming the current defines to PMD_ALLOC_ORDER. > > Then the question if to remove the BUILD_BUG becomes orthogonal to > > this patchset, but I don't see much value in retaining HPAGE_PMD/PUD_* > > unless the BUILD_BUG is retained too, because this patchset already > > hints that without the BUILD_BUG() the HPAGE_PMD_* definitions would > > likely spill into non THP paths and they would lose also the only > > value left (the ability to localize the THP code paths). So I wouldn't > > be against removing the BUILD_BUG if it's causing maintenance > > overhead, but then I would drop HPAGE_PMD_* too along with it or it > > may just cause confusion. > > btw, using the hpage_ prefix already caused one problem in the hugetlb > code: > > https://lore.kernel.org/linux-mm/20200629185003.97202-1-mike.kravetz@oracle.com/ > > I'd suggest we rename these to THP_PMD_* and THP_PUD_* to make it clear > they're only for the THP case. I agree that THP_PMD_* and THP_PUD_* would be less confusing if we are to differentiate THP and non-THP usage of 2nd and 3rd level leaf pages. -- Sincerely yours, Mike.