From patchwork Wed Jul 17 22:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13735846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F26C3DA60 for ; Wed, 17 Jul 2024 22:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AAE46B00B6; Wed, 17 Jul 2024 18:02:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 033D26B00B7; Wed, 17 Jul 2024 18:02:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E164A6B00B8; Wed, 17 Jul 2024 18:02:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B6E3B6B00B6 for ; Wed, 17 Jul 2024 18:02:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 71518140C10 for ; Wed, 17 Jul 2024 22:02:31 +0000 (UTC) X-FDA: 82350619302.25.6D8BC7A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 4D6F340029 for ; Wed, 17 Jul 2024 22:02:29 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BYyIlfsc; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721253696; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1QImmTBB9J6ICz0B3Smrm8OMXXoPNwmhbbZRF0rUpNQ=; b=Ue0YN0fCM+5Kzem3Ehr9Iib+RwGMSfRBRHjZjZ933flZNTG5ENBJPmSNjjLuKq/FtptiI3 KZdtRBJubXEO+kskwWqfsTduCRytGQrGf4EtQied5btHyt3R1s8pOb0I5WGLlRxhFNHyBW C6H4j+TB1ZdvFXQEfKgvcoytaa0EUsk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BYyIlfsc; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721253696; a=rsa-sha256; cv=none; b=jpa+YxeLOy3SDnJRHvQ4t/EY6KQsVvnlf5MVq567dUkulmZoigqBQJo8rbw2vWS0jzUskm Y6rMCLRRzSGMdPTSsIS/9CO65EKTQUzNlUiQtDQ5TR7l1o63OxwA+iyf1VXSGiRg0e0BGI 0L97hV66L/+kuByo5nRfSTM0+v7oVwk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721253748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1QImmTBB9J6ICz0B3Smrm8OMXXoPNwmhbbZRF0rUpNQ=; b=BYyIlfscfu0TlSzpQLATgGYot4scna3XiKQ9+i8j7Kd1FnfBNzEcnnhjNGtAcQ9dcPKMgB wYUrlFK67D2BmPKzIbutVrx8bkXkDcVHU4aQTkrjsuVrGFk8y9DgXjR+zwpPh/01PK0FtV IyrfauPoiksfnaK/WTQ9fO65TRju1zQ= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-GC96NbbJPhiwfSbOz7wfyA-1; Wed, 17 Jul 2024 18:02:27 -0400 X-MC-Unique: GC96NbbJPhiwfSbOz7wfyA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-44aeacbf2baso259371cf.2 for ; Wed, 17 Jul 2024 15:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721253747; x=1721858547; 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=1QImmTBB9J6ICz0B3Smrm8OMXXoPNwmhbbZRF0rUpNQ=; b=tBcAdBquKaNKwz5bqp0bAqluf/HvuVbBGqIqOvSfrkFPQ8sg8IRP73gixSVUNBhgPc nQdzgkvWtJRjIqO4QoziXw7htw/2JwARgKJ4wpQrN2t5FdeZdjzt6kluiFNOPr66d1Tu 7pzn0r+cqgRJsRPtJNk/0xhsv121x3k2Xrp5BOA7rh0rNueEL7+vl46Uom0WDkWub/Wj y40Urb5oUwBaF3VDRCFio0Jc8pvmXjQXzMsFzmbH0wqQqfZW26hp7Ds9ACINExyLpaPI 8Z458u2k3q5HnmD5189nEvSghlGBvjOGSfZH4Zk2ZWSW00+vJXfUSrFRJaXRzNzhcv/v 32Hg== X-Forwarded-Encrypted: i=1; AJvYcCUF3nTddVsBA0BWngsJXWwv5T155JJ6jjdwaMfmc4hCGYATm0p7KDoMljc1FXpzeQ40xbVckfNO+gTzPZfDZ7aksjI= X-Gm-Message-State: AOJu0YyREBJ4SJVrur0sAmQfihgte+0EcdrD+SAhQ+8s1066kF8WFc+R ni8zOO4LgOh1thdZ4ZEKPApqHndwpOMBD8106g1+dNWL5tw4F4eyYDQDTH7Pl6zWPFl4dfHT3Ze wtX0TjlnAX/i18gLtDOJ5/EzrrmhXzbNAcfw+Z2/II4qlJmVs X-Received: by 2002:a05:622a:3cd:b0:44f:89e3:e8d3 with SMTP id d75a77b69052e-44f89e3ebf3mr16472801cf.10.1721253746707; Wed, 17 Jul 2024 15:02:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7KLWkbU1UwJKSHrhdblARNi4OMqfXeCTcT+ovTUhvRHwOTG0GQKyZtUb2OdQ3d+/fWLwEbg== X-Received: by 2002:a05:622a:3cd:b0:44f:89e3:e8d3 with SMTP id d75a77b69052e-44f89e3ebf3mr16472521cf.10.1721253746301; Wed, 17 Jul 2024 15:02:26 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44f5b83f632sm53071651cf.85.2024.07.17.15.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jul 2024 15:02:25 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Vlastimil Babka , peterx@redhat.com, David Hildenbrand , Oscar Salvador , linux-s390@vger.kernel.org, Andrew Morton , Matthew Wilcox , Dan Williams , Michal Hocko , linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Alex Williamson , Jason Gunthorpe , x86@kernel.org, Alistair Popple , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, Ryan Roberts , Hugh Dickins , Axel Rasmussen Subject: [PATCH RFC 2/6] mm: PGTABLE_HAS_P[MU]D_LEAVES config options Date: Wed, 17 Jul 2024 18:02:15 -0400 Message-ID: <20240717220219.3743374-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240717220219.3743374-1-peterx@redhat.com> References: <20240717220219.3743374-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4D6F340029 X-Stat-Signature: 39gxessijgahcy3a6c1pafmrx9uid61c X-Rspam-User: X-HE-Tag: 1721253749-435789 X-HE-Meta: U2FsdGVkX188QVcTQcOMes/asqd1+y8JmqQv3IE83z6J2JZzUUaJ6FsuiZ2Tf2OuSWFNJCjzHUC5AahrgOTT7rTbWgWhUM4h9RHBSA3LV8sXzm/L7iiL12TAeKd1H3hBWTWpUAHwgME6h+HvZWIdD/SEP3tJRB+lqbyv6NYOc+W24jgGJtz1i7tWvCYgV0y/iYrc3VGydonzsSOP2IKeIwnzeyyZxajzSN4odCEt2/Q4P8AE1py15C1ND+alXxxPC81YDvMkLWdTbtB2W4paEnzGYYUp66eVd59AwOUDVt6TXka5B61mH1JGXrTb72J1z0Ia+HFCTC/3UVmlFGO7XqfdZtnuOUdjPEm2gvbQMklMiMntAseYeX6fClSNRN+mqUeP8wo7zabCGECvtYS8nLvbHYPE5wXa5eBcCqVaK8gmEwuUZz27rPiMjWXHzEoyIJpDA3r87ddEfEelfiflhwiOb9xvKkGi+1bYrKGcKqAXSxK9aqgd9F/fWN83NhrJ1aMOesXUUjQKDDFsqBfVdVRVvF6Ju0FL3YgyLPU+wqUY2EFxBEYm3p4UgPn4GngjZcY2ok/hyMOCwC5clcczwdw5irluwQGWapb81RAERnx/zI5/Im2xAcji0zpVmqmZvKtfLAMDK4BmuF0slHe5B0DD501uieYAJN8BSckA2AGFXP4FpiDCnN3laZIWgcrPVBX/76Gjv9U2OF2lfbGaUIagMkwqfe1ZFFP1GQ2dquo1h+mWn6UT8SWE7na0T1Fg5WDQSpN0FGJNNRMcNYeYxK1V5ttAgPfBHB3OeXrj/uaIK8EHWvxMbJrl0oiHXrr7HWwm/8T8ELCPAemWcD4Kl4dNoWpexYljBwMY5oUT782djm9/610QVdvOccosvind7Jr/RBoe93WtoFTri0Cwzy+b8EXLcnp72/ouSOOkBuIf28rZ6G7bFHgiaMruKe/VP3lg6UpIJXCZ53iKox+ fs9Kx4S/ dHa48Pw0K5Xrf5+a/jdXLO7Afc5ym8oBgZjkcLMc/0oc67Vb0OPCl+Wt3QJ9cbTcZB76oJWlltCTxg4zsp4Z4zBR1qIYJRYTMl3dsroyF3dNJrG7rs40cyb5VnEGxQih7/McPby+MSK+ye8DsShwrQyznLLHDcMQUq5Q93JbJMJ39//5qdB6VnGXPqsFgtqqnKo6xTsk8Z95Uz65QO/75HKrjjrbz/w9FOWW6AvO5kyIEqMdzOarDkABKb8QHjXS33/JjuYue52wSGbIAuMn6SQRJVivOoL/qkObbMc2DX1dBDvq2n8IZm+Z7qMkgmiE6CFWnNHzmexQRyAIknZKwWr0MEg== 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: List-Subscribe: List-Unsubscribe: Introduce two more sub-options for PGTABLE_HAS_HUGE_LEAVES: - PGTABLE_HAS_PMD_LEAVES: set when there can be PMD mappings - PGTABLE_HAS_PUD_LEAVES: set when there can be PUD mappings It will help to identify whether the current build may only want PMD helpers but not PUD ones, as these sub-options will also check against the arch support over HAVE_ARCH_TRANSPARENT_HUGEPAGE[_PUD]. Note that having them depend on HAVE_ARCH_TRANSPARENT_HUGEPAGE[_PUD] is still some intermediate step. The best way is to have an option say "whether arch XXX supports PMD/PUD mappings" and so on. However let's leave that for later as that's the easy part. So far, we use these options to stably detect per-arch huge mapping support. Signed-off-by: Peter Xu --- include/linux/huge_mm.h | 10 +++++++--- mm/Kconfig | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 711632df7edf..37482c8445d1 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -96,14 +96,18 @@ extern struct kobj_attribute thpsize_shmem_enabled_attr; #define thp_vma_allowable_order(vma, vm_flags, tva_flags, order) \ (!!thp_vma_allowable_orders(vma, vm_flags, tva_flags, BIT(order))) -#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES -#define HPAGE_PMD_SHIFT PMD_SHIFT +#ifdef CONFIG_PGTABLE_HAS_PUD_LEAVES #define HPAGE_PUD_SHIFT PUD_SHIFT #else -#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) #define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; }) #endif +#ifdef CONFIG_PGTABLE_HAS_PMD_LEAVES +#define HPAGE_PMD_SHIFT PMD_SHIFT +#else +#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; }) +#endif + #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) #define HPAGE_PMD_NR (1<