From mboxrd@z Thu Jan 1 00:00:00 1970 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 32BD9C47074 for ; Tue, 2 Jan 2024 02:54:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A03956B0272; Mon, 1 Jan 2024 21:54:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B3576B0274; Mon, 1 Jan 2024 21:54:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 853D16B0276; Mon, 1 Jan 2024 21:54:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6FD5C6B0272 for ; Mon, 1 Jan 2024 21:54:36 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2CD691201A8 for ; Tue, 2 Jan 2024 02:54:36 +0000 (UTC) X-FDA: 81632852952.24.B5864D9 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id C4732140009 for ; Tue, 2 Jan 2024 02:54:32 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cyJf3ixC; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of jszhang@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jszhang@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704164073; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YphyD5k1qkjmla9y9YMj0DYy+n6/Igwnhv45WEO8KSs=; b=t/D09tWSSkBfA/SpGhU3jZtfEaPKdC6NlFebbtypZanz/UkG/OoEVDzURjAV+d/1LTeMd2 bPjrub++Thq75B/DxMWnEEsdqIRV4vIJlUqi3bKm1QktHXB8k98hr6VZxqtVVxTcB8AgJw 5BvNn1tNxuDZOpNvX/7DYvlPQUYo+OQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cyJf3ixC; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of jszhang@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jszhang@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704164073; a=rsa-sha256; cv=none; b=rpKNOzKln78/zcmCD11KYHwM9qEDGmVq88HfeOgZHc/fTZ3z9iExxge/pRItjc0NgFg3Du sI0VKOAp6y7gMc2VFCASnbv4wrOF3FSWCWUXSHYrrXooqqr/4UTY4QAwzFWXiT99v3IhvC GBxnWKHqI0hCoPiT4ysme/nJjvfty78= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4CE23CE0B74; Tue, 2 Jan 2024 02:54:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47A37C433C8; Tue, 2 Jan 2024 02:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704164065; bh=11z9yjbOWrH6tSiyWTkbin1v0ZP1GSqeHEVZ1qpwWW4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cyJf3ixCiPi9UvwUkSVUpOmKCh2ropGCL0NBDwtKRDYXQBHVLgzbEDPcu3Fja3YJG jSZs8VQEgmsEJFXxqzyDTpXLIyEvLGB9gRcZcYNrAM16lNkkiVRzm+TveG0nnUdsDO Cz9Xw1AdV6g9B3vuf+hPBycNosrLD86ng+fYciVOev6XLcgrRF4jz70RQMH5NzMvdv pcsyHKuZwX9hcMrpv5EtGFEKrqiVHYWwXPKdQhUADat9VR8ZW3EnNoQU9k4MY3EztT 7r9FaoDjSiOJIV8ph/7zp97UKkY4ISTBuOqOvwxFU52/3up2s1I2mMBs9cjS3+GXOv b0gUGT9N0gE1A== Date: Tue, 2 Jan 2024 10:41:40 +0800 From: Jisheng Zhang To: Nadav Amit 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 , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , linux-riscv@lists.infradead.org, Nadav Amit , Andrea Arcangeli , Andy Lutomirski , Dave Hansen , Thomas Gleixner , Yu Zhao , the arch/x86 maintainers 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> <204B6410-2EFA-462B-9DF7-64CC5F1D3AD2@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <204B6410-2EFA-462B-9DF7-64CC5F1D3AD2@broadcom.com> X-Rspam-User: X-Stat-Signature: yrppkc8g9nx15dcdxr7o4bueeguibyzo X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C4732140009 X-HE-Tag: 1704164072-170664 X-HE-Meta: U2FsdGVkX1+w/sLmh8k5Z6zYwph3trMJ+w2LajemHNWKOA/fN/SKz8D5BkawrtVYyGsPJgqbsTzCUis/6FsbSbtcofaAy/8dn2+HunYX+hGGaEKSemXES+yxwxTJCGODHj6OoDzOtnzqaLORyXeLigdzpEojXhP8MMaB0+NcHnNUdyBkyZr/515t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L+yF/YiCBUCDFPSGrPTqcDVr+qgNCbBEfDBscwTlUygt9Orb4tHHjcwb5ymhpTTKekdwrscyTzAJqfOx0a1A2SNvhjiGxCmGMW2RPh+Oxxa44xN6qlhkRsjS90ZoFItc6UmjgshuiwQQIv7ptZ48BfcDqtLYGg5UNb8iCSFSmQ6yfzD6aGlI1piiKfHaUBfF/AwHUO6zEpfYq6dexwudIapgoGkN7XK9h7blDk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Dec 30, 2023 at 11:54:02AM +0200, Nadav Amit wrote: > > > > On Dec 28, 2023, at 10:46 AM, Jisheng Zhang wrote: > > > > From: Nadav Amit > > > > fullmm in mmu_gather is supposed to indicate that the mm is torn-down > > (e.g., on process exit) and can therefore allow certain optimizations. > > However, tlb_finish_mmu() sets fullmm, when in fact it want to say that > > the TLB should be fully flushed. > > > > Change tlb_finish_mmu() to set need_flush_all and check this flag in > > tlb_flush_mmu_tlbonly() when deciding whether a flush is needed. > > > > At the same time, bring the arm64 fullmm on process exit optimization back. > > > > Signed-off-by: Nadav Amit > > Signed-off-by: Jisheng Zhang > > Cc: Andrea Arcangeli > > Cc: Andrew Morton > > Cc: Andy Lutomirski > > Cc: Dave Hansen > > Cc: Peter Zijlstra > > Cc: Thomas Gleixner > > Cc: Will Deacon > > Cc: Yu Zhao > > Cc: Nick Piggin > > Cc: x86@kernel.org > > --- > > arch/arm64/include/asm/tlb.h | 5 ++++- > > include/asm-generic/tlb.h | 2 +- > > mm/mmu_gather.c | 2 +- > > 3 files changed, 6 insertions(+), 3 deletions(-) > > > > 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; > > > > Thanks for pulling my patch out of the abyss, but the chunk above > did not come from my old patch. I stated this in cover letter msg ;) IMHO, current arm64 uses fullmm as need_flush_all, so I think we need at least the need_flush_all line. I'd like to see comments from arm64 experts. > > My knowledge of arm64 is a bit limited, but the code does not seem > to match the comment, so if it is correct (which I strongly doubt), > the comment should be updated. will do if the above change is accepted by arm64 > > [1] https://lore.kernel.org/all/20210131001132.3368247-2-namit@vmware.com/ > > > -- > This electronic communication and the information and any files transmitted > with it, or attached to it, are confidential and are intended solely for > the use of the individual or entity to whom it is addressed and may contain > information that is confidential, legally privileged, protected by privacy > laws, or otherwise restricted from disclosure to anyone else. If you are > not the intended recipient or the person responsible for delivering the > e-mail to the intended recipient, you are hereby notified that any use, > copying, distributing, dissemination, forwarding, printing, or copying of > this e-mail is strictly prohibited. If you received this e-mail in error, > please return the e-mail to the sender, delete it from your computer, and > destroy any printed copy of it.