Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7692544rdb; Thu, 4 Jan 2024 05:01:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDnw0PhoNRl2oRuXesEfTJ+lt4JNvIGSgzTJhf7+ocyVQJxUNlec+xU8f5ODFCLTDxguXq X-Received: by 2002:a17:906:5208:b0:a23:57f3:95a9 with SMTP id g8-20020a170906520800b00a2357f395a9mr325363ejm.2.1704373298265; Thu, 04 Jan 2024 05:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704373298; cv=none; d=google.com; s=arc-20160816; b=XT24TAi/vkr1nAncAWPZxePsQT/e+WFT94zgDrpw+uZcRb9YWpOmTbr+Fo5uknESiX Hjkvet+hN1lGYi6J3lv9bi97kDqc3D1AxmWovdXHxcBRywmP0v6b7JzDR2fQ/EwLPiDm d76ieyrwsrG0ZlU538sTrvOiYdI1FEaCUTSfQ1G/3F+Zsc9MKpjgy4OnCa+NmZPoDy9f uULntDy5h66i37gkgELAh5SDNbe2ngMsVMgUDY2HzJX8sOU9ZDvXWL/dBlJowSI/XKhZ 6lpsT7c/CMcbTCK01uIJBvBkD0n3hkxwo7ny+dFZjdmHm12v9GpjQqEhDVSstkv0qnv1 00bg== 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; bh=crMN6klWskcEAZPwkQIyellJ5Jw4znZBfIWKYAuKBcY=; fh=RUvSa3+0W19U+n52Ls35bqhLjxr4PbZKQhRVHHx2AtY=; b=hHk6pQXaiwAqF3Fn9n8DMfc0iUb7hdai1KeQlKiMlak1TqUdqH+BuCgN3QdvY94RzR SG0jkiZEMAmpqcwUer4Yq7i6aomNBniKdgTfO1Kis14IsCl7pCAYS7QRD24wOogwX5uQ QVovawSBm9c6NXSRmyqOeS/Vd5ivhhbT4Rs2HlezpnwIzLi5w/+PxiA8IlAl4Bt7DLOz /PQJqprdwTICe9y4yyvIXvvVe7KKyrc3HK4cA6dEaYMEzcazv261HI8hHEi3CGUnjC82 HQ4R6pAEX1v4m0Eo3+YQlb0IVydfZb1dYYRIo7newesN0aIWO/ik6u+5AdSYms7qQmOW jmbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16670-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qy29-20020a170907689d00b00a26fceada33si8025335ejc.123.2024.01.04.05.01.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 05:01:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16670-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D39241F2577A for ; Thu, 4 Jan 2024 13:01:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58595224D6; Thu, 4 Jan 2024 13:00:52 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 43283224CE; Thu, 4 Jan 2024 13:00:48 +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 F3D03E0002; Thu, 4 Jan 2024 13:00:44 +0000 (UTC) Message-ID: <6685594f-5a50-4e4d-b6ec-2834e9f8624f@ghiti.fr> Date: Thu, 4 Jan 2024 14:00:44 +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 Content-Language: en-US To: Jisheng Zhang Cc: Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra , Catalin Marinas , Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann , 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> From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr On 02/01/2024 04:12, Jisheng Zhang wrote: > On Sat, Dec 30, 2023 at 07:26:11PM +0100, Alexandre Ghiti wrote: >> Hi Jisheng, > Hi Alex, > >> 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? > Per my understanding of the code, the path would be > set_mm_asid() > __new_context() > __flush_context() // set context_tlb_flush_pending > if (need_flush_tlb) > local_flush_tlb_all() Ok thanks, so feel free to add: Reviewed-by: Alexandre Ghiti Thanks! Alex > > Thanks > >>> + if (static_branch_likely(&use_asid_allocator) && tlb->fullmm) >>> + return; >>> + >>> if (tlb->fullmm || tlb->need_flush_all) >>> flush_tlb_mm(tlb->mm); >>> else > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv