Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7790827rdb; Thu, 4 Jan 2024 07:51:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjrqMHSEBaZz7204+yc3gDFJUCJHAFi/5u51YxhQCW7vz8t/RkSMGKxnuwdtHjYWcy1SCP X-Received: by 2002:a05:6214:2b0e:b0:67f:44b0:b997 with SMTP id jx14-20020a0562142b0e00b0067f44b0b997mr908724qvb.52.1704383459813; Thu, 04 Jan 2024 07:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704383459; cv=none; d=google.com; s=arc-20160816; b=gU/BL1vmK0LSsfFs5Ktlu/pRl0Rc3OqMqB0aT75tdGOutf4TQb41Saw7qE92nnExcV vnrMlQTRCfXzKr4tujCgspAGJ4bHkc4FDoddMEgEyh7IYSv0Z9bcMIF4Y0/s1nzFK8TD 12A0dkRKJP/gGsIJ7hQP7FMim6ckXtO+UTwMtZcqaxarkQWx3fBlVDXhP4dG7bLFD8Ji kgeNt4CyJTPylcHz+lVvLqx9nTEotioozcgjEM5DTRQ61rqjKqja6KfqCF5a4Yw8LHZh z+1kc1CezckxM1HtsN9hVi6c20hUtjJCH9K9yeJdpbY3K5ceWk+BymyTa3tjObTAh4Ij zZTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=KmpM6mBQQhHv/gSZR2zG7ER6CNMKk8ullD4Z85B1/5k=; fh=gTcM6/KWjw8syMHr9ZShAxtpToSuB9qBohNO1oFyylY=; b=mgvmRuAOIGMJTEw68fyfJj3chsITjnw7aOkkFiwE5BrOh91BdCUJqlg8gP7UuWczdW 9ij6i24MzLVwAiPHSahkMaDR2pKVZeXFG6LqqtVG/YyAOwZJvp03pv/FWZunuc46sD1/ WnlcgHIN9zoCsG0a/rc9Zjoe78PYfpPwqpkxfdVDJaSfk7Lqtl9Cl+TJiT2fe0c2Gx4J YA5o/tuhxrFTnIcj1U+Zynzl4chW3UiG4M8DZxiBSfihKATKDkUNfpUgDQ2w8cDcXonX JhrAfCX1KPppKHbbwP+MAAoMYlwW9tRGke9Q3jZlk7UYW4LZEtYC/SKAJpQJRfliPK0/ EEVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=W+zTMMgq; spf=pass (google.com: domain of linux-kernel+bounces-16885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r1-20020a0c8d01000000b0067f5276bd62si8121865qvb.309.2024.01.04.07.50.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 07:50:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=W+zTMMgq; spf=pass (google.com: domain of linux-kernel+bounces-16885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 908561C21265 for ; Thu, 4 Jan 2024 15:50:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3DC6249FC; Thu, 4 Jan 2024 15:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="W+zTMMgq" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCC50249E7 for ; Thu, 4 Jan 2024 15:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7ba9f1cfe94so43936839f.1 for ; Thu, 04 Jan 2024 07:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1704383449; x=1704988249; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KmpM6mBQQhHv/gSZR2zG7ER6CNMKk8ullD4Z85B1/5k=; b=W+zTMMgqAA8fj3eqHcMB/tTfn7ws7Wn+JQLoCYmDmAvjS15nnYnPp7g+bbHQ/rX6in ChobwW1kbZoYs3nWCdF1AWXPGHGdCObFIPzhsEXSIQYQRbopDNrYGWAdxN3o93lzT3D4 n5+UvCX21GmyIJ89ezrqec08pEaL94rLRL4XEVCASAwVXKAihVnVFZ1s92otruFi6i4d S9MkRDyJybpuWBzHVi6S7xbv5VZzrslx0Z646aDPVzA4AsV6xq8LRzTHITm6b4kykxgt NxEAlkV/siv5kPOSOSSDvKhVL3jlJi+TVmyFyUSjwFpK82C0vgB3pVyr1Kge4+b34mbZ tjew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704383449; x=1704988249; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KmpM6mBQQhHv/gSZR2zG7ER6CNMKk8ullD4Z85B1/5k=; b=LMSlQQ2pij6yLYIMspgtq3WlpsuDxuIMXGbIaZ8A++AWhDGdo68JPtT0CBORRSjosj CJA1zSUC4wxgY5U/7711qQeGcWgA8GA7rh8mQU2zbgqJdbWbbJ6kH+xdlnljF1pHjjbR aFPptrxRH83unZDQZXBf+f6rsMWONiZQUGJd2N5yb2GwBOWr3WU5pUw0hQmkfrhv3SXk 21qJY02swPCc2lb/Hg3n8foc1TZeM6CU8vAhXUs7vkex/ZT+4geT5N2ECE1A43S0hLCp GYwHFoESVDkpdKm4l9ilJ5ThWBc7Nlc1Pg7LxI4059GPauGSk6RUQ5qXc+O5axj/PoT1 PKIg== X-Gm-Message-State: AOJu0YyrqLBD/VTsLKha1i/ZiRkp6eeRPn8rJWZcOQPTuRSFenwFtH6P gUL368lNMLOdjsrbLToAJr7rxrFBobCDUg== X-Received: by 2002:a05:6e02:1aa5:b0:35f:a27c:e76a with SMTP id l5-20020a056e021aa500b0035fa27ce76amr474841ilv.9.1704383448854; Thu, 04 Jan 2024 07:50:48 -0800 (PST) Received: from ?IPV6:2605:a601:adae:4500:b86c:e734:b34:45c6? ([2605:a601:adae:4500:b86c:e734:b34:45c6]) by smtp.gmail.com with ESMTPSA id ep24-20020a0566384e1800b0046696ea033dsm7981361jab.146.2024.01.04.07.50.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Jan 2024 07:50:48 -0800 (PST) Message-ID: Date: Thu, 4 Jan 2024 09:50:48 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 12/12] riscv: mm: Always use an ASID to flush mm contexts Content-Language: en-US To: Jisheng Zhang Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexandre Ghiti References: <20240102220134.3229156-1-samuel.holland@sifive.com> <20240102220134.3229156-13-samuel.holland@sifive.com> From: Samuel Holland In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024-01-03 9:02 AM, Jisheng Zhang wrote: > On Tue, Jan 02, 2024 at 02:00:49PM -0800, Samuel Holland wrote: >> 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. >> >> Signed-off-by: Samuel Holland >> --- >> >> 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/include/asm/mmu_context.h | 2 -- >> arch/riscv/mm/context.c | 3 +-- >> arch/riscv/mm/tlbflush.c | 3 +-- >> 3 files changed, 2 insertions(+), 6 deletions(-) >> >> diff --git a/arch/riscv/include/asm/mmu_context.h b/arch/riscv/include/asm/mmu_context.h >> index 7030837adc1a..b0659413a080 100644 >> --- a/arch/riscv/include/asm/mmu_context.h >> +++ b/arch/riscv/include/asm/mmu_context.h >> @@ -33,8 +33,6 @@ static inline int init_new_context(struct task_struct *tsk, >> return 0; >> } >> >> -DECLARE_STATIC_KEY_FALSE(use_asid_allocator); >> - >> #include >> >> #endif /* _ASM_RISCV_MMU_CONTEXT_H */ >> diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c >> index 3ca9b653df7d..20057085ab8a 100644 >> --- a/arch/riscv/mm/context.c >> +++ b/arch/riscv/mm/context.c >> @@ -18,8 +18,7 @@ >> >> #ifdef CONFIG_MMU >> >> -DEFINE_STATIC_KEY_FALSE(use_asid_allocator); >> - >> +static DEFINE_STATIC_KEY_FALSE(use_asid_allocator); > > One of my optimization "riscv: tlb: avoid tlb flushing if fullmm == 1" > will make use of use_asid_allocator, so could we remove this modification? Yes, I can leave the global declaration alone for now. >> static unsigned long num_asids; >> >> static atomic_long_t current_version; >> diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c >> index 5ec621545c69..39d80f56d292 100644 >> --- a/arch/riscv/mm/tlbflush.c >> +++ b/arch/riscv/mm/tlbflush.c >> @@ -84,8 +84,7 @@ static void __flush_tlb_range(struct mm_struct *mm, unsigned long start, >> if (cpumask_empty(cmask)) >> return; >> >> - if (static_branch_unlikely(&use_asid_allocator)) >> - asid = cntx2asid(atomic_long_read(&mm->context.id)); >> + asid = cntx2asid(atomic_long_read(&mm->context.id)); >> } else { >> cmask = cpu_online_mask; >> } >> -- >> 2.42.0 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv