Message ID | fcd476e1-f580-4954-9032-6c25686f0575@paulmck-laptop |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-15001-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4758338dyb; Tue, 2 Jan 2024 16:31:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxDnzq0yC/virQ60o0w7Y+/OXAhzHocOEjGPIBuDjElY10vU3//jXqDHw7ojvR2dvzBikN X-Received: by 2002:a17:906:d6:b0:a28:2d88:582a with SMTP id 22-20020a17090600d600b00a282d88582amr1125190eji.79.1704241919787; Tue, 02 Jan 2024 16:31:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704241919; cv=none; d=google.com; s=arc-20160816; b=Zq/41lJmu0D0vthYA1p8vUjQVPey2+uHRN1pP7NQhaPIEtrzB8HosyARnDNH9FdawO uwrF/W+2OJUcZOI5nPVcQcsjSPeRNWPQ3ut04FgxyWSa8LdlOfndI8+b3K++YTudxHn/ 6EIYiUEGR8avnLH3q6S1M81htWYJb58oYi8dWxqrix/MSUfphd9gzF7WL6kjURW1REU/ Ei0ad+PqkZO/IAqoS9juDHXglMySFWObd+zQ1/zyLbKPALKGfvTEmLno9ybGrHi0vgXT Eh7VqKTwYpwoCogeg1cJWxu3VAm8p79/HwzRdAZpBwlXC9i+Y7Xxwb8X36T4MHCY+lQT Xzyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=QjNkQAhusaOQTc56iP3ktEhJKnVc4JnoApSOmiw8y8E=; fh=AHzoIEtFTrZ5qQudBgIGjY66cZaOVH4xzttwc0Gd+hQ=; b=irgFsyhknBmu+1nFs+pZn1zRxFp/SppOjrrLeD+JAsuvP8aTzYqFxJ7rPYwEE/9EGq xJLCYjmWIOfsVCKMM8bZJ+ZfVIbLfru0wG/ePWSLNOmgdZEZ2TemBuCI5nu8M9ZpD8Kl RZGmiBcCz8mXcghVs76qIr3phl2vMBoLjf2CrB8CRQWvVwfrItF2d7pq2FSUHDurdH5D MduVZ+Gpa/AdSilc+k16SNxiDTrgQtg+2dRVxY7kYpeb/MQ82BhFijgbGdwXu2dqtK2e E754MkjGhZYYYtrS5/URE8soQA+RvSaytyRNkG2ELfhXLl5U66Oh9gg7OpF10sXRGHqD 981Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=toCVBpww; spf=pass (google.com: domain of linux-kernel+bounces-15001-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15001-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id wh16-20020a170906fd1000b00a26ae03344csi9995388ejb.99.2024.01.02.16.31.59 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:31:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15001-ouuuleilei=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=@kernel.org header.s=k20201202 header.b=toCVBpww; spf=pass (google.com: domain of linux-kernel+bounces-15001-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15001-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 656181F22DCB for <ouuuleilei@gmail.com>; Wed, 3 Jan 2024 00:31:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC19EEC6; Wed, 3 Jan 2024 00:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="toCVBpww" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6161863C for <linux-kernel@vger.kernel.org>; Wed, 3 Jan 2024 00:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C52C2C433C8; Wed, 3 Jan 2024 00:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704241902; bh=c0hwMhIsCKXtfxkXFf6Gq2t1ll9WqyctEcwEz2UIEzo=; h=Date:From:To:Cc:Subject:Reply-To:From; b=toCVBpwwe1KnDV9/ZLIg406/wJF600ZU0JSCrpOfr4XneRIJiu2+tXkSsaQHZ4Hyi Vgg0jBeumqWujmxRLxhqm4j9Sq+twZdIngDDEd03T9nWrPcmD1DITLPu2B9kJAdPS0 FGh1MU8SKjFKu8thStTnxhWmKEsJoTBZQanQ/bI4hWmjRhJ46A84JrvnQ6Kbq/BpCx ctHlKoHbHf9nqfHOlJCYj0aXueWfijSBld5LMyM3fJn/oGB6Kqtl5/CK/8N+WC1gt7 YjcorpTd/Uk0K6ZHXts1iGdyahPbmB4GwswSz2+uah18QV68dr6ZF1b3aIR6Dcp9tQ ro9DjrJf3kLpQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5A15FCE16DA; Tue, 2 Jan 2024 16:31:42 -0800 (PST) Date: Tue, 2 Jan 2024 16:31:42 -0800 From: "Paul E. McKenney" <paulmck@kernel.org> To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: zhxchen17@meta.com, dcostantino@meta.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, feng.tang@intel.com, longman@redhat.com, jstultz@google.com Subject: [PATCH RFC tsc] Check for sockets instead of CPUs to make code match comment Message-ID: <fcd476e1-f580-4954-9032-6c25686f0575@paulmck-laptop> Reply-To: paulmck@kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787027175383201392 X-GMAIL-MSGID: 1787027175383201392 |
Series |
[RFC,tsc] Check for sockets instead of CPUs to make code match comment
|
|
Commit Message
Paul E. McKenney
Jan. 3, 2024, 12:31 a.m. UTC
The unsynchronized_tsc() eventually checks num_possible_cpus(), and
if the system is non-Intel and the number of possible CPUs is greater
than one, assumes that TSCs are unsynchronized. This despite the
comment saying "assume multi socket systems are not synchronized",
that is, socket rather than CPU. This behavior was preserved by
commit 8fbbc4b45ce3 ("x86: merge tsc_init and clocksource code") and
by the previous relevant commit 7e69f2b1ead2 ("clocksource: Remove the
update callback").
The clocksource drivers were added by commit 5d0cf410e94b ("Time: i386
Clocksource Drivers") back in 2006, and the comment still said "socket"
rather than "CPU".
Therefore, bravely (and perhaps foolishly) make the code match the
comment.
Note that it is possible to bypass both code and comment by booting
with tsc=reliable, but this also disables the clocksource watchdog,
which is undesirable when trust in the TSC is strictly limited.
Reported-by: Zhengxu Chen <zhxchen17@meta.com>
Reported-by: Danielle Costantino <dcostantino@meta.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Feng Tang <feng.tang@intel.com>
Cc: Waiman Long <longman@redhat.com>
Cc: John Stultz <jstultz@google.com>
Cc: <x86@kernel.org>
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 15f97c0abc9d..d45084c6a15e 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -1287,7 +1287,7 @@ int unsynchronized_tsc(void) */ if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) { /* assume multi socket systems are not synchronized: */ - if (num_possible_cpus() > 1) + if (nr_online_nodes > 1) return 1; }