From patchwork Mon Jul 10 20:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 118088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp63784vqm; Mon, 10 Jul 2023 13:48:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlEFfr/XQe2zvhSu3ifN5C0NjhTBQQQfg+dbIcSXyXOyczQL0ACLqHHVIXD3knlKpjfmXCUc X-Received: by 2002:a2e:964a:0:b0:2b7:310:65da with SMTP id z10-20020a2e964a000000b002b7031065damr7083378ljh.24.1689022100353; Mon, 10 Jul 2023 13:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689022100; cv=none; d=google.com; s=arc-20160816; b=Z3+K1eWwK4XgmPY5IgFCn8qlEm4+TRs3cNhkgIB1HHlgeJaCLSAq5c6baW3wfaEi1T X4kBPi+Qs/PZxAu1wloj7478r0f8P0V5LwuZahhdgqf4KyDLJGdC97B8Q/5PJV2udrcR qq4UmYse7oDE3gthairpFCW9rOGngaUEEDK0xuWW819k0Hr93IwDW/+roQhxLVdH2Fay KZPycDBL1SPRXcCJNWtMtOVpHi/LgGAX0TSYYFkcRTMZZMQdHwAFYu4ORcGTdQwxOzlk 9LV2Z4wCqlWs8JLw8B+J5+3m1hzfTtFDU6I6bU6ph05d5qDbGNTPe15WE6WiQ5mkKxAp g5Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YVryiR3XtoiyFiUlRMFGMnu0rhdwK+sF8PTJzbuMMJE=; fh=Sw3T8HVdJ2SNfjr8InIonpqb67K59zr0WnKWm9/Paxo=; b=Br0iPPtPnVo7Y1nN8LwnZN9eOihY1BKJnd9pAZ1EIQwrgDtiU0gVkaQDqQwu5SW0+w rfYl2DMsTmLo1A3sE4Mynf4wE/Zy+yjGT8IYQIXM9ZwssCyFQel0UDJXhScJVVPehx3+ vgoOGcRhyNGWXyQK2S4fC79sycy8YY7okWQATqkf74xUOoVgKkchGUZO5CpazvJdkYkX ILGc0+qH2b7d27zIt/keTTyHaKJlXMK+2PTyg6g9CmYQp/qRi5lJhE9uuzeZKM+MN0Hv rZURoHCqdkLtjsS1Dw5POFB3Qtt42qWXFAtIwJlZh8Yh15fDGyHSLylpdbG1wCbz6W49 Fs+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cQSu1fAY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gu21-20020a170906f29500b0099318060d55si395168ejb.516.2023.07.10.13.47.57; Mon, 10 Jul 2023 13:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cQSu1fAY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232999AbjGJUqS (ORCPT + 99 others); Mon, 10 Jul 2023 16:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231653AbjGJUo6 (ORCPT ); Mon, 10 Jul 2023 16:44:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75FAA1BC; Mon, 10 Jul 2023 13:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=YVryiR3XtoiyFiUlRMFGMnu0rhdwK+sF8PTJzbuMMJE=; b=cQSu1fAYjR+TiMmvRB+FLhQ9VZ dsKNLEH2eO+40qj1H1+SavyWnV5+amvjA/AhrbeWX/K4/wtT+3j2fFa69/prVbe1UZSyQaBq6jzmB H2+cJXFFy8UHtpl6N4Gch1Ixd0IFCKgOgHptrgwAHYlt6KpxiO1ldUzQP+osBB96120oB0vtwE+i/ oi078x9gLqcljH1xnPXdEDEYPQ9BN5HMqcnU+FGPZlsQZA5HCrT1PEZNqax5MGPGON1xh2zrdXya4 6Q7uEFlqiFvJJJ26lw+kK9j153qORPoU8+H+huhdweYsbKw8Ta5ZKrlR7R7ObA2g9/E/P7+T+bJLA PUYGo1AQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qIxjR-00EuoI-Db; Mon, 10 Jul 2023 20:43:41 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , Anshuman Khandual Subject: [PATCH v5 03/38] mm: Add generic flush_icache_pages() and documentation Date: Mon, 10 Jul 2023 21:43:04 +0100 Message-Id: <20230710204339.3554919-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230710204339.3554919-1-willy@infradead.org> References: <20230710204339.3554919-1-willy@infradead.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771068038006033845 X-GMAIL-MSGID: 1771068038006033845 flush_icache_page() is deprecated but not yet removed, so add a range version of it. Change the documentation to refer to update_mmu_cache_range() instead of update_mmu_cache(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Mike Rapoport (IBM) Reviewed-by: Anshuman Khandual --- Documentation/core-api/cachetlb.rst | 39 ++++++++++++++++------------- include/asm-generic/cacheflush.h | 5 ++++ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Documentation/core-api/cachetlb.rst b/Documentation/core-api/cachetlb.rst index 5c0552e78c58..b645947954fb 100644 --- a/Documentation/core-api/cachetlb.rst +++ b/Documentation/core-api/cachetlb.rst @@ -88,13 +88,17 @@ changes occur: This is used primarily during fault processing. -5) ``void update_mmu_cache(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep)`` +5) ``void update_mmu_cache_range(struct vm_fault *vmf, + struct vm_area_struct *vma, unsigned long address, pte_t *ptep, + unsigned int nr)`` - At the end of every page fault, this routine is invoked to - tell the architecture specific code that a translation - now exists at virtual address "address" for address space - "vma->vm_mm", in the software page tables. + At the end of every page fault, this routine is invoked to tell + the architecture specific code that translations now exists + in the software page tables for address space "vma->vm_mm" + at virtual address "address" for "nr" consecutive pages. + + This routine is also invoked in various other places which pass + a NULL "vmf". A port may use this information in any way it so chooses. For example, it could use this event to pre-load TLB @@ -306,17 +310,18 @@ maps this page at its virtual address. private". The kernel guarantees that, for pagecache pages, it will clear this bit when such a page first enters the pagecache. - This allows these interfaces to be implemented much more efficiently. - It allows one to "defer" (perhaps indefinitely) the actual flush if - there are currently no user processes mapping this page. See sparc64's - flush_dcache_page and update_mmu_cache implementations for an example - of how to go about doing this. + This allows these interfaces to be implemented much more + efficiently. It allows one to "defer" (perhaps indefinitely) the + actual flush if there are currently no user processes mapping this + page. See sparc64's flush_dcache_page and update_mmu_cache_range + implementations for an example of how to go about doing this. - The idea is, first at flush_dcache_page() time, if page_file_mapping() - returns a mapping, and mapping_mapped on that mapping returns %false, - just mark the architecture private page flag bit. Later, in - update_mmu_cache(), a check is made of this flag bit, and if set the - flush is done and the flag bit is cleared. + The idea is, first at flush_dcache_page() time, if + page_file_mapping() returns a mapping, and mapping_mapped on that + mapping returns %false, just mark the architecture private page + flag bit. Later, in update_mmu_cache_range(), a check is made + of this flag bit, and if set the flush is done and the flag bit + is cleared. .. important:: @@ -369,7 +374,7 @@ maps this page at its virtual address. ``void flush_icache_page(struct vm_area_struct *vma, struct page *page)`` All the functionality of flush_icache_page can be implemented in - flush_dcache_page and update_mmu_cache. In the future, the hope + flush_dcache_page and update_mmu_cache_range. In the future, the hope is to remove this interface completely. The final category of APIs is for I/O to deliberately aliased address diff --git a/include/asm-generic/cacheflush.h b/include/asm-generic/cacheflush.h index f46258d1a080..09d51a680765 100644 --- a/include/asm-generic/cacheflush.h +++ b/include/asm-generic/cacheflush.h @@ -78,6 +78,11 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) #endif #ifndef flush_icache_page +static inline void flush_icache_pages(struct vm_area_struct *vma, + struct page *page, unsigned int nr) +{ +} + static inline void flush_icache_page(struct vm_area_struct *vma, struct page *page) {