Message ID | 20231122010815.3545294-8-samuel.holland@sifive.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 F0166C61D9A for <linux-mm@archiver.kernel.org>; Wed, 22 Nov 2023 01:08:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D6226B052C; Tue, 21 Nov 2023 20:08:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35DF76B052E; Tue, 21 Nov 2023 20:08:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 162146B052F; Tue, 21 Nov 2023 20:08:29 -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 F073A6B052C for <linux-mm@kvack.org>; Tue, 21 Nov 2023 20:08:28 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CADD7809C2 for <linux-mm@kvack.org>; Wed, 22 Nov 2023 01:08:28 +0000 (UTC) X-FDA: 81483804696.29.717E31E Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf25.hostedemail.com (Postfix) with ESMTP id EC97BA0019 for <linux-mm@kvack.org>; Wed, 22 Nov 2023 01:08:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=GwSehgox; spf=pass (imf25.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700615307; 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=MROdnZxFJAn7brM6ye/jIKPJcvVCbRqlgsjUSxtP0PY=; b=tKzrruAdoyc0xLX9ZKIgM8y+uprCsE9dl9cxX2XlYt/w4uLVzdseNdPjk47Gmg1h1k/BBg VwzWzlu5fEnwMRU9UcNGnUvBhhDILxiQtBWEObBWv1US41NToqjkz5Kzm4pyR/BdeDJbEO PBC8uVqitUeiM4H+5QAQ+qoMFyYOdok= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700615307; a=rsa-sha256; cv=none; b=4E3BHRGGvUptW/knf+2UgmHjJY2xHQ+ztBze416g9pRv+pHBk0bExdpiPfGVpDwqcGeNiQ BqrUtd19zDlARNh9mZJvsUkZ5jYPk5xfygBG/cFD2MydtJKwQJG57WghdRUerozwKdz6nl tj7Ef2IJ1nNUNd/BXiRnOB0ncYCxZHc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=GwSehgox; spf=pass (imf25.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6be1bc5aa1cso6299850b3a.3 for <linux-mm@kvack.org>; Tue, 21 Nov 2023 17:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700615306; x=1701220106; darn=kvack.org; 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=MROdnZxFJAn7brM6ye/jIKPJcvVCbRqlgsjUSxtP0PY=; b=GwSehgoxUoyJ0r8MANoeR9L8D36WIS1kkWTLiYaT2Zo78X12kPIb5vIqHzYTr2yaxm mv5giWVyoiJBhnhJr63cFxHsM9Jlo2QH+BHEDcJ58hnQLbCXuWu+ICj3slAFR7043HBp fragPRR+pvfxge80gPMjVJ+c0mZBhSKqRQu+YQt1h1rO6XbLxTb4pEg9g9mtp1ov2o9X 4KimVQOJXlpe5Dxb1d8X+p7y8H+/cinhdK5gVAt5ISRVzeRTqKPVJHEa9mqJvvEgtPaT +Q7dwhjYU9sNf7Gxp/np3LEqsuQK3lKJ3QMpnUUfADCpyjcMfbMjOFa1nloOL/lgGfjh tpfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700615306; x=1701220106; 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=MROdnZxFJAn7brM6ye/jIKPJcvVCbRqlgsjUSxtP0PY=; b=tU0YGf316BkJjqzYm/Pwbod8PheWnkfcO5wzI8KAYCR58T1f3AsmjYRPii+wx7YRMJ GZ29PVUHCiHd+sqRHTNFCPm357/e7rklE+pZ22SuXjouXJsclLM9GE6zStZs30vfxniG 8jVES0kwGJxwDbZIE/HvGFzvWvrMmyT8G0lnoXaZdnLVdtZ/k2SQcpwgYI3AiMgwLTWL RVWUgDH6fZCLZMWSiVKn7lcLS5PzRYhYtJIZZLzuRCX4ikrO4DLmj1c/sFAcHpLIDEJ5 Lsu7JZdM1U2d9WS9qRu6JrrJSw+2u7w33UEOykVSccNAtZ1xPALdB7HJcdSg5Uv7JDVN fG5A== X-Gm-Message-State: AOJu0Yyk82egodoTaHJfaw7fi6D+/SdlReuo1XW9v+6qj12OUj4Xsgnd c2Na+f7HvBobPglqWeqM/dac9A== X-Google-Smtp-Source: AGHT+IFVZu+XEimHfZXOsjvtj11LrkIBAYyBlYwN/UfpJ7aqLGYZgxb4tCN+mMPanboANiNPoJtK3w== X-Received: by 2002:a05:6a00:b54:b0:6cb:a1fe:5217 with SMTP id p20-20020a056a000b5400b006cba1fe5217mr1041980pfo.16.1700615306009; Tue, 21 Nov 2023 17:08:26 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id bn5-20020a056a00324500b006be047268d5sm8713961pfb.174.2023.11.21.17.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 17:08:25 -0800 (PST) From: Samuel Holland <samuel.holland@sifive.com> To: Palmer Dabbelt <palmer@dabbelt.com>, linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti <alexghiti@rivosinc.com>, Samuel Holland <samuel.holland@sifive.com> Subject: [PATCH v3 7/8] riscv: mm: Preserve global TLB entries when switching contexts Date: Tue, 21 Nov 2023 17:07:18 -0800 Message-ID: <20231122010815.3545294-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122010815.3545294-1-samuel.holland@sifive.com> References: <20231122010815.3545294-1-samuel.holland@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EC97BA0019 X-Rspam-User: X-Stat-Signature: 5n93dk14qzdgjg5czwcw4yo1nrgdagrz X-Rspamd-Server: rspam03 X-HE-Tag: 1700615306-293805 X-HE-Meta: U2FsdGVkX18pR/kD+N53d0ONDMaKyhxIiOp2R1B8rgg3bhTyl4qym4VCfYoEXMsxmzghc3r8P0tvwtIRE0oNg6XZt6HS0Elk6kXS1e/7XpPuiNrdkvjaQcZSN5bADY3v9aZgPZOZvhg+335m+cGgmnlNpGcytcPEl3EYD4CXHPGAKn2zEX4Cv3tJ8bRptr4UTfSeLxXqYDv5j6HgmAiirBDXRb/cyAV49/kYC+HKbpyOh2AIEDVjKeJCxUAxoNfYxa3Ezl8mJ2eOzaDGtlLpsLp7PQTOuT3qI9IL0GJUmZF3BitpoST81HfC20GQlwDqnNzm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ests=bogofilter, spamicity=0.000030, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
riscv: ASID-related and UP-related TLB flush enhancements
|
expand
|
diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c index 43a8bc2d5af4..3ca9b653df7d 100644 --- a/arch/riscv/mm/context.c +++ b/arch/riscv/mm/context.c @@ -200,7 +200,7 @@ static void set_mm_noasid(struct mm_struct *mm) { /* Switch the page table and blindly nuke entire local TLB */ csr_write(CSR_SATP, virt_to_pfn(mm->pgd) | satp_mode); - local_flush_tlb_all(); + local_flush_tlb_all_asid(0); } static inline void set_mm(struct mm_struct *prev,
If the CPU does not support multiple ASIDs, all MM contexts use ASID 0. In this case, it is still beneficial to flush the TLB by ASID, as the single-ASID variant of the sfence.vma instruction preserves TLB entries for global (kernel) pages. This optimization is recommended by the RISC-V privileged specification: If the implementation does not provide ASIDs, or software chooses to always use ASID 0, then after every satp write, software should execute SFENCE.VMA with rs1=x0. In the common case that no global translations have been modified, rs2 should be set to a register other than x0 but which contains the value zero, so that global translations are not flushed. It is not possible to apply this optimization when using the ASID allocator, because that code must flush the TLB for all ASIDs at once when incrementing the version number. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> --- (no changes since v1) arch/riscv/mm/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)