Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp376897lql; Mon, 11 Mar 2024 05:42:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXN7p7Ymk+rNA1kYIkG16ozC/DklmIFfHX+WmU8TNaQIXot8UVo4WsyyBFb/9mMpnc4US1Jng3ei41CedHNqx/WGhh3Gg+gnM5y6su2hA== X-Google-Smtp-Source: AGHT+IFtRkFNGLOcqw/670hcdQMdOUSZehuhqfjVGR3Cu9/FejSzDn+/2iefgbHgGiWAw9OHumOJ X-Received: by 2002:a17:907:a809:b0:a46:1a14:356a with SMTP id vo9-20020a170907a80900b00a461a14356amr2586303ejc.53.1710160951077; Mon, 11 Mar 2024 05:42:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710160951; cv=pass; d=google.com; s=arc-20160816; b=P/O+CYTOPcx/1nUB19Y3KA1QjRfJvSr2UJOLdbelPN5MFWQVsk56WSRxKTLCd1+CGL bm5EIddxkvT0yG8bUCzIeJ7d5YKl3pd5ULusbNlNXhobMoPMpDrmh0/WLK7vs1iqnKET ipyxiYtba5Y2TLNyFc3cYbdhOX9LyuwbW3+hKpvtaSki3y9MP/qQKLC82HecRwWkT2PJ 46yD3621s9M7xdPKlBW/9ffGIUDqaV7GxtLxDbWhJnnk6C9W6q0NpTUEvsMyFeHWIaDt vdeoZoZtmEU52j6/QwOk25/NwmRvuhYO+dP5xet5ysn2JSMUOLjHq6h6LOiyTf1ijcX9 DQ+A== ARC-Message-Signature: i=2; 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=Vtq9+h9uNNxjuly1OjVaYv0d7kBnnWSRa7QN7HjtQMY=; fh=ph+DQeP2MZa4aqXYmI/PlPEcF5zbUh8NRA5NutzkrU4=; b=Z6SnqnE3A/EC0RCwAl9I5ksSwPzypd1b5wyJFID66TG8prpl86HwAYpXnDlHeCtjQN tan8hlmGjL1CO+Z8/YTBD1MIUCQOhMFZJKFeqew+ZMTBQ98H8OU9IAm0rydFppp4vhsC fOMP3xQRMzKlfURm0gbYg1rZi0YOno3j14hoh0NObd5lI7U08x7Rm9qHm25lFbM/AIFD cNa57iKf07qHWggkaBUyU4d3niu2qNsofmz4xwc7jMR5XHzkYqe8Fps2CX6o7QKbb7Ip H+JOlk4aEWw8MUNpYDz9MwAGG7UKXBiYDfXCkb20dViBicguaRngRE69SJ4+bHs2lf2I v/Nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Rn6ztg7y; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-98836-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98836-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 rs11-20020a170907036b00b00a44d27980c5si2475244ejb.421.2024.03.11.05.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 05:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98836-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=@intel.com header.s=Intel header.b=Rn6ztg7y; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-98836-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98836-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 C68E31F20F35 for ; Mon, 11 Mar 2024 12:42:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D900837160; Mon, 11 Mar 2024 12:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Rn6ztg7y" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 5ED8314298 for ; Mon, 11 Mar 2024 12:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710160944; cv=none; b=XvOAfUlDgGg1QMLHMIKSBa94ECA1gIO7as1+xe0GIVGlOJ/Kl8VTckeQk8PRpT50oH/O+yGA/++ggMz46lzYxOwdDmR9XKT0ffYVNsD+1Vn9jG7FXVU6PXJIvNzHqWzqg2mkXpylMWZckYOAmDFEGRb/shuOi0lkuenkSH9mWpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710160944; c=relaxed/simple; bh=drNSqX9EaSckBuQ7fqCj5jsg1tNnSNmL5x44pJ2lqQM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pkieM0PG3E224MC+Tu4j0L8HjTeazgMlmWm46WZtO3rZ9N3JA1ek7/iKZ2XAZITmicC4M9zZDZK4gpbT9G2zHJ03NJBRgKvDSLASHDKNxCk1qZr6OOU9AiKQnfMGqA/R/cIPvXBm6qLXBcO8l1Q5BejkAYcPapSe0dPfaPTeP1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Rn6ztg7y; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710160942; x=1741696942; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=drNSqX9EaSckBuQ7fqCj5jsg1tNnSNmL5x44pJ2lqQM=; b=Rn6ztg7yq/hSCYzCESIGPPqyaxt6fQmkwOzzkHqp4k0aMBiII4Mm+6G/ b6c3VIy8gsA701JR1V01rBX/Yp2mGsezNtjzVCz/u8NxA/OrNewtfx49g AgXFU6AGv8a7U4EnqV0/f3Vey8wstXC7olLlA6Lflo1Y8UJe0XIcFJ9j5 jFgKqNQ9Tp2HzpzowYOeAlvbrq5N7gDJaBjEfL3PBLH7xgQ3diF6Lz5+f Ndu3DXhXODsyLAyAuVLjU8OvPrQ97OHJDLdJZs0CYcRqO1XYwGYWN0JsQ 8rUhZblZ9qCuTStYfoYKtHbBJkyX/pbbvHYLw7JCLfIHFCQQDaH42jCEf w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4663162" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4663162" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 05:42:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="937049757" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="937049757" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 Mar 2024 05:42:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 81F2F177; Mon, 11 Mar 2024 14:42:17 +0200 (EET) Date: Mon, 11 Mar 2024 14:42:17 +0200 From: "Kirill A. Shutemov" To: Yosry Ahmed Cc: Dave Hansen , Andy Lutomirski , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "Peter Zijlstra (Intel)" , the arch/x86 maintainers , linux-mm@kvack.org, Linux Kernel Mailing List Subject: Re: [RFC PATCH 2/3] x86/mm: make sure LAM is up-to-date during context switching Message-ID: References: <20240307133916.3782068-1-yosryahmed@google.com> <20240307133916.3782068-3-yosryahmed@google.com> <420fcb06-c3c3-4e8f-a82d-be2fb2ef444d@app.fastmail.com> <35b670e2-9ef5-4d3a-b6ea-f8016dfa088d@intel.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: On Sat, Mar 09, 2024 at 01:37:06PM -0800, Yosry Ahmed wrote: > On Sat, Mar 9, 2024 at 8:34 AM Kirill A. Shutemov > wrote: > > > > On Sat, Mar 09, 2024 at 02:19:19AM +0000, Yosry Ahmed wrote: > > > I don't see how skipping set_tlbstate_lam_mode() for kthreads fixes this > > > problem. Do you mind elaborating? > > > > Define what problem is. > > > > Yes, in this scenario kthread gets more permissive LAM mode than it needs. > > But nothing breaks. > > > The problem here is not how the kthread runs at all. It is the fact > that if that kthread context switches into the user process that has > enabled LAM, it may not update CR3 because the mm doesn't change. > switch_mm_irqs_off() will only update CR3 in this case if there is a > pending TLB flush. Otherwise, we just return, even if the LAM for this > mm has changed. > > This can cause the process that has enabled LAM to run with LAM > disabled and fault on tagged addresses, right? Did I miss something? You are right. I think IPI is the way to go. Will you prepare a patch? -- Kiryl Shutsemau / Kirill A. Shutemov