From patchwork Fri Jul 26 15:07:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13742871 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 BECC5C3DA70 for ; Fri, 26 Jul 2024 15:08:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6026D6B00A4; Fri, 26 Jul 2024 11:08:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B2C56B00A5; Fri, 26 Jul 2024 11:08:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47A326B00A6; Fri, 26 Jul 2024 11:08:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2B3856B00A4 for ; Fri, 26 Jul 2024 11:08:13 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A77891A1198 for ; Fri, 26 Jul 2024 15:08:12 +0000 (UTC) X-FDA: 82382234424.17.B30D22D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id F312E40023 for ; Fri, 26 Jul 2024 15:08:10 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekoM1XeE; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722006489; a=rsa-sha256; cv=none; b=JOYYeoNd5E1h9St5D6jHv7C0GWn5b6+nyaNU/6rlDqlhbCkwfKCgv95d5NlGgmVUt3Dc6m +QZ4nKSKOqbvCQgXCXHfouhpZysOAyyq9hzPU9qLOuTrOqn9yWLm1WYNfrxob9gG5w2iA8 QM3MVdgQA8SyK0r0SrnL3ApKLtvRNM4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekoM1XeE; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722006489; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gclXSPT2RuzrPlofvNqS2CiD4N2Pif5SxTyxuMydzCs=; b=ZMFhgtl6ianRtxUSlKZf5JrF0QcH+t0jmB0D1U1Z2XHGrWO/5qMuTWorDIfLRt1JnoNqgN iIjMLwLP+pcTVXFFB/soXrddvZUfFy5wJMklZOvC88AHSXgzmrsD1Nba8twtI4AFz8FCQw gg94VRj4hujmtf6lXSNim2Q6a61JBOM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722006490; 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=gclXSPT2RuzrPlofvNqS2CiD4N2Pif5SxTyxuMydzCs=; b=ekoM1XeEGewFpWmvKd8XUGfCK0Fm3t2kXd2sCJxEgiWf9EwoZbDjb0vAdkqMzbTaPy8eGP a3YwMljDWYrajc8Yum1Uotsj6odyaJXmMFbXpzC0yA2c6A1/XS5BVflhrCNzIiEXC4eXYf yxw5jwGCNZRlYzBs4rv8GQMTv/C5tZA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-481-CIqENtZwNcGlPB5wTz9pqg-1; Fri, 26 Jul 2024 11:08:04 -0400 X-MC-Unique: CIqENtZwNcGlPB5wTz9pqg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 336DD1955D50; Fri, 26 Jul 2024 15:08:00 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.153]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D50641955D45; Fri, 26 Jul 2024 15:07:50 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Peter Xu , Muchun Song , Russell King , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Alexander Viro , Christian Brauner Subject: [PATCH v1 2/3] mm/hugetlb: enforce that PMD PT sharing has split PMD PT locks Date: Fri, 26 Jul 2024 17:07:27 +0200 Message-ID: <20240726150728.3159964-3-david@redhat.com> In-Reply-To: <20240726150728.3159964-1-david@redhat.com> References: <20240726150728.3159964-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Rspamd-Queue-Id: F312E40023 X-Rspamd-Server: rspam01 X-Stat-Signature: ao78gbxx3nttfbbtrzwh9yzk5sj6cy8f X-HE-Tag: 1722006490-608571 X-HE-Meta: U2FsdGVkX1+ip4epVDqZFZaszJvyHpYLGoGLZvz7zhwR4vY5XyHkwI5QD+E+kpk0PAoQdG2CthN4Lghc/hxGja6e2iSNxFds+w+brC/OXgFUneIHIIOJBorwqagN1OM9HRFUXTIJQNYeSnUu3rCNQsKtiX19OPIex62lfM/RxTd+5O+TVaRwh1ghK+hxl45D3TrJFKfWuE5SXpNsz65DdkrlpWSTead/BXq0P9PNCc818WRmEya/KO1HtWPyMc/GCTZQbSrONHikkUc/7mrxJStCzNhd1OArF873xI/wJvHelgaJKxh/r8pIBu7okIJqlfb+b8BKXSAtflSc8YXQyKyNEiWUtkKpo5g2bzwkuxLn9QTACuHx4LdcfLmnKbyW9mif7iw9GNSwAHjwfvg0QFqbSkolcfeB6uzPcSsCNu95OzpkeVLKacUFnu7dO2MRZRfPxRvnyWsi0J+Bt8/ztatflRF8ZEDAy0gE5pEDVHDHlggNwVu1JIKdAqmdWjQqB0to9fQg9n6yv09noVYkAegwNL2/1Fwj9PpM8mAaPpTLwmJ3BV4jMrSkZX+4GQ1b10XOSc1TWREp2BerzuDBWxG3Pb0tUnFDSenWagfJAQdEk2pfDyYm+igeDS3/3J6fGZrtH/9UuSRRotCKs39h8Erdw+xbcjmwuSd/hFA1Xm2VHfRarP3ecjuT2TQEOlthChOGolJ7ESUr/IWXt2V6s+XY2q7dGyAFS5mm/jzlg1JG9PClKwibac9J/t8Qamxi1yTRrd4Duwb+3P36faNL8gcXt7iIaiS1wKK8G3o/RZxiGVFhAqMf7kRaY+SoYxZB9jU9SZ20cvFMsfz1GiNMvCyqiTMBBcnCP9yPfkbo5paOpdwrQb35ZLvCxPf2JPJYZ7w3tXaODg7gy7kjh0epijLP+wOGQmIdEwVgQHTrW/u5rcaMim9okKDD6xti4fG94vD/MXdbGMEPiPWTJ3o AnndWsth tL/KlnULTM0XVi19Vi6bsxUuLCuoZJ+aLde8eLNY6h/x7RaZ2+oE2sxA1FYTPeLpNn7b9YfB1xoyoG3xzv+nXBfzx1QDBcKsARnadalDA3+OBfP1z2Y6OB0c8pjeaTrXKQElbyDfnfkT24bwPxKu+Y0GYWaF0NoG8UvJvPb0asNZDae429U5/zQE4lwVWcGGQkH1I4kwbxs6kBqRYHI4h2S2Hq/pFkGVWMUAXXnTYCPfDS+3Ijvv2K4B/syHkOqKjWfQ99qBFubKysGWic/WeJ5byIsK/VJNZaQibfnkgk6B7Ne0= 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: Sharing page tables between processes but falling back to per-MM page table locks cannot possibly work. So, let's make sure that we do have split PMD locks by adding a new Kconfig option and letting that depend on CONFIG_SPLIT_PMD_PTLOCKS. Signed-off-by: David Hildenbrand Acked-by: Mike Rapoport (Microsoft) --- fs/Kconfig | 4 ++++ include/linux/hugetlb.h | 5 ++--- mm/hugetlb.c | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/Kconfig b/fs/Kconfig index a46b0cbc4d8f6..0e4efec1d92e6 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -288,6 +288,10 @@ config HUGETLB_PAGE_OPTIMIZE_VMEMMAP depends on ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP depends on SPARSEMEM_VMEMMAP +config HUGETLB_PMD_PAGE_TABLE_SHARING + def_bool HUGETLB_PAGE + depends on ARCH_WANT_HUGE_PMD_SHARE && SPLIT_PMD_PTLOCKS + config ARCH_HAS_GIGANTIC_PAGE bool diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index da800e56fe590..4d2f3224ff027 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -1243,7 +1243,7 @@ static inline __init void hugetlb_cma_reserve(int order) } #endif -#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING static inline bool hugetlb_pmd_shared(pte_t *pte) { return page_count(virt_to_page(pte)) > 1; @@ -1279,8 +1279,7 @@ bool __vma_private_lock(struct vm_area_struct *vma); static inline pte_t * hugetlb_walk(struct vm_area_struct *vma, unsigned long addr, unsigned long sz) { -#if defined(CONFIG_HUGETLB_PAGE) && \ - defined(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && defined(CONFIG_LOCKDEP) +#if defined(CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING) && defined(CONFIG_LOCKDEP) struct hugetlb_vma_lock *vma_lock = vma->vm_private_data; /* diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0858a18272073..c4d94e122c41f 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7211,7 +7211,7 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end, return 0; } -#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING static unsigned long page_table_shareable(struct vm_area_struct *svma, struct vm_area_struct *vma, unsigned long addr, pgoff_t idx) @@ -7373,7 +7373,7 @@ int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma, return 1; } -#else /* !CONFIG_ARCH_WANT_HUGE_PMD_SHARE */ +#else /* !CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING */ pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, pud_t *pud) @@ -7396,7 +7396,7 @@ bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr) { return false; } -#endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */ +#endif /* CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING */ #ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, @@ -7494,7 +7494,7 @@ unsigned long hugetlb_mask_last_page(struct hstate *h) /* See description above. Architectures can provide their own version. */ __weak unsigned long hugetlb_mask_last_page(struct hstate *h) { -#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING if (huge_page_size(h) == PMD_SIZE) return PUD_SIZE - PMD_SIZE; #endif