Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp493109lqt; Fri, 19 Apr 2024 01:53:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVD2/j66A/8B5BzO5K1sWPMzlS/JGVwX9vj2xqPkUGpK+Ix3UIbzKjvObUSpPNFKZTykwayW2UqK6tjQIRDr9gqYjC2/HOggiZDo8huLg== X-Google-Smtp-Source: AGHT+IHZ13bIdGE0bGXEDbs9vHY0S0ZAQqLRxMdkBKOgtb6NJ6HIBtzotR8IrFzlC9zVxLx7tdlU X-Received: by 2002:a05:6a20:dda3:b0:1a9:dcd9:9756 with SMTP id kw35-20020a056a20dda300b001a9dcd99756mr1561430pzb.16.1713516812914; Fri, 19 Apr 2024 01:53:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713516812; cv=pass; d=google.com; s=arc-20160816; b=PGWAo0TKcKcZ7YS6FCcqRuqLCfyDsKPa++mmXRSymPj0UQZNCwtm54fvCL1jePKqZ0 APe5U9v8a2SLu+8huvuZYCVRyhb2Te7Vd6LInoZutMbOwGazu5AtiCn8E3cx+xaCGLlO kS3aqaRV8/Z35JpiOlx+bVpCcoecA7FJ+lk7Sx60nMvN0PasWchkP5V7XO9mmIoxSAuW Met6OOg9c2GhdhlFagbs5KuWwNzoKq9JIjAYRO+ckc262LwsZqz2SuTH0nHQKRGKOT2v b82C8eurkH9ZeE6fLu+80/Tp5JxM3U7AXCdJf3dBL/5JRUOB57eD2s40sxZWnfL4ijKJ HbiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=3kSmPAY2XS4ryCfo1DSiuqPgECXM8l4iXsIqd+cYB64=; fh=CDihOmqBBUzo9zEoz2gvhZg7Qc5aQl7cgyUgj8VFCYo=; b=qx1pXF0yiC9CWO1W3amA7H6rz42UTuDtzAjwmxe6fh/S7vfmf11VVmtYlQ0aoemE3U HCRcY9AWEhJTL+mPMx0vwctlDvrK6nqKbS2zh9x+4yFlNoBx0BWuGP4xY23PCi/lkWbG r4MDpJztIMCOdjrmey2nqOaLJggKKljMNbNRi1LLwNK8FZu1sr8Zzb1MQyv5hYytU4h2 I+4fWEvsyYQS3z7CzDkWUoDP/WP/JJyFjtfz/7id74Jx++ODXs7mbNQqSiJy7/K0oVfu XkKgCiqB4wFk3fsxzVuXnwgz+Kvvp7VGtTPav0JEBPwv/0w6OPKbxOSrfN/O7lcgZ79Y Kh6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quora.org header.s=google header.b=plMaSgpS; arc=pass (i=1 spf=pass spfdomain=quora.org dkim=pass dkdomain=quora.org); spf=pass (google.com: domain of linux-kernel+bounces-151190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151190-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s3-20020a170902a50300b001e02aae12aesi2810242plq.401.2024.04.19.01.53.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 01:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quora.org header.s=google header.b=plMaSgpS; arc=pass (i=1 spf=pass spfdomain=quora.org dkim=pass dkdomain=quora.org); spf=pass (google.com: domain of linux-kernel+bounces-151190-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151190-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E8450B217C9 for ; Fri, 19 Apr 2024 08:51:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B1196FE14; Fri, 19 Apr 2024 08:51:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=quora.org header.i=@quora.org header.b="plMaSgpS" Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 136BC3E485 for ; Fri, 19 Apr 2024 08:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713516715; cv=none; b=fuCBBJoU49sLV6UQtSZqIpCjOmof6FZWDU6rMlZeEaiy0Dh6duZXbMyoMlCh7O02BGT29f+U8WOaw4MROh7869U9E7wH+Nyl/ZYEWhprfh1vcAcrV62AG8MOUV7p1Nen0rDOiMDpcJxR6S3/QbD+NgjR6bYnYkc+HputQstOzho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713516715; c=relaxed/simple; bh=mXEa3/fr+2Yd+gOLSZ48gbNrkoHV+D8vEycijLzI+ok=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fPZ+zpuOOyUBjcaQ7s9NQqWWzmErin6iTrb4bHUO9AhK0MEEM2/5PEXS3BrdiP7RBd6M+oM8ddIeV7NDbEbVKu4LdvBANT/p0/pVNYaLb68c2R4NIqWTZymPdOX3UOTvWu1tGW1we9St2K0pj8zdDRdoh5Vd3/yutcK4B0dvWbg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=quora.org; spf=pass smtp.mailfrom=quora.org; dkim=pass (1024-bit key) header.d=quora.org header.i=@quora.org header.b=plMaSgpS; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=quora.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quora.org Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2a5215314a4so1331949a91.0 for ; Fri, 19 Apr 2024 01:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quora.org; s=google; t=1713516712; x=1714121512; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3kSmPAY2XS4ryCfo1DSiuqPgECXM8l4iXsIqd+cYB64=; b=plMaSgpSv+JdwfhcHMP0pujgbkpnLujYCDp9eeACcsxE7Wo9XzwpqOGH3g6VfkQ9l0 opDEZHzg+Hldt2QRLcd03ocZvlwDntv36kGEMJz58eUoiHrfCzc6JJ8LS7bz7VB0dXCz xFJrbscAcfOc9bYgoFYRtTwkXRAIZhndlcVYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713516712; x=1714121512; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3kSmPAY2XS4ryCfo1DSiuqPgECXM8l4iXsIqd+cYB64=; b=XCUKyxhf/nsfnnTIDpwRqSQUrC/6zPbxdPc+48nFIui+kas8RgJdct3Ovvfre4AS5R uW6JlvEqaY0xSjV67RNPyYPtiiw9shfbchMJ0dh6W/RGPYR0ziGXk9qnevsjBXsCOAs9 ArXBfQCl0ravbJrbctpHx3cVOgcVofVBeMEThXIxEvFLlTg8wVX+BvpabUT+lQbSu3lE dXSU7xvt1jlnlth1BiISavJ9IQVC0ZWYNAOUmYmYIOzXur/LVffRFhD5ZmgJN+mhWgt5 ZBP4G70h9pcP+juWLsK0Qf1+5E6VQGWBYPwGqbVeVJEancx9AZedAhphyWVZhBbRGbuv IVww== X-Forwarded-Encrypted: i=1; AJvYcCWX5nps3AphSDc6GOYgNM62cJA9iADlPxircd0D+Et6xshqJiAoyszVZ7lk4gAnUojSwSQmSvBwd5DO7lLKX1vUa2s3cFT1GIDOOjzo X-Gm-Message-State: AOJu0Ywxm9z4AvEkfVpY2kvJ77TLv3p7aDcfDYMBjwWElrF3S85z2fir SnFzbH0krXO8FLUj4LGbTA5PcZoXiVuElrN/Rk2Tb6IChFQhdVirNIfKuz4yrDo= X-Received: by 2002:a17:90b:24d:b0:2ac:9ee:a7a0 with SMTP id fz13-20020a17090b024d00b002ac09eea7a0mr1526287pjb.1.1713516712249; Fri, 19 Apr 2024 01:51:52 -0700 (PDT) Received: from nuc.. ([202.83.99.71]) by smtp.gmail.com with ESMTPSA id hg19-20020a17090b301300b0029c472ec962sm4430566pjb.47.2024.04.19.01.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 01:51:51 -0700 (PDT) From: Daniel J Blueman To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Cc: x86@kernel.org, "H. Peter Anvin" , "Peter Zijlstra" , linux-kernel@vger.kernel.org, Daniel J Blueman , Steffen Persvold , James Cleverdon , Dimitri Sivanich , Steve Wahl , Prarit Bhargava , Frank Ramsay , Russ Anderson Subject: [PATCH v2] x86: Trust initial offset in architectural TSC-adjust MSRs Date: Fri, 19 Apr 2024 16:51:46 +0800 Message-Id: <20240419085146.175665-1-daniel@quora.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the BIOS configures the architectural TSC-adjust MSRs on secondary sockets to correct a constant inter-chassis offset, after Linux brings the cores online, the TSC sync check later resets the core-local MSR to 0, triggering HPET fallback and leading to performance loss. Fix this by unconditionally using the initial adjust values read from the MSRs. Trusting the initial offsets in this architectural mechanism is a better approach than special-casing workarounds for specific platforms. Signed-off-by: Daniel J Blueman Reviewed-by: Steffen Persvold Reviewed-by: James Cleverdon Reviewed-by: Dimitri Sivanich Cc: Steve Wahl Cc: Prarit Bhargava Cc: Frank Ramsay Cc: Russ Anderson --- Changes in v2: - Maintain comment based on feedback - Rebase against v6.9-rc4 arch/x86/kernel/tsc_sync.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c index 1123ef3ccf90..4334033658ed 100644 --- a/arch/x86/kernel/tsc_sync.c +++ b/arch/x86/kernel/tsc_sync.c @@ -193,11 +193,9 @@ bool tsc_store_and_check_tsc_adjust(bool bootcpu) cur->warned = false; /* - * If a non-zero TSC value for socket 0 may be valid then the default - * adjusted value cannot assumed to be zero either. + * The default adjust value cannot be assumed to be zero on any socket. */ - if (tsc_async_resets) - cur->adjusted = bootval; + cur->adjusted = bootval; /* * Check whether this CPU is the first in a package to come up. In -- 2.40.1