From patchwork Thu Dec 28 08:46:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13505704 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 15254C4706F for ; Thu, 28 Dec 2023 08:59:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A4EC6B00A4; Thu, 28 Dec 2023 03:59:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4304C6B00A6; Thu, 28 Dec 2023 03:59:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31C876B00A5; Thu, 28 Dec 2023 03:59:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1B81C6B00A3 for ; Thu, 28 Dec 2023 03:59:33 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F0566160844 for ; Thu, 28 Dec 2023 08:59:32 +0000 (UTC) X-FDA: 81615628584.03.DE06240 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 6A39D40008 for ; Thu, 28 Dec 2023 08:59:31 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TKBsmvO8; spf=pass (imf04.hostedemail.com: domain of jszhang@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jszhang@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703753971; a=rsa-sha256; cv=none; b=EMEmJRWmA/LWTxA5HX4eTnBKpdP6sE/r5sKuTq9Xv4zZk53iFVM9cGzmgXitbYTvvlY9rC /EruhoL7tEI58bgTBTVShZX0XSCgbK9gbFYEGNvs+trHdcGDXMu6qkWu9G1GGF8PHjAkDu HFeQlvjK02PvIOY0TFnRZaAgPO157dw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TKBsmvO8; spf=pass (imf04.hostedemail.com: domain of jszhang@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jszhang@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703753971; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=U0bHBCfybk8M/ty/5LuxJpVChy9zxALoGJGRJoUUtYY=; b=dpk1zfY8/XtpxsFzWXTUt/9TB+bU5jDyGQpSk1yXyFclZ2zAfVPKsHbHF3ai6qLVR5Zj/t 5eEjBcP1tii6PubEabktUSKeEZ5lUWvBk2JmlFr25K1nsnGyaDR2xsdrn5Q9JpvQUqdjDp ELXWOc+qs+b7rpMiGnF8BCyzYFPtutU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4F39E60FE6; Thu, 28 Dec 2023 08:59:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5389DC433CC; Thu, 28 Dec 2023 08:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703753970; bh=4x9t1f04s06EEvjvtQ7yC2/ljPKJqNDBrcj2L/hT3Js=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKBsmvO8700bopUsWROGXLmoCWFXsTW+dDVnNGSxOkaL/USi53RKl8TdsixW0+meq ZCWxQdbp33ikg/G9ezCtq7NkctrZnj90/OzQ0n9iUxG+YKDW4DQ0nPcXFY42wiBv+r 997dRhgKccetlwPkyjqAZY+f5mx70kEYFtXj+CoiB8mr5EJbZvQA7ejpm/TS62Kx8Z MVCzbTzHlBLytfAxGrORGDpTnrYATlbt8PPwaCWGIg2WfXt/VlliMYXrTExd8VnHSR LxHkWdaNYJGBiXawHPjLTvQ6a2cSRLkXc9Y/wtpnv3MN3QHCLVBpveSUN4P0ShLMkB BBgaja1UR4WBA== From: Jisheng Zhang To: Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra , Catalin Marinas , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 2/2] riscv: tlb: avoid tlb flushing if fullmm == 1 Date: Thu, 28 Dec 2023 16:46:42 +0800 Message-Id: <20231228084642.1765-3-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20231228084642.1765-1-jszhang@kernel.org> References: <20231228084642.1765-1-jszhang@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6A39D40008 X-Stat-Signature: op746j165zrwdq8bqaaijx4x15c7qmwb X-Rspam-User: X-HE-Tag: 1703753971-836905 X-HE-Meta: U2FsdGVkX1/TgNKB3XuOUezxiL8a79hCivQHeVVYBZ6sLfHtLYmsJfCKdi1jq6vHNIF98NVord2Tx9iOoFnCGkmSFgZIYkC+ZUZW7IzKwS0QJEDd4wboD/i61jipGd6IhlgVsOVJsqGAh7Rzso0jRCAZCZbczAHxz6QE6OjkTfyxTGgv0gMueUbVwjpe+zUpDRsLBMjPk+QT1s+mFHpdF1ufhoL0Igb6PBy9BNYtAsu3yhCIajVqoBf9/vsT6RJNmX4rgb28VtX5Nh8VSzLMIZ6us0lSmurYx6JwWbVPPpWvob6sIR5ScNF3VzLhZgsm3WG/yZm8odJBe4ZMYQBhwPUMfLj5KDKGo2r/EdQjM4196dP7KXXO18or6B9kCDuzqt4Bv+pnFSa4XOMaFSPsTbhbjG/umjSmTSkvu/JbBsN7mc/kaACehOjlu0J/kOEJlPQbMVRT03R8k8tZpnmxaZF8h6yC78XU2XvXv55XaP+9Q2sbrii5x39oft8i901PSTgLK8sQLfKUJlU9DSkFvM+zXu2rUiMvS0xV2ovlt61szkh3mtlKTX0nC8g+eygcvzV6BW+hNetXhvBF/3zxbEkwPIMYdbQNc/7B1b1Pa/InH6gyTK1ixa0ocoR6nSccEHZ+hzLkLDvvOIcigUNAALahPeWfOYSE66TUAwv3Iivjbk72Dwfi1GP/5kZ/vv8JwORf3uw4VSZE99d7klXhZtzvvTdNH6DZXq+yS14IIyP4zYJAya6NgplggwyB3eUA2fPNK15P/ZUx22WYTKOxgQPQMNTZfbX4ngD4c3/pEe5KeYq9OG7ndyVZTj3aamrA0IrDFWYbkWVhaXQQIW4LiRv/4O1ykBMxBtISefZ9ynuwb/MTOVYgmVlY0GUJj7H59NkDSwVRe/atnxKVg7BUl28pFAgwVi6vVRT5XYcdpxYs2bu4iXfIfzyPjzuRXr/QwjjCzrbeBQR1dBMAmNc D7ssb6AG UiXRzYkLTv3EVsXbktPV1B8MCnQoixdNmeXNVf6pMLHXzsnhduv4kLwukDA2hnjzjqGsWAdur5pYbFebevR+H4vJy9js8TRSHTczKA7WNUz1OZh9/JbqRdMQpxBsEUjwGQIcsmoue1VQ8lB9Dhyh+bg3mJ1SGG2uoWrzpmGGyymsblJel/m51fV/gWuJGtektI0YiiZHhy8bK9fpBJYMX86GPDodqjCNqR16ovV+CgSMx7bl8G2kZY4wipw== 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: The mmu_gather code sets fullmm=1 when tearing down the entire address space for an mm_struct on exit or execve. So if the underlying platform supports ASID, the tlb flushing can be avoided because the ASID allocator will never re-allocate a dirty ASID. Use the performance of Process creation in unixbench on T-HEAD TH1520 platform is improved by about 4%. Signed-off-by: Jisheng Zhang Reviewed-by: Alexandre Ghiti --- arch/riscv/include/asm/tlb.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/tlb.h b/arch/riscv/include/asm/tlb.h index 1eb5682b2af6..35f3c214332e 100644 --- a/arch/riscv/include/asm/tlb.h +++ b/arch/riscv/include/asm/tlb.h @@ -12,10 +12,19 @@ static void tlb_flush(struct mmu_gather *tlb); #define tlb_flush tlb_flush #include +#include static inline void tlb_flush(struct mmu_gather *tlb) { #ifdef CONFIG_MMU + /* + * If ASID is supported, the ASID allocator will either invalidate the + * ASID or mark it as used. So we can avoid TLB invalidation when + * pulling down a full mm. + */ + if (static_branch_likely(&use_asid_allocator) && tlb->fullmm) + return; + if (tlb->fullmm || tlb->need_flush_all) flush_tlb_mm(tlb->mm); else