From patchwork Fri Jun 21 14:25:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13707656 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 A6037C27C4F for ; Fri, 21 Jun 2024 14:25:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D44998D0177; Fri, 21 Jun 2024 10:25:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF7158D0176; Fri, 21 Jun 2024 10:25:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF9B38D0177; Fri, 21 Jun 2024 10:25:20 -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 84A488D0176 for ; Fri, 21 Jun 2024 10:25:20 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4193A120F2E for ; Fri, 21 Jun 2024 14:25:20 +0000 (UTC) X-FDA: 82255118400.05.78BC067 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 238B214001F for ; Fri, 21 Jun 2024 14:25:17 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OBFvTQTp; spf=pass (imf23.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=1718979912; a=rsa-sha256; cv=none; b=JdBwcaGI/hHRZItbYcADWrKW7XGcsGJUbqdpOOQtsU4zx3SNE5DMg1+cJ2Sx4mhshrMsvd 0twaUmI7bmmkR8FUQrh0MqZhyPxGuIXdQujz5lNKthhGXAHZWLlYRsAQzuEWmmlcWtIFnn pvBtElao8xle1QmBUwdTDrsbKmUetoQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OBFvTQTp; spf=pass (imf23.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=1718979912; 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=sMhnR88Gj51dgjDcNyzJVzhu8osLx9zEmj3hidZ3w4E=; b=2lm+IHoslkcwDRkwQOIUINmgt/3p061JnH5B9g4xfviqums/J2jSkGsWIuLydAVbtdyI8A 8Fn86jCaDAdtCyrnpu0tQOAsMxcCyg5eXi+5eOt0U/RrKUAY6ol7dhql5pWYrRc8/gfUWL zh7K/zi2m+XqHYjF9TbPCKvAw0nJsQw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718979917; 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=sMhnR88Gj51dgjDcNyzJVzhu8osLx9zEmj3hidZ3w4E=; b=OBFvTQTp8UEOINw9sBFyJdIdvS7mNXFR8yPBYqkPn4GR8qYbtUgKMYXVd5k5BZo2qtWXbh XdSsjI/b5v9glHJGYIJIEPLfchBzP4HglAGfcLtk3RFKnhpENWxhirtDR6A0lFxKsKbgrm 1I5Yqb8cM8dfoI5X/ch7O9Y/qjcwczw= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-aIbT7vPTMzKis3si18EI7w-1; Fri, 21 Jun 2024 10:25:16 -0400 X-MC-Unique: aIbT7vPTMzKis3si18EI7w-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-797cde3c2f8so18604185a.1 for ; Fri, 21 Jun 2024 07:25:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718979916; x=1719584716; 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=sMhnR88Gj51dgjDcNyzJVzhu8osLx9zEmj3hidZ3w4E=; b=kfJXHj+NWEw5QRZud7+n6yHMhBkB+xJajqybhJCbv5KRQUpDpDSt91kv7u8yNV7p2N Q9yFL3TM/1r96LIM+YKotHxZpQzgpAfZXq6gPwVwOX9PRjwOzJ1hY6Wx2H+2Um4CShyo 9XE8JBNGaC7yrhB9zw+ueVsWLb6eO+XomuEeKqzGFu+1D6d38supIjlajvEl6yDu2QfV ePJfCrBnuB/pqskEFwP/96OwbFbXRaRCVJQ+FNNzo+2Mf5eQQIhhmjvWWM1jaAfOItis glHZ14W3I7uM7uK4O0egZm255YlNfQWf+W8TA1MSgpb3E6mwI84E7/OzK9EuI1u4jzkk mfMA== X-Forwarded-Encrypted: i=1; AJvYcCV/VhQ+wiSCx2Ca+pEX4E2Ohvud5b3bEwoCkc38Md1JEvqs0Jh/YSsVRMz250/YTvxDzmFOKJt2pNBNu/gixkLLrSM= X-Gm-Message-State: AOJu0YzcvAO6g+VFJP9HkiFxQfaIrh8OicBXDn3GgOu1UzcWV/dMoepR pD0l+NA0n0P+9yzXCyX9E/BS/i9D7Qnq4xAHEKD68kb9UDqQIyVXq6QPtfaswoE7d2EhqtH3Z2B ZZ6nOMnBSoUl3qyEGN4QFLnLJOGCzxDpnSPe+LqgLsidnAQSb X-Received: by 2002:a05:620a:3951:b0:79b:be0b:77e9 with SMTP id af79cd13be357-79bbe0b7cbemr703657385a.1.1718979915479; Fri, 21 Jun 2024 07:25:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKR5sMdbnn7x0tNnlB82FrZESiADWgCE3S9rPF+Z4OitOxuRlE3iKP8psvTE41pTKeNbOqHw== X-Received: by 2002:a05:620a:3951:b0:79b:be0b:77e9 with SMTP id af79cd13be357-79bbe0b7cbemr703653085a.1.1718979914845; Fri, 21 Jun 2024 07:25:14 -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 af79cd13be357-79bce944cb2sm90564785a.125.2024.06.21.07.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:25:14 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: x86@kernel.org, Borislav Petkov , Dave Jiang , "Kirill A . Shutemov" , Ingo Molnar , Oscar Salvador , peterx@redhat.com, Matthew Wilcox , Vlastimil Babka , Dan Williams , Andrew Morton , Hugh Dickins , Michael Ellerman , Dave Hansen , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Rik van Riel , Mel Gorman , "Aneesh Kumar K . V" , Nicholas Piggin , Huang Ying Subject: [PATCH 4/7] mm/powerpc: Add missing pud helpers Date: Fri, 21 Jun 2024 10:25:01 -0400 Message-ID: <20240621142504.1940209-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240621142504.1940209-1-peterx@redhat.com> References: <20240621142504.1940209-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: yhtph49tid3wpygxi17ngwcutid97fed X-Rspamd-Queue-Id: 238B214001F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718979917-488877 X-HE-Meta: U2FsdGVkX19rMMSVRpgyC9VNEOfTr9gdWMR7df7rnqLiLv3IK8AOlqRo0QUV9G4tsXXeGZ51Mp4pOBZmu1mim7kaee0VV7/b9VW+maY+CFzXuDzWQL1fQeizVVrLy1Phei0oTRzTPFiiowDDi53M+FRGYRwN/R7iolJWTbv7gqQxR2ib2HgD6u2zIF2mfSo16stWOCjcSLEZ4uO5Efo9pUrq3tTPlQwy0nC3y0M4zhZwIj9fxeA4YipzXIsnbRusc+OnXfU1++YJo05o9+dn7d7ANYCnfpjIOjqjMdgVVGBrguDt5bxBXAdjiOew1TctVzh/rpJsfN7hF/zZqCUfyGQGJkQKagBTb5Y6lvo0tu8b9/75OPJIoZjtptlSuJ9l/+GMkxZxmCTtCyBdJdiIVMem6ZXQm21tU7c4KR9S2NV96DjiClN9J3w+IhJMBjNHTNlWjNtLw3kZYa6hMmsZ/qxKa20AJGtcD/IhEZagyp+5FdEXwgRx8VFIfUXVRiQjAupm0qg7+D+9POGzn00IuTtlobD3LI3UoG6Q9qnJG2AVkgtIjsz7KHwRqtOV2jWLc8UwXHqymsg7dil/epIsIkAsoho39TtSMh3GRHZK7Uo8TIK20+IbtmaWWk3pKtFL3HuBcjWkTDqheUGliWxQY1s21KYvu6OgJrvTB4maN9EGrWOUoVeW/lfHv5VSGI1vJEEnbAym9PUf43qUCDEWzJBIFVHVGszUqmQfqrtpq/iv3us4+5H+FNWLzs35WSO/cA9019cSz02YuLAP1WO7oZ9i3sDXoJ3mhjbcg2HX6xULNiXnvHLMucToIVTwVfX+obN5a428JoiJEQpXJLa9ec4P6vxQVuwRQsUsdpJjefyh5HAAJN2uO3pA8Fda9nFa29KA+XUiYAR8S4EOQSegImvSLXP/2fE9qV5J8FC98QXGzkSj9CK0QYQs/1gch5C0WabJXlJUYic+1zPwgqK dHTIoIJC vTwxGbIxG67i3uQFXEa3HGQb6oQXLjSuERmOr9laDh1n8g8XFtqovgjG6XO0NU5qd9hvJUE1uXWKd4ADRS2LXIPe+B3agEUyKH6oGuhCb0GssZUC49FD658vhH668mG4Go7QgKiRQJNGiKoOee1ZBT4xpRpVMICggRQM1epd830ovoCIhqSipiuIUr5X974sXcJPBlFWQaf0JQRMPlpYX8iKn1YYzB9Jg9BGtEujMEKJk2IjAt7bXmPdKQb8QESneIj6KIp0Hpne5Vw93oo51zSXLWu7iMk72opDtYbPxvJ9pxjG9s3YTMU+4ZEVrt/6gM481ngrkr38QBxyeDYVFSOBhf/uBF7YzfaY2UlIkfciZm87SaDE84jgbNrQZkSwPAo34IenhEvvdjzM+k0F4QnesfeFEMGR3D+HV+z9UL/MpM4BMxRl0BXcDBr3yKK2K0HSW+v188MCEmKzyP5o6zKhG8QLMjRhDdloA8icULaIsc1d0BBCGOY3fGi7UIAvcrHFq1j1h4WA7qg/5CGH7Hpp4D22yBc1E+jr3AoHR9fgzxYAzBn1ljlxHQyqRY9I3q2jjsQ9aN/Fx0YYxeHNtkUx/Zw== 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. 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 8f9432e3855a..fc628a984669 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1108,6 +1108,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, @@ -1368,6 +1369,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 2975ea0841ba..c6ae969020e0 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); } +pmd_t pudp_invalidate(struct vm_area_struct *vma, unsigned long address, + pud_t *pudp) +{ + unsigned long old_pud; + + VM_WARN_ON_ONCE(!pmd_present(*pmdp)); + old_pmd = pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, _PAGE_INVALID); + flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); + return __pmd(old_pmd); +} + 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 */