From patchwork Thu Jul 27 18:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 12718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp1319444vqo; Thu, 27 Jul 2023 12:30:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZ0sPQrRn/mgHHsf3/lO8Aa3dmLxaTPMLpjW0jkL6rZvbvM/GDES7IsjFWL06BWHcAKBvo X-Received: by 2002:a17:902:d505:b0:1bb:d70b:e00a with SMTP id b5-20020a170902d50500b001bbd70be00amr290876plg.67.1690486214422; Thu, 27 Jul 2023 12:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690486214; cv=none; d=google.com; s=arc-20160816; b=n8H5MDrnjcAGHkn4BZ51j0CpXtj7dXmieAFdVr/5GB5R8HrhuFtNK1r1+IQ2AA2kuA D0WcC07IEhaM+winsMNVnscJiVKhAFk+UadZqhRzqmieS8933FeNETcd927IRefZQ/dK Jdg3jIdd2Lo63y2y/y6uGN+JbI+uKhmKN3Xrex7ycP1Lz+GfnzCFmZP4Oc1u5QMfqHPR 0VStSgwkqzjlfMLl5/bUexNui3yuaVYiS0VssT27/yaOV8rTB6fdV26NSHEiYv6ciFXJ 56+Fjk7n4jnjljGd84OT1u3567H4TxZEZqG3cfc2vqUqzLkgVYx3gABHwasWEbkZ6N+i +79g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5FhI2SLAGzFPgM0XDlLYh3qjUrSBQmA+KXnizzmLufc=; fh=9KG1GxoJIHO8DA9/W8zOCR/cizSACkxrp9LVRbza3AA=; b=hzOE61EjxFgv5qBaDUS5o3J1ZmAotwGGLnFH2F8wAywpoboJMlkWvdMWYRkZthrv6s xr3Qes3oLcLboufFlZTA7SOAILoq5C4pWAxpMzg39n/hNG3GrrAyVtydspTB8IEfBFSe Z5fE2YRBqUB3xnhGH2SeacKz7KuJzDC22CpmzOg8eihZvzgYFN0N8dZUQwFpqPiTZizw fn56YTWIXhUaQVVYcxqIn7jNSRS2iWn4yUTAzJi7cai7pc4lp35zl+tA4I/1gnQctoUu GuD6HUxZVOqOE9239ugwAJ69bsEWUvlRXVktatYOrML+0gj7qx7L1jzWSvwHzgMoSRCu PD/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=UEbP1zqh; 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 jz6-20020a170903430600b001bb02e4b739si1628795plb.475.2023.07.27.12.29.37; Thu, 27 Jul 2023 12:30:14 -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=UEbP1zqh; 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 S231372AbjG0S4G (ORCPT + 99 others); Thu, 27 Jul 2023 14:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjG0S4E (ORCPT ); Thu, 27 Jul 2023 14:56:04 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F33B319A7 for ; Thu, 27 Jul 2023 11:56:02 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3177163aa97so1347878f8f.0 for ; Thu, 27 Jul 2023 11:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1690484161; x=1691088961; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5FhI2SLAGzFPgM0XDlLYh3qjUrSBQmA+KXnizzmLufc=; b=UEbP1zqhCFEiTaUL5idLu7vKPg1UFl76YwNFzxk+gTjDjuwDufCyOxWIareE7LpI7M hQcy4WocH73NHpscnoUE2uao5LPwfT3On28WKOhhuLLnmQgK8lo4dVzqOTGjTi33ALg6 c0/7py79DrKXQQpO35r81d4LEai/ijN+47oqcZVg/oTep4drF+adrfWVrIMhYBBmOwwW qxvwQ4vQ6q+8AyNVn3Mh2geRJmizY2Xeum0eYyg0CTL4wZVWTEVTg/SJ7yek42Ifpb1Q vGQsJgw6HlMmZSxtyxv3qNun490/7QiQpcxjaTP1yWWjQtpMhCI8ZcM2CMV4nQfYfzYr FQ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690484161; x=1691088961; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5FhI2SLAGzFPgM0XDlLYh3qjUrSBQmA+KXnizzmLufc=; b=F9MDluOsvctErR0qf+su0t50kcTE35RDzUMBW9JhWnlH7o759w5m1OBUQS7kpzsNXZ gFTY4nz1gwaJ/ugdySBEcZfcK5BfuaNWP5rBjf0of8JodPlA2SYI70PK71vuSwOWCzL8 vwHlfXmUx+RUrj/a4aFKQMhi3kpyaJKk8VaO8AOFWgyavc1XeI5Xco80kOfxiEsKSJUo 3X52kzbw3uYGpBrZ82l/elwKPa5LnwLaOTh1FwhT8RcDCpScz3mksLdEiKcxjjbEhk/d 73yPFFzgYtRJHmMbIq0kBu3pJyuIzXBUXwia6gc/TRSXIGv+7bkMLc05tBU/c8oenV3i V5Jw== X-Gm-Message-State: ABy/qLZtHST10gdd/asdzos9gNOfgscHzz694QQsHVx6phHRdEIpRH1K hLmLpTQjDBL9DNZIiSK/Ep/bUg== X-Received: by 2002:a05:6000:11cc:b0:317:7af4:5297 with SMTP id i12-20020a05600011cc00b003177af45297mr4780wrx.62.1690484161377; Thu, 27 Jul 2023 11:56:01 -0700 (PDT) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id u13-20020a5d514d000000b003172510d19dsm2754302wrt.73.2023.07.27.11.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 11:56:00 -0700 (PDT) From: Alexandre Ghiti To: Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra , Mayuresh Chitale , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH v2 0/4] riscv: tlb flush improvements Date: Thu, 27 Jul 2023 20:55:49 +0200 Message-Id: <20230727185553.980262-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772603272728212269 X-GMAIL-MSGID: 1772603272728212269 This series optimizes the tlb flushes on riscv which used to simply flush the whole tlb whatever the size of the range to flush or the size of the stride. Patch 3 introduces a threshold that is microarchitecture specific and will very likely be modified by vendors, not sure though which mechanism we'll use to do that (dt? alternatives? vendor initialization code?). Next steps would be to implement: - svinval extension as Mayuresh did here [1] - BATCHED_UNMAP_TLB_FLUSH (I'll wait for arm64 patchset to land) - MMU_GATHER_RCU_TABLE_FREE - MMU_GATHER_MERGE_VMAS Any other idea welcome. [1] https://lore.kernel.org/linux-riscv/20230623123849.1425805-1-mchitale@ventanamicro.com/ Changes in v2: - Make static tlb_flush_all_threshold, we'll figure out later how to override this value on a vendor basis, as suggested by Conor and Palmer - Fix nommu build, as reported by Conor Alexandre Ghiti (4): riscv: Improve flush_tlb() riscv: Improve flush_tlb_range() for hugetlb pages riscv: Make __flush_tlb_range() loop over pte instead of flushing the whole tlb riscv: Improve flush_tlb_kernel_range() arch/riscv/include/asm/tlb.h | 8 ++- arch/riscv/include/asm/tlbflush.h | 12 ++-- arch/riscv/mm/tlbflush.c | 93 +++++++++++++++++++++++++++---- 3 files changed, 96 insertions(+), 17 deletions(-)