Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1150063rbb; Sun, 25 Feb 2024 23:27:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXaGqYVYOtIihKQj/2B/WnZd8q+tbU7cdqLtVJ+EIvsIQcedAqqMxVkHEDVJtFtm/mC4RqjaO5e1ay2aT9beDhScygsKke5LtdYSlrSVw== X-Google-Smtp-Source: AGHT+IF2dYQ8IKxbJOR+w5YYqyrvoT08mF07mqUzXEQIH6PZC3lVCmsYQkwWhj7iLXLoe6LQVdWN X-Received: by 2002:aa7:d5c4:0:b0:565:cbe9:eea7 with SMTP id d4-20020aa7d5c4000000b00565cbe9eea7mr2361952eds.25.1708932420514; Sun, 25 Feb 2024 23:27:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708932420; cv=pass; d=google.com; s=arc-20160816; b=ZyH+ejPSlPQ0SPA+Y8gtmVmZrjTwgwFHxdJz9HuJWsZEXz+/n1K9qrVHtUuDt2EMZ5 RDaw0qgN23xJRL9ba+5GBKO1mCJAGfu8+YEQ9yka5BPB7+vukCp1TeoLYVg4XQwC/Loy ketSmSxX8jMLyv/yQSaNC6oB+QutZK3bOxmJngF5o4rSOpzzcU7uqaWjU6dOg9keFclx aMR291ttDOxgWhG+uISw9RyJoDDRXl6ZT+5C99SXs6vTd5KlRSwz7/mPkSo+pIpDkT51 BbeTmvplgSOKuqPeRRW50heg0xXM6GqT6HZL9SSHKOmgrIPU0DrTdenZi7Gc44+2K4sh 2tlA== 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=VjePcL8BUGrL8noDvW1Os1K5ntKu4PXsZjDkWTtsAqk=; fh=hpJQDtT/wiGCHxUjTkhomYJErgVJq9zL3e0jTuxtIQM=; b=CK+dhZfRYp2uasWvRCrTMkNHszRxmPHUQGIg1TmzKtZVOuZasgt3kLEuJS9tbgRzeg EwBsLYjk9kmIvHDMlO+buhhgCGlgBj7+RDdLECCE0yCfXOlq2Rt8uB98WRnhjO9A1Djr XfIhlpUo+3oVQTKUiYySk823oZwu6HkQInTPtICkMQxNtD95kStcI9yY75SgtR0Qv/8G 9oHd/1gHf7SwjvOwFdHi22vjig0PNsHyQV1Gjnlw+kMIoxuhG6bkWVojlLTGkSmSJFR7 HPs53nxmCcKqJpEYqT8u5Tdkr1Q6DmrZcjIHClpdqwNd3c5S74BBBQaL9gTesLA3M0ix r3yQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quora.org header.s=google header.b=id8ndVyY; arc=pass (i=1 spf=pass spfdomain=quora.org dkim=pass dkdomain=quora.org); spf=pass (google.com: domain of linux-kernel+bounces-80631-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80631-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n29-20020a5099dd000000b005641711f02bsi1825003edb.344.2024.02.25.23.27.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 23:27:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80631-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=@quora.org header.s=google header.b=id8ndVyY; arc=pass (i=1 spf=pass spfdomain=quora.org dkim=pass dkdomain=quora.org); spf=pass (google.com: domain of linux-kernel+bounces-80631-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80631-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 194001F212F0 for ; Mon, 26 Feb 2024 07:26:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C736F1BF24; Mon, 26 Feb 2024 07:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=quora.org header.i=@quora.org header.b="id8ndVyY" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 6468F1BDCB for ; Mon, 26 Feb 2024 07:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708932391; cv=none; b=OSNpAFDejCbJHWle6vhyEMfIp/AmbGUXxkZl0tzx5+yIFx+pz+H0DrQHVnqC0lOWcwNdIHP9UNs+1O8WKYnhgGppifIYrNi2BaWPv6ZeLkAM2rCT0p8Wd2yrU3qxt4QhX3Krif6WXv9CWP1/jBsJCjR9Ryq0TRM+XELe1tOgDnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708932391; c=relaxed/simple; bh=qPsFkvdA/kFCDJ8vwXsssv+4A2ZY6yjRRpNtVPWmndY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=RfKakdGIaorQ6V1ZYY717KaTD7T/2NH1FyQUr3xP/gw1yMLtfVqMaa0jMwSRfKIanohTU8YGvr0SnFRmRmBGpjmW3DrVt5bWOQrLKcIMdwVJUdtQOiDwmCxuVXsASZeSiA7MuctWI/w3wAWINSMzbYni+AEdxWi4cXntGnqjoBk= 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=id8ndVyY; arc=none smtp.client-ip=209.85.210.172 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-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e4f49c5632so301690b3a.0 for ; Sun, 25 Feb 2024 23:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quora.org; s=google; t=1708932389; x=1709537189; 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=VjePcL8BUGrL8noDvW1Os1K5ntKu4PXsZjDkWTtsAqk=; b=id8ndVyY7kXyenCTzHI83Upr/rpxOphevcJsuMR8LdIyBEVMTRvlslr2ksktepVNK1 xVCH8tw2wWtMOBYiYGoW3wjdaYd6ZVBUlgEHPhoy8SaQPgWLRWqpTpS4N0RCrGDDhYqM gZCuECmGVtxLVREQXEEtFaQgr+FS2s05Aa4Zw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708932389; x=1709537189; 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=VjePcL8BUGrL8noDvW1Os1K5ntKu4PXsZjDkWTtsAqk=; b=q3EwLox12ZRoTQqa5/GxbMhxd98/6D3xh7Vsh1G7TNfmH1qfeFUPV/s3DAdofSd8z1 IxzY8XWfuQEidnC2ho+fcd8qeNHNRu9TzlO8we5km9SrUtgwF8hVwh/PN+VYLVXrczW/ vTx4UJlkSQrJlgac4gINe9rQblTm9DJf+g7EVnR0QBT5Z61i4fD6TrTchVBL8N2emWlb m1uo5CEJAyMjm908X7oTsb1QzcTzACS0Suedc6GrXCEpGJul/tjotPypwZGQ/DddLcCl sOfbWYsHiqrYMVVemvolLJ0RZ+pxCeszm98ybZF6XnAuTy4p5+DUvS2HwS6Z7cOMmoZn Sy/Q== X-Forwarded-Encrypted: i=1; AJvYcCU432xOzZOWS3OjK8iCxD7DKolPYfZvm0xh5P9yNvLXmXUKqOEinGa2F5EtL0ZQbMKt536njQ78+1TzG5O0Tmc4FHmwMB2v4m49nZjG X-Gm-Message-State: AOJu0Yw8FiYKLXsSyxd8+8ybzUhoFJEjHs44NWGee0pXVAEC6QMRxtnO J4oEvpTQBj2vmCIqd0Klc4txbazYhjnRJHjtK+13NMwylwqEWvCL9vSZhEOrkBI= X-Received: by 2002:a05:6a00:93a6:b0:6e5:35c8:ef06 with SMTP id ka38-20020a056a0093a600b006e535c8ef06mr769332pfb.31.1708932389515; Sun, 25 Feb 2024 23:26:29 -0800 (PST) Received: from nuc.quora.org ([202.83.99.71]) by smtp.gmail.com with ESMTPSA id ey11-20020a056a0038cb00b006e144ec8eafsm3405624pfb.119.2024.02.25.23.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 23:26:29 -0800 (PST) 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 Subject: [PATCH] x86: Trust initial offset in architectural TSC-adjust MSRs Date: Mon, 26 Feb 2024 15:25:33 +0800 Message-Id: <20240226072533.341382-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 --- arch/x86/kernel/tsc_sync.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c index 1123ef3ccf90..cd64b25154d7 100644 --- a/arch/x86/kernel/tsc_sync.c +++ b/arch/x86/kernel/tsc_sync.c @@ -188,17 +188,10 @@ bool tsc_store_and_check_tsc_adjust(bool bootcpu) return false; rdmsrl(MSR_IA32_TSC_ADJUST, bootval); - cur->bootval = bootval; + cur->adjusted = cur->bootval = bootval; cur->nextcheck = jiffies + HZ; 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. - */ - if (tsc_async_resets) - cur->adjusted = bootval; - /* * Check whether this CPU is the first in a package to come up. In * this case do not check the boot value against another package -- 2.40.1