From patchwork Wed Jul 3 21:29:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13722800 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 D0CA9C31D97 for ; Wed, 3 Jul 2024 21:29:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 856C86B0093; Wed, 3 Jul 2024 17:29:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8071A6B0095; Wed, 3 Jul 2024 17:29:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E49A6B0096; Wed, 3 Jul 2024 17:29:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3DED36B0093 for ; Wed, 3 Jul 2024 17:29:36 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BC9E7A1F9E for ; Wed, 3 Jul 2024 21:29:35 +0000 (UTC) X-FDA: 82299733110.18.AA02829 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id A0F4B4000C for ; Wed, 3 Jul 2024 21:29:32 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Km3/jtgH"; spf=pass (imf01.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1720042161; 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=DPSgdrK+/9txvlBVeWURx0wHDXuvLt3nB8aMlUhEkV8=; b=Euo9iBtlaj7KZ/svDCbOhcfV7IHUabstr0wWq0fBtoexqZ9dkw4doUMXV4N07hv//i8hLl 1K+dZeiI5WYSEeAVMqmUhgqwLT1lGk8gq1Hoi/snRRxvlqUHEpz0d3jLYYIUjODMVk+N6h LH43azyJlAR5+KLOPJqYKAWyr67yqgo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Km3/jtgH"; spf=pass (imf01.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1720042161; a=rsa-sha256; cv=none; b=16VlfOwdTAL3pInHVZ3CRskPRaekf7zrHf3umOH3zuNWptLek8qKqKzGfymOYDAbLgo8YA oq9tTLRnbeVXQIb8uXIOEo9WkeUkL4rwpCYgN5fTuQzr8n0E3YMPky9Pwx0JReW17tj9/G qt4upIy4Gd0CGGoOv/cV1KnGwQVMWq4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720042172; 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=DPSgdrK+/9txvlBVeWURx0wHDXuvLt3nB8aMlUhEkV8=; b=Km3/jtgHsTRSi5gGVw/t0cmhyKsIi3WMvVh5hIdyIIa4diuninNPt5mtDnxCM4R1wQjBDm XS/+H3qzqQ3v4pCBvJkLl+N+2Gb3BlDPoCxYGYrVhgsf9Th8GRfH4gc4b6gzcyC46ZhA8X ToTP6VI4hOTbi6X11ytEfZV2gaIbJgA= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-YYFbZh5vOVeU94vn7whZMg-1; Wed, 03 Jul 2024 17:29:30 -0400 X-MC-Unique: YYFbZh5vOVeU94vn7whZMg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4466fe59a3dso2086181cf.3 for ; Wed, 03 Jul 2024 14:29:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720042170; x=1720646970; 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=DPSgdrK+/9txvlBVeWURx0wHDXuvLt3nB8aMlUhEkV8=; b=OrANW+UcRxbOXO3fs0tzkAwExvuvFzAtdGckrS4oDfoYpYOTDyYS8SOVu8wLakUuQu JC1NMfwMvAmv5q5oU8U8mrwdWeBbG7MqSL3Huy8iaQrBfFSGdU7H1YuCgEdabk1y0ETe ALl3c/2Vozc/3KdxzI4PTFsuMdNSXPUXbslLBdVDxawsmB+tm2cL9oflp6MGRcNEDe6T vfdAJSlg+HtqRA8gQfS6jQgri7a1i/CIFHuPIFtnV8zJYkQOuKktpKmHYFdRVmcQGRsV uMC1npsa8QQNjsNqP6TdfD0X5cbsHJwTb0YKSLi9564miyBpIxg77ZuZtp1lJnuJairR 5czg== X-Forwarded-Encrypted: i=1; AJvYcCXp/9ObcG5nBX9O2dN+LRudwnnEg+o3SQ4B9+GoQw4JFXGSCKZO08GR6v+lIq2V6tGlYyAbLhl1+hsoR8vt0GvPqRA= X-Gm-Message-State: AOJu0Yw3qhITeWxxHZnBbRH8OfU9O7LGUaNnWs9mFhO9R9dWuSEqCDZn IkbOVpQ/j8GoS+o2uSSTmobwj4njaRWZC7RBieykuIOXww+124h9NRTFmRRTj0JdJDDKXpLuc34 Nymb7z2dfezs/sjS7SG228augKaQpf6nU4AYas05XClZskzs6 X-Received: by 2002:a05:622a:102:b0:446:5d1b:5a2e with SMTP id d75a77b69052e-44662f544a3mr145792471cf.5.1720042170211; Wed, 03 Jul 2024 14:29:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbwAQwNTOhld77jh3m6+0aceNgmx9fLMFpnLFNTJ0A2GCbsDu4E9EVwwSQY1Fjy1mOFnq/rQ== X-Received: by 2002:a05:622a:102:b0:446:5d1b:5a2e with SMTP id d75a77b69052e-44662f544a3mr145792111cf.5.1720042169860; Wed, 03 Jul 2024 14:29:29 -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-4465143eb1csm54337481cf.57.2024.07.03.14.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 14:29:29 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Mel Gorman , Dave Jiang , linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Rik van Riel , Vlastimil Babka , Nicholas Piggin , Christophe Leroy , Andrew Morton , Huang Ying , Oscar Salvador , "Aneesh Kumar K . V" , Thomas Gleixner , Dave Hansen , x86@kernel.org, Ingo Molnar , "Kirill A . Shutemov" , Dan Williams , Borislav Petkov , peterx@redhat.com, Hugh Dickins , Rick P Edgecombe Subject: [PATCH v2 4/8] mm/powerpc: Add missing pud helpers Date: Wed, 3 Jul 2024 17:29:14 -0400 Message-ID: <20240703212918.2417843-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240703212918.2417843-1-peterx@redhat.com> References: <20240703212918.2417843-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A0F4B4000C X-Stat-Signature: pds4zc5nmcq84k3r8xsj3a917kqq3r4c X-HE-Tag: 1720042172-3112 X-HE-Meta: U2FsdGVkX1+85W7BK9UuBATWMUYX0YiIZ+oGAmP7etjVluRWDH56oKl0elluSL4YrYnhQ8jfxWy8kDrXNKMh1LWay2xScEQq7BwQebbbaiL6HKghst5XaIziy3fSCO623c7W+IohGib7xRuuZipdu4RPP/sEEbZKJI2Z+Wd2iuZR01iKxoQgENz4zAB0AZepVwtYazXRtdotBmT99zMcldlUBSs5cvwHH0E5nku0EPakErWqsYnAM6ztNaJ0FyxwZ+t1Im7rMthP/rM+yj+XHOiJWOfszSKIyZOcYHjtwZ+Bb+ticlWAS7VZQPxfALdUpd8VtXIEGk3vtFEaTRe7XWQte01RvZR5j1rQAMiGn4Ny0H14eyBufjuf9vB00m6S96Q51UJkwOp9FIn1HLSDykpiz6yKQY+crEevY8p1sNmMOWNtCoLFum9ry2Dt8R9PeinLhFqpzCr1YCrxTZ0f5I1t+dhXPriu7xqpLgz4O/PhJFoAessbu+TAuczmNAeg4ja6JlrZL3zwS2c7xZtkxx5mgTv9bV323qKH4kuNrbRysoK0DFSXheLcdhUe9HtzyzgOEjm9O93Fqx8Wh/Qt0v7mbxFQbv5iBvKXwRxisn6UMT0ytzJfQE3p40M/DmmsUeAVa2kPwOMFk3NOQ39CD6DO8tRMevZTEDFVL7w0kZbhYI/QOWF8Sl4SDj+aThq87kVWsbp+yLSAO5+C60CMIoZA7UX2D8hUbhhVsW6HVyxw9upov7geDQZTPSqIKcCe/OgaSH0hKKHUrsHQubutvty9vw0jSinOiwyOomb4/vupw98UUCRAcHX8dtSauktmfStHv0ie76kHoBLfKTD+iWx7lgQBEvZTYUSnDdUODd6PXMUPoA5o/bm33OSXKQkHzZ7KZ7dBDAEVAKjlI/wS4YdbCTo1e4CXlW0hLf8MArXFOP6Mw16XynFHZvWgbUFRyLsQ2g4Bsi8iU7QMT+T GykW1BTS e4mVpT9aey8QYwsYzD2Rc6LdDkDbgJS+fLOcG870cmfSOHk5kKF45Y1LovohJv7l8oEauX1O85SBFqqEDrVzJAs59eCmbh/mfxCgUp/Z3xPq//LamOhFvRxJ5tWP8TtNxcC9azhwETgHL9UWG0cH4upyKCdLZMw3P3+oVbUFHvKNe3JcgabMpG4f/FlBiJcJJM6QGPBwOyMaQBAo5MtRjgY9Ewq53BWa7uj/tAwfHdIEoE6tO6INotDOu7fdC+/dnPPK/BjcbeUWqHiEH0eO6GrvlUn1C4uBkLpAhDjaHtcbn9xfz/pF7FFQueRUlJvEeK9RJpC33EAMEIQf6WJqh3tmutRxFcgdG8M3wtEh4bzsNxSFXHGIqhP4Y5GQWzfcIbVM3otYEip2q/qB5kWiHdqZcrKNOX78N/2yeyJmLTPrKn3GCaVIUOJ/kmmNKfi21IvOjsz7OmDpofo9EWiiJ2dcYwz32Jl19ce/H1voRO/RKhSFqxXxnqG0XAA== 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: These new helpers will be needed for pud entry updates soon. Introduce them by referencing the pmd ones. Namely: - pudp_invalidate() - pud_modify() Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: linuxppc-dev@lists.ozlabs.org Cc: Aneesh Kumar K.V Signed-off-by: Peter Xu --- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 +++ arch/powerpc/mm/book3s64/pgtable.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 519b1743a0f4..5da92ba68a45 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1124,6 +1124,7 @@ extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot); extern pud_t pfn_pud(unsigned long pfn, pgprot_t pgprot); extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot); extern pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot); +extern pud_t pud_modify(pud_t pud, pgprot_t newprot); extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd); extern void set_pud_at(struct mm_struct *mm, unsigned long addr, @@ -1384,6 +1385,8 @@ static inline pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, #define __HAVE_ARCH_PMDP_INVALIDATE extern pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp); +extern pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, + pud_t *pudp); #define pmd_move_must_withdraw pmd_move_must_withdraw struct spinlock; diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c index f4d8d3c40e5c..5a4a75369043 100644 --- a/arch/powerpc/mm/book3s64/pgtable.c +++ b/arch/powerpc/mm/book3s64/pgtable.c @@ -176,6 +176,17 @@ pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, return __pmd(old_pmd); } +pud_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, + pud_t *pudp) +{ + unsigned long old_pud; + + VM_WARN_ON_ONCE(!pud_present(*pudp)); + old_pud = pud_hugepage_update(vma->vm_mm, address, pudp, _PAGE_PRESENT, _PAGE_INVALID); + flush_pud_tlb_range(vma, address, address + HPAGE_PUD_SIZE); + return __pud(old_pud); +} + pmd_t pmdp_huge_get_and_clear_full(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmdp, int full) { @@ -259,6 +270,15 @@ pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) pmdv &= _HPAGE_CHG_MASK; return pmd_set_protbits(__pmd(pmdv), newprot); } + +pud_t pud_modify(pud_t pud, pgprot_t newprot) +{ + unsigned long pudv; + + pudv = pud_val(pud); + pudv &= _HPAGE_CHG_MASK; + return pud_set_protbits(__pud(pudv), newprot); +} #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ /* For use by kexec, called with MMU off */