From patchwork Mon Jul 15 19:21:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13733835 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 21C27C3DA64 for ; Mon, 15 Jul 2024 19:22:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D485E6B009A; Mon, 15 Jul 2024 15:22:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFA406B009C; Mon, 15 Jul 2024 15:22:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B22FC6B009D; Mon, 15 Jul 2024 15:22:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 931366B009A for ; Mon, 15 Jul 2024 15:22:01 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 45E9380157 for ; Mon, 15 Jul 2024 19:22:01 +0000 (UTC) X-FDA: 82342957242.29.DB81E3F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 39DF7100015 for ; Mon, 15 Jul 2024 19:21:58 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cGx7pQhS; spf=pass (imf14.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=1721071299; 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=JQsWXKlYARhd17zV/s6WeK2CL/vGMx3ZgiMAzEuZ0WknfdkY/vlkBpUK+Me/lci7pMfgYc N5QUu9cvSgk5J7GfKCtqsCRWwxQNq6zXbvZt4VtOSxeoawZDcAnTKnnAVUtWikWzvGsHP6 JpwYrqUOZs6WZnSuTZC6NxkpTVeC2co= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cGx7pQhS; spf=pass (imf14.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=1721071299; a=rsa-sha256; cv=none; b=5N2igaBvQvzJ0gSQ3Prq9kT3IREggDzbPZdqB2GBnMa8phN+1U13XKQ6sR/LV1yCLWdtVP 6hK4eqCAqhyeoLKQzm10UJSvHp4lxzhLVWAB3/6GBAOuNe7PEWr4i++DtJcwgQcSRnG3BL rpuDpJnQJyXG+ZlcFL+Sor7wrJt/aMo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721071317; 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=cGx7pQhSGxG8NiooGlbcXbDFs3ikYT9ajrHI0k+S6iAH2RCABJ8FxJDqLrFbt2icnhfFSa C8ooNWzbvOmuQ0ZgOSntMfLP1RO0ph3WG3dlQDMLwBEHCoCJC5d4Y6Ixm+6L1jNLyY8o9m 4zhqvVhkb6bdCnvHC225jqfFkoOf1qs= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-B9UFhhDqPeSISU9a9qcrOw-1; Mon, 15 Jul 2024 15:21:56 -0400 X-MC-Unique: B9UFhhDqPeSISU9a9qcrOw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6b60b5b85deso13080186d6.3 for ; Mon, 15 Jul 2024 12:21:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721071315; x=1721676115; 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=e//iPaby34H2HJz7tTFmr9iQzGRX18ze6EubnTWrLwiInqsz03gEhgRKG/hTzMvvIF GIGqbF4Jl8ogR+TLhu0XFMitTIGFIx2jpYaENO112ZfPkYf26N3vWv8j5rfzG3ZL6v/A SoiJPXSeZ3VFRF8xFIquLXLzVuEiwsuzp3Jv9flTrIBlamRqCnbFfXNU3TcQlzu3fp+g G2LblN9VXJXuff/+jWcCYO6vPiqtZTuVEZoPZeH2I4eSrwf1TUwByflJGW3YFVWddGFn z+h/vLWEa9GiMOlyTaxsgiImaq2vhGryruF4HkocPEJEZi35aHMGi0afoat8+brLz/sN SxiA== X-Gm-Message-State: AOJu0YzT+ptsWxEAk/dW9/JH3Og08XSo+apTIDLtdkAGGaRM1QAQFvsw Xdm8AM7rG0/wQwau4IwvXsOmWnQskC8Vbx6pBUjwN4FLmZlFa02EAyjnm9Mdw4eG7Nw5PzoqIHe Na265alH6jtvOhHW7rZzNQdFKT+2AS+IWRGPQOLWIETyTfR0jTYHjjTwHMRuPcLciTOnf17+2Sa u88bynJf6qJbGpeZxxpBz5Krk8RqjfqQ== X-Received: by 2002:a05:6214:2dc1:b0:6b5:90eb:370f with SMTP id 6a1803df08f44-6b77de8150amr4905806d6.2.1721071315045; Mon, 15 Jul 2024 12:21:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFc1iq6cjowggxR08A9jWNh2nLNKZtlnYVNF070vv7/tCRn3zBtJYgG+pCX+rmBsWl/qf7Fw== X-Received: by 2002:a05:6214:2dc1:b0:6b5:90eb:370f with SMTP id 6a1803df08f44-6b77de8150amr4905476d6.2.1721071314625; Mon, 15 Jul 2024 12:21:54 -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 6a1803df08f44-6b761978d30sm24039356d6.31.2024.07.15.12.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 12:21:54 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Dave Jiang , Rik van Riel , Dave Hansen , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Matthew Wilcox , Rick P Edgecombe , peterx@redhat.com, Oscar Salvador , Mel Gorman , Andrew Morton , Borislav Petkov , Christophe Leroy , Huang Ying , "Kirill A . Shutemov" , "Aneesh Kumar K . V" , Dan Williams , Thomas Gleixner , Hugh Dickins , x86@kernel.org, Nicholas Piggin , Vlastimil Babka , Ingo Molnar Subject: [PATCH v3 4/8] mm/powerpc: Add missing pud helpers Date: Mon, 15 Jul 2024 15:21:38 -0400 Message-ID: <20240715192142.3241557-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240715192142.3241557-1-peterx@redhat.com> References: <20240715192142.3241557-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: red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qdT1lMv05PuDRdfOpXuYtA 2gFDiVcV VOY6V1Z9uDkBtX1XK7h5Rcp6F/H3qQLH6JjzFyuuZa9kcNGu3Pk4jLW+pc02D0X1lqhmPxt1+XulQzYdFsj7SPTL5zzmQfMRcvNa2FK3NfCF7cpkV64tg0uocUrfdDhiIHBIIqWrNwQYdjmvNhasyzrv2kBdXgdmqwWygJumTUx/v5uUGbQCscdLU4iZpD2IJuc5/DzMfEY4P69VtPyBFJ++fQ83Q2IpQiloGKGqw+MZ4F5834Zt3QWlBH1hyIl3J+TWA0KWm5sXtq49OFPvyZlwma+cUjfUOi/2bO5IzlDyKRJ8ij6DcUwlAKZfdnDTbp1dzPLmMjNMUvByk9TKyftLlUWzy4EKgfNPMX7oHqVQoR96IdzpDK0rLKKZ2rndTCSmtGQoLWLhexlW2gdc4n67DY2LisGz738T3EOKfDD0vP80MSXpVB/S8xOeN37kHBWThasSTVSJRpsY= 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 */