Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6317537rdb; Mon, 1 Jan 2024 18:54:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBXWxiwQU4sSm/6YwemEtPS4z/EnoAqhsDXBWfYfnx1jYqzNfd1GHbfdB6oxKuzvb7Qrym X-Received: by 2002:a50:ab16:0:b0:54d:9782:c3db with SMTP id s22-20020a50ab16000000b0054d9782c3dbmr10998916edc.84.1704164077467; Mon, 01 Jan 2024 18:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704164077; cv=none; d=google.com; s=arc-20160816; b=mwBc2I1kO3oQLJIHpBgWgCVbXRD4qxMGCEgKZV0HfSsQ12Lh2941AofGX10R/WeCRr wcolntJTnjjJ64+njNZOkzUMca0xlsfhC3VciQAkmhaV6hUyIC/5bOxz1fGtB4wHS2aY ifD9PkAIk48oaqnkMAbTyng05ogUCcoI6DT9qQZhbSe8fZsmQimMB8N3RXG7fp0IEyPU yg6WCqghE6NKPW5FlePECzlwpijbo1r97DX4a0lz1YVke9SDfc6Ewqfs6i82NlKwwC2m +yBEJVfPES2cXccYEXagUgU7iyi9GL/urJMQ8DTMfvp3e3kPmdF2EAtDOyNLURt63YOu mRJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YphyD5k1qkjmla9y9YMj0DYy+n6/Igwnhv45WEO8KSs=; fh=0kHIv6HXW7BLqo8khHUIfgutDzFMSwTC6VuhSkSP/mI=; b=bJyg+wDsvW8Fole8znwxV+bsRSPfwjRUqKKmcm60opOQxG+tU/eDAOd5TRzh1Cd2U1 aWDutHLjhHBj0SvztCh2x3Ih14OPEgZe8V9dZZNQUpYBCWUpwRqkZ/5Ff47r8r6ezlWD y+WmkmY7CYmF3VOZQAdWhJGV74txewo3/4KCPZmEdsS/VUVIjSbj2CW1nZEnLlMgB5Es gfU9Js/CGYy0h/fuLAeHJkLBpWPboFrHfIzdiiNgtRmJCuil+LKZ/H/WkNoXoiF22VCh E/GawJblcoAqvhIhAEKE14yzyXKgzhrMvHSA+GbYTyBX/5rJ5jOo+QmAJ0y+T81TKNAb 4dgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cyJf3ixC; spf=pass (google.com: domain of linux-kernel+bounces-13991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s21-20020a056402521500b00554f791ce11si6724818edd.484.2024.01.01.18.54.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 18:54:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13991-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cyJf3ixC; spf=pass (google.com: domain of linux-kernel+bounces-13991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 285CC1F218E6 for ; Tue, 2 Jan 2024 02:54:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2834723CA; Tue, 2 Jan 2024 02:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cyJf3ixC" 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 5314020F9; Tue, 2 Jan 2024 02:54:25 +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> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <204B6410-2EFA-462B-9DF7-64CC5F1D3AD2@broadcom.com> 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.