Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp694417ybt; Fri, 10 Jul 2020 10:00:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIRruEsOEWNEoAotZB9++XQ+ZY2Q+rEGd0WX6gnkPt58eZcyZyZJrMsOR7kyFq2Mff7dBE X-Received: by 2002:a17:906:abd6:: with SMTP id kq22mr64808719ejb.458.1594400426064; Fri, 10 Jul 2020 10:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594400426; cv=none; d=google.com; s=arc-20160816; b=O9F11GM3WHKpjZLdjmhF2NKf86rpLm2j9hlfMylViaysRAE1W4A1u84XVCVLNRBGzx PJ2QwXjv25NYmlgu6/Flb2h70gW6hzDolGG7GlMK1FgdZ9iqhGf+wOgV3Ldz4nq4Z8cl 64yTuVMczul2p68bYKptXfVKl4f46/8jCb0piW42d6YDG9DQeSYi1hTARViK03NyXRZV Wqr+j1t03TIMhN6qsh32RQE/9utI2Xx2jPC41cYLBaogtvK/OLS7VZVacj71ovncwkQc 3PWLc+AGAdphUNfxVVDowpAueUAanVMm//vMbdmZZ+YMKjJjp+vABUesJ8VcpMe4Iii9 57Og== 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=REVCDakwgDG+DYRws7LZzQi4QLzZc//D1GvkmuJe/WI=; b=0j7CD2G2PpO9PE8hnmbiZjBeDp+w/+Dk50xBiBJnWIPnRfWhBcQ8wNad+u8pyA5fmr HVnxsTiLh0PAMiRUlPKOJaFn651WlYHFlcFhfpktXjx6kVtt3yqHG0iIr0pFYUGQMQGS +EfmtU7dNSbjwj+0ZWqkUmkAdIypraQtXP3KyRSedUUhE9gmrr7OdpyLM516dcMo0rX6 5Y1W6jLXxPgYOVphGNRezJXr8fKw2NRCNxIfEcU8uzoPHZNi62eNzaGCgnLuwIvqsHcO y/C7N77Q2dgP62vdgpOL56ecS/KcnJIQR643VWDh9hUVAmVB7RDwGLQpBj5mY4Xn9cr4 OXLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=dgVJrxlU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g26si4108759ejo.47.2020.07.10.10.00.00; Fri, 10 Jul 2020 10:00:26 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=dgVJrxlU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbgGJQ5x (ORCPT + 99 others); Fri, 10 Jul 2020 12:57:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbgGJQ5x (ORCPT ); Fri, 10 Jul 2020 12:57:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305A2C08C5DC; Fri, 10 Jul 2020 09:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=REVCDakwgDG+DYRws7LZzQi4QLzZc//D1GvkmuJe/WI=; b=dgVJrxlUyxMQ21th+aRn2MrSte FdbzjRbZu8cLN84tlxqHdpFUtzI8O95wTMXQ/rcd+AaWG72Fv2A7dITBe7ZOMYqOkJkP5Wl2RDVQI PrmqKB+qfPCs2PhwcxeQZndW25BDLWlRghD4B9Re6xZnguBBMY+GfbMomE2r+5y9IDCsfAeIH/DmH C9EnZqB7WqxgWix+ggL/mp49WUS29EzpgQePI53Ku3ta6GNOlTwRLtiwQ46aA8MwI0KaYXr5V8FDZ QO3Rc9Rco4kbnB4D8KC0p+ua5rvu7TpfJ+SFN8HchKD8BAzsrCCyjPu/Ro1bimWM5UAQlpTmOh6dY AZQhWk4A==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtwLK-0005Nl-8U; Fri, 10 Jul 2020 16:57:46 +0000 Date: Fri, 10 Jul 2020 17:57:46 +0100 From: Matthew Wilcox To: Andrea Arcangeli Cc: Hugh Dickins , Mike Rapoport , 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: <20200710165746.GO12769@casper.infradead.org> References: <20200706172051.19465-1-rppt@kernel.org> <20200706172051.19465-2-rppt@kernel.org> <20200710164037.GA11749@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710164037.GA11749@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ > 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.