Message ID | 20231116012908.392077-4-peterx@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2924214vqg; Wed, 15 Nov 2023 17:29:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEawFDEdtEvt2u2YW5dEG6XdpMjQg65S4Biya9Hj2JRfJE8Lm+7QHF8AE0H8o4lJnPo3o6Z X-Received: by 2002:a05:6a20:7486:b0:15e:dc75:66a7 with SMTP id p6-20020a056a20748600b0015edc7566a7mr12917356pzd.24.1700098183852; Wed, 15 Nov 2023 17:29:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700098183; cv=none; d=google.com; s=arc-20160816; b=EhJ3qvhq5VAE3f+UfWAYBq/+PsJArkt5N1hg0rIvTB9LpgWwzezw/CKluDWrBBUrGP AuHTJseE4je/M2Bpcg/406qaQPtIm3uh7VQySDnZye2LwPGdzZBo7vJBBkP9/oibmA6d nShiO8h/x13CXfY8eiGK2HEVrQfkz432k8OmKX9nsc1zMznMWe72DZ2DfFXjS/Wl1bOG R7vXDmgdD5uNNpOXufxlbYC/x8n/oHSYAS8czdNb/oh+urIYuzf6MuUF/TVT1tPA+Y7W Ac0KThqDMVbdNVXeiOkOReBTBWsX7yuAiJkUSGUEgcArt7z2UAGkOOrbcyfj46fmgXIY W2TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PGiD5LrOPbNAVIZVL9CsLOYGNogun3F0ZNXBV5lOZSk=; fh=o+FJD7UTEFgAOwGBZppViFyhRpBzPGRfoO/6xzRNnMs=; b=cUYo+BGJgElN84MOF2ZA52CjikIZ+0Q9aRpbG7fke7N+s+luZvhQ5buqdYjjByQydd jyVD7YQ66B9/P21RBz8Vw8Pu1CUCNPgx1Zwg5AjO+mYmAFRZNz+//HlSth1HNupVGHU/ Wyg//bGmo2mD6dfoemsS/7ib4Ng1Xp6IGhyxK5qtyTxHhWh4fMG7vTltbRNRCtphbVKL +izJEdKnuuWLU8dkcXWyxm5DbSY8s3ahJOoXXpJv0PbAxq6eopH3XxlIhUirjM2omaEj Gr91IQX9oiyEBbVBQFTYAjtJQ0WHfWtOA874+J3BuRShmmQ5V6bUw1aJuycQ1JOc8P8q FlQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LgKVGdB6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d10-20020a170903230a00b001cc45fcb81fsi11861166plh.334.2023.11.15.17.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:29:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LgKVGdB6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8DEE6811F115; Wed, 15 Nov 2023 17:29:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344475AbjKPB33 (ORCPT <rfc822;lhua1029@gmail.com> + 28 others); Wed, 15 Nov 2023 20:29:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344326AbjKPB3Y (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Nov 2023 20:29:24 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4538419B for <linux-kernel@vger.kernel.org>; Wed, 15 Nov 2023 17:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700098160; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PGiD5LrOPbNAVIZVL9CsLOYGNogun3F0ZNXBV5lOZSk=; b=LgKVGdB6I4hNe4lwEdpQGH/NWKuJhQm4TWd80F/drBP9Vq8+DJCrNjCFv/e2kuYEzj5+7d e3ZI6JJ9s8w+mluRgz+vQmVYzjLiY7p4QY+g3zRawMDOY2z+hgurdBfHgiSJViKCvNQYr6 S95Aih6Eb2bBC33DMba37QwRgM6LpgQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-w0VJCoTSNWCS79fGDUeRTw-1; Wed, 15 Nov 2023 20:29:17 -0500 X-MC-Unique: w0VJCoTSNWCS79fGDUeRTw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-66ffa15d354so814626d6.0 for <linux-kernel@vger.kernel.org>; Wed, 15 Nov 2023 17:29:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700098156; x=1700702956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PGiD5LrOPbNAVIZVL9CsLOYGNogun3F0ZNXBV5lOZSk=; b=FJ8tWTHSk7IrYTtgVBxiuvJsBDwI9TAywTI9/KP81JFBMTD004U5/1PrtccqxC+Xkh IVwp9SRsLDKoD9ebHCG86graWF20A7ICcwfb3WEDaTLxNssqoQkr/vJOjGp3/fwubx+I Y0G0nJrmWrh/btWLcDrqxzGz7SCBh4YkJOBqwqbwvXYSBHQYajKPfs/31UOE1aY9AkxD CcTSYYjYqsmCWsknGO2rhtyTdan/VvVAxLq2SoCn9QqnFbyhFAYPSJCtyzQRYwLw5K+0 +WHpYhpqluAv6RQzV/tz0exP1bU+nGIrym8RIr9Tb3gAcOhWQWjoJzv8clJkmmHvyqe2 JAHw== X-Gm-Message-State: AOJu0Yx9GOtu0iC3/zK1za/xuyk4dpw1sTCc/EyS5n5pNgP9Od8BQ9R7 LVheTEt/84XV1vrY/26q7ORNrZ35BpDcpbIgxg9AszZGCRRsVmh4yB1v3agZ+rvVttMinK+Nqsl iNnh2E5gSwNI5u/By5Mj9jQOT5RNnvxqc/5UTqCqpLyeND4xEy9d+7pvDcOQh3cGvqqRwcIeMYB LZsw38+A== X-Received: by 2002:a05:622a:8008:b0:41e:a62b:3d28 with SMTP id jr8-20020a05622a800800b0041ea62b3d28mr6714107qtb.4.1700098156347; Wed, 15 Nov 2023 17:29:16 -0800 (PST) X-Received: by 2002:a05:622a:8008:b0:41e:a62b:3d28 with SMTP id jr8-20020a05622a800800b0041ea62b3d28mr6714076qtb.4.1700098155869; Wed, 15 Nov 2023 17:29:15 -0800 (PST) Received: from x1n.redhat.com (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id c24-20020ac85198000000b0041e383d527esm3922598qtn.66.2023.11.15.17.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:29:15 -0800 (PST) From: Peter Xu <peterx@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Kravetz <mike.kravetz@oracle.com>, "Kirill A . Shutemov" <kirill@shutemov.name>, Lorenzo Stoakes <lstoakes@gmail.com>, Axel Rasmussen <axelrasmussen@google.com>, Matthew Wilcox <willy@infradead.org>, John Hubbard <jhubbard@nvidia.com>, Mike Rapoport <rppt@kernel.org>, peterx@redhat.com, Hugh Dickins <hughd@google.com>, David Hildenbrand <david@redhat.com>, Andrea Arcangeli <aarcange@redhat.com>, Rik van Riel <riel@surriel.com>, James Houghton <jthoughton@google.com>, Yang Shi <shy828301@gmail.com>, Jason Gunthorpe <jgg@nvidia.com>, Vlastimil Babka <vbabka@suse.cz>, Andrew Morton <akpm@linux-foundation.org> Subject: [PATCH RFC 03/12] mm: Export HPAGE_PXD_* macros even if !THP Date: Wed, 15 Nov 2023 20:28:59 -0500 Message-ID: <20231116012908.392077-4-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231116012908.392077-1-peterx@redhat.com> References: <20231116012908.392077-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 17:29:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782682153243685301 X-GMAIL-MSGID: 1782682153243685301 |
Series |
mm/gup: Unify hugetlb, part 2
|
|
Commit Message
Peter Xu
Nov. 16, 2023, 1:28 a.m. UTC
These macros can be helpful when we plan to merge hugetlb code into generic
code. Move them out and define them even if !THP.
We actually already defined HPAGE_PMD_NR for other reasons even if !THP.
Reorganize these macros.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/linux/huge_mm.h | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
Comments
No way to export macros :)
I'd say define, but other might have better ideas.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
On Wed, Nov 22, 2023 at 11:23:57PM -0800, Christoph Hellwig wrote: > No way to export macros :) > > I'd say define, but other might have better ideas. Make HPAGE_PXD_* macros visible even if !THP > Otherwise looks good: > > Reviewed-by: Christoph Hellwig <hch@lst.de> >
On Thu, Nov 23, 2023 at 11:53:04AM +0200, Mike Rapoport wrote: > On Wed, Nov 22, 2023 at 11:23:57PM -0800, Christoph Hellwig wrote: > > No way to export macros :) > > > > I'd say define, but other might have better ideas. > > Make HPAGE_PXD_* macros visible even if !THP Sounds good, thanks both! Besides, I do plan to introduce a new macro in the next version to mean "THP || HUGETLB", so as to put PxD code segments into it and not compile when unnecessary (!THP && !HUGETLB). Currently what I had is: config PGTABLE_HAS_HUGE_LEAVES def_bool TRANSPARENT_HUGEPAGE || HUGETLB_PAGE I didn't use something like CONFIG_HUGE_PAGE because it's too close to HUGETLB_PAGE, even if generic and short enough. Please speak if there's any early comments on that, either the name or the format. For example, I can also define it in e.g. mm/internal.h, instead of a config entry.
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index fa0350b0812a..ec463410aecc 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -64,17 +64,19 @@ ssize_t single_hugepage_flag_show(struct kobject *kobj, enum transparent_hugepage_flag flag); extern struct kobj_attribute shmem_enabled_attr; -#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) -#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) - -#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)) +#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) +#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER) #define HPAGE_PUD_SHIFT PUD_SHIFT #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) +#define HPAGE_PUD_ORDER (HPAGE_PUD_SHIFT-PAGE_SHIFT) +#define HPAGE_PUD_NR (1<<HPAGE_PUD_ORDER) + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE extern unsigned long transparent_hugepage_flags; @@ -254,13 +256,6 @@ static inline bool thp_migration_supported(void) } #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 bool folio_test_pmd_mappable(struct folio *folio) {