Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5008220rdb; Sat, 30 Dec 2023 01:54:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEF/8xlkZahMp4JZ2a/VYdwoXa5bFYinEf4Gk1NNZcorolLYNBd+R/9rE0mAFI+CNzioSoU X-Received: by 2002:a17:907:c91f:b0:a27:91fc:19a7 with SMTP id ui31-20020a170907c91f00b00a2791fc19a7mr629269ejc.161.1703930069136; Sat, 30 Dec 2023 01:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703930069; cv=none; d=google.com; s=arc-20160816; b=GmScuKXG/ZjNT6hOSGt9zVMGPkokU6jyO7GsYPYvAHrLkC9bqYsA8MEqKM/5HicBos s06JpsW0EaPHvPV/yHBKp1z2txmCdhMovOJbP88kPD9+3icOuM3Yt0mPw1CA1xhvauqY 6Y0cvpc8XlB/01cptmyBpQ0xuxl0u19i3GH/XZ8mceAC7ZILnjuqThphvz+WuWC61e2d gJypUfAXpsD/N6imJvW12hujfTmnDIIiZ0tFJ1VWXbpsDxMvrPgiBUN+ujyOR6ma0sMY zsQ2U0JsY/Zc4HfTB/fPKM53zG7XFVJwO2giiKXqUGkYBViv86q2doDsVgbMnl/nlZ6J FIcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:to:references:message-id:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=abUTt15ozYHOLG/fk60Lc57aa9WtZ24J7IwER8hUXeE=; fh=0x8nwHHY9zvJtgRC/n28dkJ62a2T/DIDBvkz6Ch/oDY=; b=T+HhJUnDL/JF5m4HMi7qQiQk4VZ7yetkYmxT66P6J8UVQfjEmunftobisYE8ZKtynr j77jPD78Sd6aiLv8hB8UHpHclkpvseY/paQML4kLxzTn8I8Yd82KoH+k8JdRDAXWM2m/ gTPLcmfKSifUFHU1xy8s01zkaSoyRoqu9gFc4JyXfHMGdCkp74/KnjKXM9BcLBDr05KH ioKh6krbTK2AAqZR0AExcy5mKhKNOxcKADtMVM4bUsdgGjKj3owJt9xIflVPC0gdFOOV HvF6pVh42Pns1ZYR6w710ExHuMGx8L9cnKD8UE20XZC96HSYb4LhgfjkLdW2pdLF4rTr 115A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=d1w1OrxQ; spf=pass (google.com: domain of linux-kernel+bounces-13380-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id oy17-20020a170907105100b00a23614f9a7asi7890462ejb.860.2023.12.30.01.54.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 01:54:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13380-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; dkim=pass header.i=@broadcom.com header.s=google header.b=d1w1OrxQ; spf=pass (google.com: domain of linux-kernel+bounces-13380-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.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 B7A941F217E2 for ; Sat, 30 Dec 2023 09:54:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CBDC5CBD; Sat, 30 Dec 2023 09:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="d1w1OrxQ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C4D45248 for ; Sat, 30 Dec 2023 09:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-555b361353bso1523131a12.1 for ; Sat, 30 Dec 2023 01:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703930058; x=1704534858; darn=vger.kernel.org; h=content-transfer-encoding:to:references:message-id:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=abUTt15ozYHOLG/fk60Lc57aa9WtZ24J7IwER8hUXeE=; b=d1w1OrxQSL/PEmBYJoZE4VTCpsv6fck5HKO6c46JnAR8GE5mtXbL/rPyuRcjk5KF/2 v2CDieeJkgZ0VzOjaTSuK6ATFDK2IsqDErlIWH68xZTiT0dcazKphxUHgAzYOD6A12O8 JcMBABm7/194Lg/YTOLGmJUSJVj9E3zv9rtWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703930058; x=1704534858; h=content-transfer-encoding:to:references:message-id:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=abUTt15ozYHOLG/fk60Lc57aa9WtZ24J7IwER8hUXeE=; b=PQuJL+gsbx9FiYse5tVNpYjbo8Mvgcpq4EgN9Z2znUIoTxIIzOKbjkLuC1TnNBaSqU TRNCVRArmUkAv7Fua6+UPRKY8env36ItyImkKmJKVVWEkLNjj1Oc8sjuFKCScoaIcn0a ewoa7+Sa7umIOAhipO7UpK5X7TabbD0AtIc3L4/Wc1lGKPGT1qdpuQ7Jtq2aEqrP81Ex PjcBEEhPFoRpm4r0Q9Kq++y6KvwXItWPj/1wOr9+cRKrsnYjp4vNhQ9TZOJrbaISkGMQ 43i9jPQey2tQaKnDUQAjCBaeFD4IJk0R5S0Q3iz+cxGMOec2uEJAGFQmyJiN+Bqt2kGa xDaQ== X-Gm-Message-State: AOJu0YydlZUaeAsiZdQexYSb+UPZnVs1avYdm25tGP4IumSVdJh7ynPt DQbiwy83YPn4N6tmgBluH8ngJDJ5y0j4LRPlkbbBfnZaSGMKJOkgqbMdAwaCpslVQ7Q+Hc9MEwC IqhkOGD1RVO4bFcy2r+PgbQ== X-Received: by 2002:a05:6402:ca3:b0:54c:9dbe:5c03 with SMTP id cn3-20020a0564020ca300b0054c9dbe5c03mr5290445edb.40.1703930057752; Sat, 30 Dec 2023 01:54:17 -0800 (PST) Received: from smtpclient.apple ([132.69.236.92]) by smtp.gmail.com with ESMTPSA id m9-20020aa7c2c9000000b00552666f4745sm12089039edp.22.2023.12.30.01.54.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Dec 2023 01:54:17 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) Subject: Re: [PATCH 1/2] mm/tlb: fix fullmm semantics From: Nadav Amit In-Reply-To: <20231228084642.1765-2-jszhang@kernel.org> Date: Sat, 30 Dec 2023 11:54:02 +0200 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 Message-Id: <204B6410-2EFA-462B-9DF7-64CC5F1D3AD2@broadcom.com> References: <20231228084642.1765-1-jszhang@kernel.org> <20231228084642.1765-2-jszhang@kernel.org> To: Jisheng Zhang X-Mailer: Apple Mail (2.3774.300.61.1.2) Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > On Dec 28, 2023, at 10:46=E2=80=AFAM, Jisheng Zhang = wrote: >=20 > From: Nadav Amit >=20 > 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. >=20 > 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. >=20 > At the same time, bring the arm64 fullmm on process exit optimization bac= k. >=20 > 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(-) >=20 > 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; >=20 Thanks for pulling my patch out of the abyss, but the chunk above did not come from my old patch. 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. [1] https://lore.kernel.org/all/20210131001132.3368247-2-namit@vmware.com/ --=20 This electronic communication and the information and any files transmitted= =20 with it, or attached to it, are confidential and are intended solely for=20 the use of the individual or entity to whom it is addressed and may contain= =20 information that is confidential, legally privileged, protected by privacy= =20 laws, or otherwise restricted from disclosure to anyone else. If you are=20 not the intended recipient or the person responsible for delivering the=20 e-mail to the intended recipient, you are hereby notified that any use,=20 copying, distributing, dissemination, forwarding, printing, or copying of= =20 this e-mail is strictly prohibited. If you received this e-mail in error,= =20 please return the e-mail to the sender, delete it from your computer, and= =20 destroy any printed copy of it.