From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 9E88BC2FB for ; Mon, 20 Jan 2025 17:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737395464; cv=none; b=eqAoSEz41ecDoPC5BDGANXQTvgGMDtlzAnGwFF3DPa6u3Jkgpe+WWbR/sTmguOx3raHs/hT79xmdMaqAbU/AFr1kh4B4UlV9Vgei5npiPuspcbFXc2a31LDXytn6a2XPKFnwq0OyB2JL6SepJwwIvN16BUqgDhlzirvKOPr4OGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737395464; c=relaxed/simple; bh=Exmjcn6lh6wauJHBqfM/TCM16K2/QQBQEZN0i+kSpqI=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=jwRwKxubuftWf4LcNYxsO9mM89mmqetU5aOHTSg1E5rH+wNv8ABa0fxp+7NwGakG+dasKU6IvLlCEP30+FmkNSXbyDnYjjxIpuaqNM11tWVm8MmmJk6sz19+5E68fvxcFHLhAHEKXPrg+Tg2Jt5FaJVIH/QNcszQyeDoxXU7smE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I2vIP+mA; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I2vIP+mA" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aa6a92f863cso887437166b.1 for ; Mon, 20 Jan 2025 09:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737395459; x=1738000259; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Exmjcn6lh6wauJHBqfM/TCM16K2/QQBQEZN0i+kSpqI=; b=I2vIP+mAh2PhD7oupoGc2YtxZkIEqpfVvS7ufZ+z3qhe+MJg4tw5Upafaa6HsMufxY xAc9JsmksxevenM5H6DeP88VSg4fIFuzky76A1NF3YDjVeXATYPBXpCE9Q0y39L5tjTe CjWKKgvluegZMwb4IMh2wMX1rRCU93RdYoxohewCeCfWR80dEPztRx0k1iMSiolrdANv 8cw1H1ax/xO0MLmymuFaXfLVV6c5rpNfxJsbzKBKaVdctPKKYTt90HBYtMk8jKR+IhsB MaVwtAlFZHQ364gGIcdk2rFuLV26b906kv9KfLkzCwwXWtguKlq234jfZ3GtIHYu+wfV bocg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737395459; x=1738000259; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Exmjcn6lh6wauJHBqfM/TCM16K2/QQBQEZN0i+kSpqI=; b=B6cWzwubOmynC+VmCpnrlgSSAqBUmq2hp4qTwVVFwRBCpfcR1BX6rhOxWNCO92k6ol jyx9cMpgGyqZJt1HIdSa/k+TlM88K0MlTKc9s6HF8Th0R5O3fMvkH0/ojYtUZLwa4Zm9 4cRE62shG9WyFCQGjg1FRmUwHQZaChIDFk2GAhqHsAEAWhWSIBEOAV52Y7cuhuRuYgHL iVGmWRUbkKyjlzj5aHjdwJIL/Lx0698le1ipJEsJmZ3I9mMyNIZvkGw4MLqeV2V20KTE KvyXRseaiJ+jlIAlZd2cHm9V+yNaFThmuxZdCyP1c8Atn+YHeWO9WZHbMiRyUGlaB+L1 yfnA== X-Forwarded-Encrypted: i=1; AJvYcCXJkGSUjEar8MLyjkPf1COvBculOR2ChVAv4/+wYvZCh/+tksJgH2T6aFUgrQaPLZBb/WxEoMAIrBb4LOY=@vger.kernel.org X-Gm-Message-State: AOJu0YyIQL31YuGaOoS5tLImXss8Sn6eRJzfeCQBdTAsLx1Tjc95asUt rmMiE69PNUnyEIbq5cnhj0d188mNbfKJgDOtxvgpNge168xuuWH2 X-Gm-Gg: ASbGncuG0Zx9LYfUx8hgx4EBbYGj35XxtR8mnuZA0sZL/IyagCAfSxhv913bDfYryXV +2mpKVOa99fK/GhdZAXQkm32rXSjKpFuFLSl1BghUyQuzRlF728tyNrOiowmqtnnJ8ipOhTM3qX O0h8qETUCHaSgfVI/cbWjM/MPr9cYMYEQF2OOLIP0pexDx9GFHEuaWmhf2lcinqpGAiPGECCRLN fmfOfBIQmUKxoccfBV7pHI6yxr5dmdoc9tPjtoS7r70u3rQX85EvniFTbKYYzUH8bflCPgAXQ4d NtIQx1xlkg== X-Google-Smtp-Source: AGHT+IFbYq+Ft5rH6pT9zSbxDQnDtz7c/Xvt+8NX7LYSVi+AeSkfJyDRRGG1V6UenjLIrxM/xZqOUQ== X-Received: by 2002:a17:906:f6cd:b0:ab6:3704:5f0b with SMTP id a640c23a62f3a-ab637046235mr75406366b.10.1737395458663; Mon, 20 Jan 2025 09:50:58 -0800 (PST) Received: from smtpclient.apple ([132.68.46.60]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5db750293aesm5915723a12.71.2025.01.20.09.50.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2025 09:50:57 -0800 (PST) Content-Type: text/plain; charset=utf-8 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 \(3826.300.87.4.3\)) Subject: Re: [PATCH v5 10/12] x86,tlb: do targeted broadcast flushing from tlbbatch code From: Nadav Amit In-Reply-To: Date: Mon, 20 Jan 2025 19:50:44 +0200 Cc: the arch/x86 maintainers , Linux Kernel Mailing List , Borislav Petkov , peterz@infradead.org, Dave Hansen , zhengqi.arch@bytedance.com, thomas.lendacky@amd.com, kernel-team@meta.com, "open list:MEMORY MANAGEMENT" , Andrew Morton , jannh@google.com, mhklinux@outlook.com, andrew.cooper3@citrix.com Content-Transfer-Encoding: quoted-printable Message-Id: <5F51AFA6-EA48-42BF-8E24-10FAAAA7BE4B@gmail.com> References: <20250116023127.1531583-1-riel@surriel.com> <20250116023127.1531583-11-riel@surriel.com> <13bc0c49-09a4-434e-bd35-1ea50be38e25@gmail.com> <4dcf2b4ecaede883e2c7f6af3db58a4f6afaf4ad.camel@surriel.com> <2975f6a4-58ef-4499-b177-4b73ead4c670@gmail.com> <2c93b3f17e658483e3ea03ca3f0a717668fd117d.camel@surriel.com> <11d9f41a-eae3-43a1-90bc-eb5c69020002@gmail.com> To: Rik van Riel X-Mailer: Apple Mail (2.3826.300.87.4.3) [ Thanks for your patience. ] > On 20 Jan 2025, at 19:11, Rik van Riel wrote: >=20 > On Mon, 2025-01-20 at 19:09 +0200, Nadav Amit wrote: >=20 > This is the page reclaim code. >=20 > The process that has those other pages mapped might be > running on other CPUs simultaneously with the page > reclaim code. >=20 > Even if we were invalidating one of our own pages this > way, there could be other threads in the same process, > running while we are in the page reclaim code. Of course, but there is nothing new here. Let me see where we lose each other by first stating the goal, what you propose, and what I suggest. We are issuing invlpgb and we need to ensure tlbsync on the same core that initiated invlpgb before arch_tlbbatch_flush() finishes. That=E2=80=99= s all that matters for our discussion (correct me if I miss something). You solved it by disabling migration and running tlbsync at the end. I suggest *not* to disable migration, to keep running tlbsync at the arch_tlbbatch_flush() as you do, and if context-switch happens after arch_tlbbatch_add_pending() and before arch_tlbbatch_flush(), to run tlbsync during the context switch.