Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7275911rdb; Wed, 3 Jan 2024 10:05:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUsN1Pja+F5LygF3/rLV1KEJZI2VH7SRJlK0atqQ5rMO0tRH9uR3MNxvvBhTYFf+vW2EeQ X-Received: by 2002:a50:d602:0:b0:54f:478f:9bbe with SMTP id x2-20020a50d602000000b0054f478f9bbemr13759130edi.37.1704305138869; Wed, 03 Jan 2024 10:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704305138; cv=none; d=google.com; s=arc-20160816; b=ocbKPphapMvTwktt3rijJZOT9HvxKzVI1Ydap4TGj73T7UPu12xIIOrsx8vv2vtAtl 8vQStG4JNJ2CRdb1ryxHP0tirgGuUTXHgSeNotDkb8upgQdFitJ2mtzlTJ/iYcaNj+oq gviMobqLJKLVSkmXRh/dCDjmrqtgLE+rFsQcx8me2lH+2HN7rJB1b7ciKD2HL0lu16/f 6vbD5dVJgI3h69yTcVIDl8eZXBlGbKHcMxxN9F+ZJjcm5QdyOnEmIUoW322ceuH5XCF1 Vzowkwxq2QIlJ40J6gkASlhzcA5UtRN4VfH0PY4y6hCbxTg8M9uyL73mS3zFKEMPc7HI p/GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=zQsYD+uD2GIm+ypQPxsSniZM3Q+27NYZFWRCX0vZfAI=; fh=ARXP3aNhpxLR9419gA+zCfhAm5tSVV8yvfmQzZoumH8=; b=PLf1g6TE2JHqfKf37x5s5D8Xyul5QHJ0q1CsUNTxEYUZgNAmdBqNf3uYSvZuYvQleh gx0LNDc6qWtdiHXFwAcrD9O5w0/Hmq/mlkf0uA1YT6m7bi0qVI4/6HMdWYb3dQmNzcwG PdMFJAASIH14eQuaqeFGip4RqIsHSDiQNx2vD80N+SBUj/Ym9YxnFryqebeciTjr9p/P upPDWyEdf5DA/vi09DgclHqCf+ZuIvcnJh75G/9Gs0+vyTAvdS2/gwQbbz5NZ/fK18uF ZNWfBpSALvfLIL06tP1+7SCLCk9jtvvheuWKJfgkDK1+P7k6bdShN6X9e0EQYM+sax6e +yug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r4-20020a056402234400b00553aba11b40si12926846eda.49.2024.01.03.10.05.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 10:05:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9B6B61F2462B for ; Wed, 3 Jan 2024 18:05:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62A4E1C68A; Wed, 3 Jan 2024 18:05:29 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EA6D81C2AE; Wed, 3 Jan 2024 18:05:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DBDAC433C7; Wed, 3 Jan 2024 18:05:24 +0000 (UTC) Date: Wed, 3 Jan 2024 18:05:21 +0000 From: Catalin Marinas To: Jisheng Zhang Cc: Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra , 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, Nadav Amit , Andrea Arcangeli , Andy Lutomirski , Dave Hansen , Thomas Gleixner , Yu Zhao , x86@kernel.org Subject: Re: [PATCH 1/2] mm/tlb: fix fullmm semantics Message-ID: References: <20231228084642.1765-1-jszhang@kernel.org> <20231228084642.1765-2-jszhang@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231228084642.1765-2-jszhang@kernel.org> On Thu, Dec 28, 2023 at 04:46:41PM +0800, Jisheng Zhang wrote: > diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h > index 846c563689a8..6164c5f3b78f 100644 > --- a/arch/arm64/include/asm/tlb.h > +++ b/arch/arm64/include/asm/tlb.h > @@ -62,7 +62,10 @@ static inline void tlb_flush(struct mmu_gather *tlb) > * invalidating the walk-cache, since the ASID allocator won't > * reallocate our ASID without invalidating the entire TLB. > */ > - if (tlb->fullmm) { > + if (tlb->fullmm) > + return; > + > + if (tlb->need_flush_all) { > if (!last_level) > flush_tlb_mm(tlb->mm); > return; I don't think that's correct. IIRC, commit f270ab88fdf2 ("arm64: tlb: Adjust stride and type of TLBI according to mmu_gather") explicitly added the !last_level check to invalidate the walk cache (correspondence between the VA and the page table page rather than the full VA->PA translation). > diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h > index 129a3a759976..f2d46357bcbb 100644 > --- a/include/asm-generic/tlb.h > +++ b/include/asm-generic/tlb.h > @@ -452,7 +452,7 @@ static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) > * these bits. > */ > if (!(tlb->freed_tables || tlb->cleared_ptes || tlb->cleared_pmds || > - tlb->cleared_puds || tlb->cleared_p4ds)) > + tlb->cleared_puds || tlb->cleared_p4ds || tlb->need_flush_all)) > return; > > tlb_flush(tlb); > diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c > index 4f559f4ddd21..79298bac3481 100644 > --- a/mm/mmu_gather.c > +++ b/mm/mmu_gather.c > @@ -384,7 +384,7 @@ void tlb_finish_mmu(struct mmu_gather *tlb) > * On x86 non-fullmm doesn't yield significant difference > * against fullmm. > */ > - tlb->fullmm = 1; > + tlb->need_flush_all = 1; > __tlb_reset_range(tlb); > tlb->freed_tables = 1; > } The optimisation here was added about a year later in commit 7a30df49f63a ("mm: mmu_gather: remove __tlb_reset_range() for force flush"). Do we still need to keep freed_tables = 1 here? I'd say only __tlb_reset_range(). -- Catalin