From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E72FC77B72 for ; Fri, 14 Apr 2023 13:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u+yH6a/FR9Poa8Cgqz5v/OKOSsi6/QykmrPQjrRmsFY=; b=Ks10ySrabiZuLN +uOKER8E6IXFBY81+uLZ1ZflU6wtYqmBV7RUqlzKRDx5vknWHvgraxYw7nt/ZPEkd39I9UTSQeYRK mNMRxyklunoTaPjNfDLJoFBOZzVzmKyrWDFNUnoU8ODB4BSw3pmiKb9U6+MHPY4SWtaI4xoQ8RKto brhKVimEe98jG3yVQjzRV2j03J8NpDh+NUBqb4OEfAq6EHwQ/+OwuswkPUERDGKmCb6f8CaJXVRJ5 ERG8FZMkLKzYvS2yoiBMu6Vlcz7rYR228E81BTcWQE01yhIE/fZ5UNlAR9oDxZSPfZgYvMfXP/drf rWjre2QIJnEKa4UnLL+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pnJ6H-009bw3-0w; Fri, 14 Apr 2023 13:04:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pnJ5R-009bTl-38 for linux-arm-kernel@lists.infradead.org; Fri, 14 Apr 2023 13:03:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C74816F8; Fri, 14 Apr 2023 06:04:18 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 980903F6C4; Fri, 14 Apr 2023 06:03:32 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , "Matthew Wilcox (Oracle)" , Yu Zhao , "Yin, Fengwei" Cc: Ryan Roberts , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [RFC v2 PATCH 12/17] mm: ptep_clear_flush_range_notify() macro for batch operation Date: Fri, 14 Apr 2023 14:02:58 +0100 Message-Id: <20230414130303.2345383-13-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414130303.2345383-1-ryan.roberts@arm.com> References: <20230414130303.2345383-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230414_060334_227792_D1469A07 X-CRM114-Status: GOOD ( 10.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We will soon add support for CoWing large anonymous folios, so create a ranged version of the ptep_clear_flush_notify() macro in preparation for that. It is able call mmu_notifier_invalidate_range() once for the entire range, but still calls ptep_clear_flush() per page since there is no arch support for a batched version of this API yet. No functional change intended. Signed-off-by: Ryan Roberts --- include/linux/mmu_notifier.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 64a3e051c3c4..527aa89959b4 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -595,6 +595,24 @@ static inline void mmu_notifier_range_init_owner( ___pte; \ }) +#define ptep_clear_flush_range_notify(__vma, __address, __ptep, __nr) \ +({ \ + struct vm_area_struct *___vma = (__vma); \ + unsigned long ___addr = (__address) & PAGE_MASK; \ + pte_t *___ptep = (__ptep); \ + int ___nr = (__nr); \ + struct mm_struct *___mm = ___vma->vm_mm; \ + int ___i; \ + \ + for (___i = 0; ___i < ___nr; ___i++) \ + ptep_clear_flush(___vma, \ + ___addr + (___i << PAGE_SHIFT), \ + ___ptep + ___i); \ + \ + mmu_notifier_invalidate_range(___mm, ___addr, \ + ___addr + (___nr << PAGE_SHIFT)); \ +}) + #define pmdp_huge_clear_flush_notify(__vma, __haddr, __pmd) \ ({ \ unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \ @@ -736,6 +754,19 @@ static inline void mmu_notifier_subscriptions_destroy(struct mm_struct *mm) #define ptep_clear_young_notify ptep_test_and_clear_young #define pmdp_clear_young_notify pmdp_test_and_clear_young #define ptep_clear_flush_notify ptep_clear_flush +#define ptep_clear_flush_range_notify(__vma, __address, __ptep, __nr) \ +({ \ + struct vm_area_struct *___vma = (__vma); \ + unsigned long ___addr = (__address) & PAGE_MASK; \ + pte_t *___ptep = (__ptep); \ + int ___nr = (__nr); \ + int ___i; \ + \ + for (___i = 0; ___i < ___nr; ___i++) \ + ptep_clear_flush(___vma, \ + ___addr + (___i << PAGE_SHIFT), \ + ___ptep + ___i); \ +}) #define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush #define pudp_huge_clear_flush_notify pudp_huge_clear_flush #define set_pte_at_notify set_pte_at -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel