Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5213556rdb; Sat, 30 Dec 2023 10:26:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXL/5nU025HisSmHaV72BQamykj4nImdGxdYZF0x64nWxhFktH23+ShK+NDnbW9v+eBPQI X-Received: by 2002:a05:6871:3a24:b0:204:dfb4:375b with SMTP id pu36-20020a0568713a2400b00204dfb4375bmr7194104oac.55.1703960797317; Sat, 30 Dec 2023 10:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703960797; cv=none; d=google.com; s=arc-20160816; b=xpbx0abXF+ddzOcIOHsKAn8YKe5iVsOsoTF88KkNtGSE97vRWwlcXuUITbOZkyHGkI LfLbtXP3V/83ScM7pcAp7itOVVQlqtJhv/S+qr9XAKhYz4sWrg6ObXG9DxJUTxNa6cgN FY7TrLERCfe6lZfa3bFXzBjYWr+7/AIJWvS+vQNldnnCm7zcDsEI4J9vmZAlOMBgZySS vSSLVFPpHFTVlYhukxrZunUbehB+iV7q3hd97QJUZ5kv0bRRxtjUavAWW7hTOQfG1C4H 9hBZU7QWELB7gae62esuXvmk/Q2esdkbnoKJMHvgXoH+c99fhzHZE2lroeWVuUnPW+fc BaBQ== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=3KqePvpy2xe4tH0TQP9AAhj/l0vxDxMwKUdMSu5K8/o=; fh=MQKPYtHlTvV2Ezf6FW4PZjyYYu801+bDilc8hqtMQ/s=; b=Wob4HeIMk47AbDzxWJnK++3wrCsJrWaDEKDXzxfaRCNWcYqll/8DnKAJh+j4CkjvIi 4EbJmHoCj2nYUUou7mTSx1KFMDdis8LCGM85EsUTHgo4L4zsOWZkZCW/CwiSVhnCdGDi RgGrgDa+Q3TEgBL9gxzOSQ1bJb1uxOVFZAOnmGuO4wnf40uhVtwbc18zjw0FimXUZB9d IUDZs/q4N7onm6PASZqBUYMggmlmmaA0NKUnOEHW3BfC7TdI9FPKS5OZkMbcXIetZv6i MLojuCwfrCiPd2bewljs0X9cGJkuS9rzaiGdAEr5KYogmDBQ5WhzhiAgy7JUAWemk+jG kWnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13569-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13569-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q81-20020a632a54000000b005cdfe08f41asi13148441pgq.635.2023.12.30.10.26.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 10:26:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13569-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13569-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13569-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EED0C283C04 for ; Sat, 30 Dec 2023 18:26:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D9F5BE4B; Sat, 30 Dec 2023 18:26:30 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA1A4BA33; Sat, 30 Dec 2023 18:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 56F6B240003; Sat, 30 Dec 2023 18:26:12 +0000 (UTC) Message-ID: Date: Sat, 30 Dec 2023 19:26:11 +0100 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 2/2] riscv: tlb: avoid tlb flushing if fullmm == 1 To: Jisheng Zhang , 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 References: <20231228084642.1765-1-jszhang@kernel.org> <20231228084642.1765-3-jszhang@kernel.org> Content-Language: en-US From: Alexandre Ghiti In-Reply-To: <20231228084642.1765-3-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi Jisheng, On 28/12/2023 09:46, Jisheng Zhang wrote: > 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 > --- > 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. > + */ Given the number of bits are limited for the ASID, at some point we'll reuse previously allocated ASID so the ASID allocator must make sure to invalidate the entries when reusing an ASID: can you point where this is done? Thanks, Alex > + if (static_branch_likely(&use_asid_allocator) && tlb->fullmm) > + return; > + > if (tlb->fullmm || tlb->need_flush_all) > flush_tlb_mm(tlb->mm); > else