Message ID | 20230711075434.10936-3-alexghiti@rivosinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp319793vqm; Tue, 11 Jul 2023 01:16:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlE5Zc7b0wZ/WoJpcUfqTs1KXPMsAqfoztVTT/tI4PnbZr6UhofoOEwpay4ol26Gq9z5lW0H X-Received: by 2002:a05:6512:348b:b0:4f8:7807:a612 with SMTP id v11-20020a056512348b00b004f87807a612mr11678797lfr.61.1689063361582; Tue, 11 Jul 2023 01:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689063361; cv=none; d=google.com; s=arc-20160816; b=MjainQ2k6GxaX84zSVWlEmStx1srrYa/alKOhKQEI+G1ZYQ8CuwTAJhD+6vB6l9cSt YODTVyRV+IoZfrjNfdpP6WvWPZKrXDlGqXUXF9nswMNTFV1QtJ6InjzCGsdkOwneMuoV gw8FqI5/djS2gvF6ksO+kJMBqdRa9QBplS/troSNfWXY2T3EWuClaGpLa2RTGzv3qnQW mULQP/HYJfJxxswGLx6hoWUSQQnXejPFegWCgIQI0JIjAgVugdTVQ/VRST5j8SjtSbxX s2YHAL75CdaKB/cld5hgYzVeDLJ1ijjAt1wUq1zqtBErOF0Fb3rb4tNsYdFks5+hSCKy k9oA== 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=FofimiyN+7gyzGEdPyrBP2skR/4a1H3RZbKcHwnJwCU=; fh=9KG1GxoJIHO8DA9/W8zOCR/cizSACkxrp9LVRbza3AA=; b=jvdqyNZVyfpBxncqDHAxiLraRu9CjrE7BhKDsuegNSdTarNPiGFaaZCARLU954IUfc h+nkBLW+irXKxvs1SHMzDQ1k04ZOD66bVHMAF0cJEDi3lVJWnAvSWieDLM7p6Q03Q1rW bZ5NjnmgPxlFgjZJeDwYfRY2pAX5Jz40tgbokFyofDIAqybx3uTPWWE8bARAkHWjwB8X TznLo6XOQLERH1NQQrXOrh8XQoli9C+mXeffO66amHtG02KwvpO50Qy/naLo2GGjuTjs KseVBfpGTAY52MmiCCmXfJWw3WPDYZLFF1TV0yZZOcPjK63fHyGhX0JRu9tZlAb+zlCI aesQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Qf1MDi4I; 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 k19-20020aa7c393000000b0051e2cc05ba9si1527982edq.306.2023.07.11.01.15.38; Tue, 11 Jul 2023 01:16:01 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Qf1MDi4I; 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 S231503AbjGKH4p (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Tue, 11 Jul 2023 03:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbjGKH4m (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Jul 2023 03:56:42 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D661A8 for <linux-kernel@vger.kernel.org>; Tue, 11 Jul 2023 00:56:40 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fc0aecf15bso28410575e9.1 for <linux-kernel@vger.kernel.org>; Tue, 11 Jul 2023 00:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1689062199; x=1691654199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FofimiyN+7gyzGEdPyrBP2skR/4a1H3RZbKcHwnJwCU=; b=Qf1MDi4IQVSgi+mVmNSDLBvvWhfd8ba6Ayo48Gj0+fuhQZ4V9G61dBcMO//cFS1/fC eMTYYy06UvyotO+oVGCBq6zI9sY1LeYU01nJRoZJ+JLckfsVKJMM97nPklKyDZRE3HOu TVkWiZ1s6BeKrYLS2wuPUnzE9wyBrK5LdHaTtNHXVs67A6vQfZbIP4oSE43hkg/e5u/I R82FjYAOaShi8TnwHOG++346KF4aekyWodyFCqKGj8HPeSDtbX8x88W80pqGP3MBU7wD 2AUgLCJEZ6IWj8TTYNHFpXz8+pCuX+wIU15tPfBynjH9x67d68/tJq305rfx6T581tDJ NCkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689062199; x=1691654199; 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=FofimiyN+7gyzGEdPyrBP2skR/4a1H3RZbKcHwnJwCU=; b=dln7TNWGQ+VVkuWvNFCKcmHgklokzhprinyx+AZMFWxzxVhHJcwWUwVUoeuoOXJ/z6 zfp80pEn/yD1CaJ9L9c8xJSytV7MFLiu0wB6X9+D4wbhdXFBwk5dCtpNXyLmzxVjA07v 4A87SGJScbr+leo5+8XtTk3UxlWyiU+OeH6Bs23AscuVI+rQvMhzqFXuy0LYr5T5nL20 6Cuo5Z5S3EpEJHKh8O0r0M8fWIgRP/YbnLEPlmNgi7TOYNv8ewfNjRE+xDZCwdXpIFqM 66YabW6aHq4ibfgy5Th3FfpQd0sYpn0847XjXdZN+OaKTL95c3hurOSB2lqVpwZHRe9f 0bpw== X-Gm-Message-State: ABy/qLZkj86a/aASTN8kXrToLcpnpy0ManoOC8AxLJmZhy6Z/ZUxHaAu dOXZ5cOwtay4eZBbVIIMw4olWQ== X-Received: by 2002:adf:f052:0:b0:30a:a15d:eb2f with SMTP id t18-20020adff052000000b0030aa15deb2fmr16274589wro.3.1689062199178; Tue, 11 Jul 2023 00:56:39 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id p8-20020adfe608000000b003141f3843e6sm1489099wrm.90.2023.07.11.00.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 00:56:39 -0700 (PDT) From: Alexandre Ghiti <alexghiti@rivosinc.com> To: Will Deacon <will@kernel.org>, "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>, Andrew Morton <akpm@linux-foundation.org>, Nick Piggin <npiggin@gmail.com>, Peter Zijlstra <peterz@infradead.org>, Mayuresh Chitale <mchitale@ventanamicro.com>, Vincent Chen <vincent.chen@sifive.com>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti <alexghiti@rivosinc.com> Subject: [PATCH 2/4] riscv: Improve flush_tlb_range() for hugetlb pages Date: Tue, 11 Jul 2023 09:54:32 +0200 Message-Id: <20230711075434.10936-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230711075434.10936-1-alexghiti@rivosinc.com> References: <20230711075434.10936-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771111303661734466 X-GMAIL-MSGID: 1771111303661734466 |
Series |
riscv: tlb flush improvements
|
|
Commit Message
Alexandre Ghiti
July 11, 2023, 7:54 a.m. UTC
flush_tlb_range() uses a fixed stride of PAGE_SIZE and in its current form,
when a hugetlb mapping needs to be flushed, flush_tlb_range() flushes the
whole tlb: so set a stride of the size of the hugetlb mapping in order to
only flush the hugetlb mapping.
Note that THPs are directly handled by flush_pmd_tlb_range().
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
arch/riscv/mm/tlbflush.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c index fa03289853d8..3e4acef1f6bc 100644 --- a/arch/riscv/mm/tlbflush.c +++ b/arch/riscv/mm/tlbflush.c @@ -3,6 +3,7 @@ #include <linux/mm.h> #include <linux/smp.h> #include <linux/sched.h> +#include <linux/hugetlb.h> #include <asm/sbi.h> #include <asm/mmu_context.h> @@ -147,7 +148,14 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { - __flush_tlb_range(vma->vm_mm, start, end - start, PAGE_SIZE); + unsigned long stride_shift; + + stride_shift = is_vm_hugetlb_page(vma) ? + huge_page_shift(hstate_vma(vma)) : + PAGE_SHIFT; + + __flush_tlb_range(vma->vm_mm, + start, end - start, 1 << stride_shift); } #ifdef CONFIG_TRANSPARENT_HUGEPAGE void flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,