Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp152536lqc; Thu, 7 Mar 2024 13:06:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXd0pkYatHF5LtVGDADD8/P0wnsdY+MdSbS63UVc+o7WbsuMatw1nMJbcVRmY8HESqsm7ojLalbu3JM/dPCbiLFasHIS65lGB7F0S7B1A== X-Google-Smtp-Source: AGHT+IEbKPtWSUGmU/ZfvHZzT/xCvOLoFxFQfsmAgzbjNHP6xPUuncde/WSh++ziYGdu94IFP4A3 X-Received: by 2002:a50:950e:0:b0:566:aa2:8433 with SMTP id u14-20020a50950e000000b005660aa28433mr628066eda.36.1709845609170; Thu, 07 Mar 2024 13:06:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709845609; cv=pass; d=google.com; s=arc-20160816; b=eu7pmsQVv05XWEtD2QwRA/0ukkEOjlDB+lyabJnIKDmvppyoFXnO+N7C6wkIpUwCAW JjXMXNb9f411P7vNP5e03fWeY7LDPL0SYy9FSZlua1jHEvZQ2Z08ry4c/qbEkJgZE8E/ +eHA+nN8a9uZS91yrOqpPg5RGZ7iQHw0Skq2VSZju+ps44nss+/UMhqggBgzJukovRsH uCMOMY7LAvwx7z/VS+0w/12cNniWVsjMp6Kr7GUg9LjEysQpSZK8LUBWS5OhOMJoyr/c FjwwSMktdWCfqyiyEsxC0ym6gOfM77BRODfAOpThBhFZ6iLSbxYWMOVvjheU38qEA/Iw +N2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eTmkaXARmo3N/Mp8/PXvdx9u+PgbpwI3E1dTV/vZEeY=; fh=tj1/N7k3DinjgtsukVzA1FZB5kBIqDmHrjEq/RKRaBQ=; b=uqTFHtFSBWRLoFNU2DdtpD/Lq2A/kLo/NzawdWGhtdkFwjk/R6N+tzncARrlmIjAOP lKufAniArijO5w4lTQElDFjg1doQ/k6OFHFQwOtjrH7+3SeG1phXMwg2RYDFXzkNn6AH M9pV2dZmP8bu5P2ntaLRKQ8fT+8PLdF7l03M3hzs/YHBnLLeUCkDz3Qh9PLluJgNI3sn 9qlKKa/j33sdYal0RySqu0PQvABYTjzgvlTWEcpSrbHqQsafJxhDl1B5hxV0n/ariR19 j5/scnwnxb3oxRiI1OL5CVsxmFtTX/EC43UW8F1C1Qae96BCVgwP2FxRReS1DUUmS3zz r6cQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ARi9oqRh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-95940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95940-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. [147.75.80.249]) by mx.google.com with ESMTPS id y5-20020a50e605000000b0056802618891si1226179edm.369.2024.03.07.13.06.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 13:06:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95940-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=@intel.com header.s=Intel header.b=ARi9oqRh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-95940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95940-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 BBE4B1F21417 for ; Thu, 7 Mar 2024 17:29:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EA86130AF8; Thu, 7 Mar 2024 17:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ARi9oqRh" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 5E5D11DA27 for ; Thu, 7 Mar 2024 17:29:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709832586; cv=none; b=t/Bfu2v3YRIJ5q+khkBszXCsFFVXjuua5/8l7+LV9GyTSzYKgASFd2A6UV6i12kW9aj7qC/gv7SLQnTjZIDY0eWZ11Q7vey5PYY9anF8lrDe3FNc8PZURRNyw0QJstH9YNZc3jQuLNUZe4SQr56QZA1nldYXJY1UEwZag25K72o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709832586; c=relaxed/simple; bh=uxUbV0oMd2fQbX5ovQlDJR2DtR8unKq0norIZwYBo1s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hsW0HaE0CF17ZdMS55BrIsd4t2sxdu9QnnaCWXBaU1cC6x+ainwmO3LOqV/QLLV0a0aGUDOXezYjKeqjNq4Lp24tx+Rsw2HifWudzmGtNK8lDR6tF3m+bmrXrikTN6RtgS/Fpxzqck3wjGI9KdSkIhZRqbDDcMrHktHVIQd9+cY= 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=ARi9oqRh; arc=none smtp.client-ip=198.175.65.9 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=1709832585; x=1741368585; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uxUbV0oMd2fQbX5ovQlDJR2DtR8unKq0norIZwYBo1s=; b=ARi9oqRhA1CwV+uNwHciehYKt85X1wcvGyVGfQ1nEfIDec9PDyqGC2mR 3gkQPkfODFH05AGMzHwYhXvK/rXXJjRJjekCjdyTXKzWJP5kmm8PTeqDF bgwOWyqHOH18VZUZEGxtCcn8UaY4zo5sge2DEWt0F1qxC4fI7/tjbDHL2 Ypkk4sFYv2gFe5IJSOUkVGBcigIrqiF2XuFnXmoMzFlQBNPpvkoc0On8f WJMt4JZgHGdQh/T2cUleBtaBAjnUte844b0zqOJWMrbWIH66bmYYPVVxT +b9P0+Z/gz57OhfkprYw0c3Uc9Eho/ytstk+FncG+sc52GmQBaZeuTTxz g==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="26987009" X-IronPort-AV: E=Sophos;i="6.07,107,1708416000"; d="scan'208";a="26987009" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 09:29:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="937046426" X-IronPort-AV: E=Sophos;i="6.07,107,1708416000"; d="scan'208";a="937046426" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 07 Mar 2024 09:29:41 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id B9D68128; Thu, 7 Mar 2024 19:29:40 +0200 (EET) Date: Thu, 7 Mar 2024 19:29:40 +0200 From: "Kirill A. Shutemov" To: Yosry Ahmed Cc: Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra , Andy Lutomirski , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org 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> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240307133916.3782068-3-yosryahmed@google.com> On Thu, Mar 07, 2024 at 01:39:15PM +0000, Yosry Ahmed wrote: > During context switching, if we are not switching to new mm and no TLB > flush is needed, we do not write CR3. However, it is possible that a > user thread enables LAM while a kthread is running on a different CPU > with the old LAM CR3 mask. If the kthread context switches into any > thread of that user process, it may not write CR3 with the new LAM mask, > which would cause the user thread to run with a misconfigured CR3 that > disables LAM on the CPU. I don't think it is possible. As I said we can only enable LAM when the process has single thread. If it enables LAM concurrently with kernel thread and kernel thread gets control on the same CPU after the userspace thread of the same process LAM is already going to be enabled. No need in special handling. -- Kiryl Shutsemau / Kirill A. Shutemov