From patchwork Thu Feb 29 23:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13577718 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 7C3BFC54E49 for ; Thu, 29 Feb 2024 23:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2219A940009; Thu, 29 Feb 2024 18:22:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 180C2940007; Thu, 29 Feb 2024 18:22:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F17D8940009; Thu, 29 Feb 2024 18:22: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 DA69C940007 for ; Thu, 29 Feb 2024 18:22:29 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BD1D11A0140 for ; Thu, 29 Feb 2024 23:22:29 +0000 (UTC) X-FDA: 81846417618.23.D24B442 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf27.hostedemail.com (Postfix) with ESMTP id DCDDE40020 for ; Thu, 29 Feb 2024 23:22:27 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=kS8t+75j; spf=pass (imf27.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.169 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=1709248947; 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=cJvv9umwOkXOwc0iOvLk+NQYD7Mm5kACvwQaK1YGZP0=; b=1u3oFHauuxjXQo5c6td7E3RIWTEAdcKbzbG4mitYf8jL6ZcT2TpT55EEpkAq6q/PCHT9ux 9d9zugNLI7qG5c2Gz/luB4gsevOU3/t8L5XJ1k8rHNhh13Wldkp2262NM38qHIzvAkoXMS SPMHlsFNBGRnBYVB07cL3QiWdsMor48= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709248947; a=rsa-sha256; cv=none; b=EfDwDbOIbHYrHTPq8B8AbGrTTHgTGqWgtL4T1hXuB590F+MEZ1dfkv+sze6uTCdTnnqtM+ YBSPUmA+jew5K5fuLWYwHeEkzozqZzo7ljL43VrmO8s297C4mQ4A2/3c6r+hLBB821ApYO rJyMKISVOwzncI4XZBUnEoEIvS8CXRQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=sifive.com header.s=google header.b=kS8t+75j; spf=pass (imf27.hostedemail.com: domain of samuel.holland@sifive.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=samuel.holland@sifive.com; dmarc=pass (policy=reject) header.from=sifive.com Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e581ba25e1so1204950b3a.1 for ; Thu, 29 Feb 2024 15:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1709248947; x=1709853747; 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=cJvv9umwOkXOwc0iOvLk+NQYD7Mm5kACvwQaK1YGZP0=; b=kS8t+75je4RPkBs5zXOxP9gfTb4B3HKQuSdYR8QnSdUHBfUssoSlmaGN9DoDEt4n97 f10lX39RZdmcuLdSwP1OdE7py2APtCMEsvUV1BI558Mjx4FL6UpQZHM4/O7Ujp83csKL FTVgz/E6KhA+KjYNEt4JqyxHt3Tz7R7ZMESAM67AWEXXHSLh3xQ+gGO0feLuYjjTF6o9 fWGtKe5V5c86Fbreezzcuwb/L3/exI3FOpTncdVKI4L6ybcCyqdf7hCJSUH79XuU8K75 fau2JRmMzQtGz1ioas9aW6569Tf5miGsRYbGvuChg/EicNiSVls4ZcEVvR73ml+gGyDf vUaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709248947; x=1709853747; 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=cJvv9umwOkXOwc0iOvLk+NQYD7Mm5kACvwQaK1YGZP0=; b=FuGZnNGxdQLkKMx1Vn9vCmqaDav9xMFXl6iH/fW/6nhvKUWqwJRaJNZhno0/JxEyf8 AOJKteNXtlkNLu6qsJeWob1hlL6uBxv5AakzdvXjVO9jwS3y1m/Iz8F2SXDMkXtaNPm7 Tknx+7gNPCcm4se2HKnvgDteXAEHbeTex6oEFA68ElzM4eqjzToTcN3dXk79ktuDKPMP DorXh6soBW3WeTiFTeA4ctRIolUBTTZn+IBFcJtiBwfep0cxrJRp6hmC1b28MrawKrGL O0VrUpNL9C/8wUYwYFxnUS1cBi3ZYcLYFwv1ENo1BSaG7kJO/8Sc4YIddlaxQEslyaBk sfHw== X-Forwarded-Encrypted: i=1; AJvYcCXMMW7uqdAuozNMM09OI172Rbm7KVw3ZwPqy0iC/zJjZvwD9/1r8gMNSENKqQytUOuBSZuk1OzjE+Cxrz7pLAqR3vA= X-Gm-Message-State: AOJu0YzZcJ03eTWQQjbxR4TrfzyZTJfkVoKGxmI9RhxlhTQRIrYjlD3m 0IYzkhT2SmTluu7Y4vCugDpMLw8GuwHb5zNNFQOIafI27FtCK/6NCKPZjwBLVrQ= X-Google-Smtp-Source: AGHT+IG000bMn11OdL3LH1zGovTy9Qg+UUgYE8CMrW4h6bNv2nzitQBp1dzsEHx4shrcmNE8zaAVpw== X-Received: by 2002:a05:6a00:27a3:b0:6e5:3dea:bf51 with SMTP id bd35-20020a056a0027a300b006e53deabf51mr562992pfb.7.1709248946831; Thu, 29 Feb 2024 15:22:26 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id c6-20020aa78806000000b006e55aa75d6csm1779719pfo.122.2024.02.29.15.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 15:22:26 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti , Jisheng Zhang , Yunhui Cui , Samuel Holland Subject: [PATCH v5 13/13] riscv: mm: Always use an ASID to flush mm contexts Date: Thu, 29 Feb 2024 15:21:54 -0800 Message-ID: <20240229232211.161961-14-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240229232211.161961-1-samuel.holland@sifive.com> References: <20240229232211.161961-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-Stat-Signature: a35zz3z1ppqyto7nxkpbxe1cn6potrkg X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DCDDE40020 X-Rspam-User: X-HE-Tag: 1709248947-950160 X-HE-Meta: U2FsdGVkX1/jE03F0ExXoRONqr6Jk/K0OgEQ0S92rMsaCrB9zxQKcQ9EURIZHpI9cuZac7TsxVyjTvw7KsVYr0qZ8M6RSdmTPChMftIlXnAbuEYQilqXExOmn25O/rT0hxz2XyikScFZdp31Q2PRDa/7eDVR99wyRDEnwwirUALBlule8XPFKvWSzmI6pLzgYywa0AqzM27zd094H/QC2B0ubp+dUMrWIN+fLHRYx1bxzbm2zrviWREc9MsTq2+tDLhadL77IpNaZczVSEXII5Zqc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pHDt31MlTbS10gbsOgijhoFiBgM/vd6vUQyiqLcsqHqK+LK1CtrbebjxdjVMgn4ruLVwdj4hWS/zGpaLbaE3QfPt85iRFd5LoT4iSo2rkCw5I8Xw13YYW3fXssl4aK5o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000234, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Even if multiple ASIDs are not supported, using the single-ASID variant of the sfence.vma instruction preserves TLB entries for global (kernel) pages. So it is always more efficient to use the single-ASID code path. Reviewed-by: Alexandre Ghiti Signed-off-by: Samuel Holland --- Changes in v5: - Leave use_asid_allocator declared in asm/mmu_context.h Changes in v4: - There is now only one copy of __flush_tlb_range() Changes in v2: - Update both copies of __flush_tlb_range() arch/riscv/mm/tlbflush.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c index e194e14e5b2b..5b473588a985 100644 --- a/arch/riscv/mm/tlbflush.c +++ b/arch/riscv/mm/tlbflush.c @@ -108,8 +108,7 @@ static void __flush_tlb_range(struct cpumask *cmask, unsigned long asid, static inline unsigned long get_mm_asid(struct mm_struct *mm) { - return static_branch_unlikely(&use_asid_allocator) ? - cntx2asid(atomic_long_read(&mm->context.id)) : FLUSH_TLB_NO_ASID; + return cntx2asid(atomic_long_read(&mm->context.id)); } void flush_tlb_mm(struct mm_struct *mm)