Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp204752lqp; Thu, 4 Apr 2024 10:39:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmYq0E4wuDI9BXX1r0qkVUun/GTH2+QejSgrQrWvd3tNbgpRXRUDcEeP1sAytmpEHXEEUdkuEyHgq4Xad2BMb33TuIR70IlcjyGr+OnQ== X-Google-Smtp-Source: AGHT+IHkFMzLZN9w7FU+n4e9+27YX21akOKTX1eHLGPoFWonmMcn6kWl0nHT9EtUtSXBdgsETTux X-Received: by 2002:ac8:5f14:0:b0:434:335d:f91 with SMTP id x20-20020ac85f14000000b00434335d0f91mr3052606qta.33.1712252347387; Thu, 04 Apr 2024 10:39:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712252347; cv=pass; d=google.com; s=arc-20160816; b=IvOJ3gCWWJu6dul7PrGn9fu4PQwEQLzV1PqMtAM+zx+EQaK1DJqHI8Gz6Da9rte4rN KEKYliMOnBYKBZFsnI7N+6xFXizLbLkmtXkPkbmisUDWzyOviRfreZ/Ajtn5ckL2n7iO qnJmqDWnhw5Js5J1yBOS/xP0OPnb17ySfc3o9hOHKUmstwIlK1WYoj1uPx9QcZZxoozf 7Ih6NBE8Mhzfj9FPdMpmD2jPcIY6Onr0ckNhbpjUBshR12hgvUNbePCi1C7vkEq9XRwd 9LExJJ8GKzJbdA2Sw27dy4h2cwqUTgdTGjCOw//12jHkoBXxmeKRA1LCewxE+Mrti1XD nADQ== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=6qg9D9xyZvxgVjppZfp0BcGWMCAZDJNa67XVy34o9AE=; fh=8RyG5+2fMgScLOzqe4eipl6+OoKTMoDOp9FS+slVTq4=; b=fwsZ1Ds/mUIKZF6oSejkT2ZF3Dmjq5UPaFwmdfI4SABsuIRaZ5H5GDSVXNotXPXGVQ IvO8T6TyFf28vSKorEfOUFGqu+G9Hug32JIkfSFeeZKIcrjCOzZF/UbaAU9j3wVWPRN4 0hcA9URod6b14VRpdlrGCljdtlgrVtjqphB0VNxNht1W39Eb1VPJDcspOY2pvkgylwpb uxZtZ/WRCsXnM6It/TuqnsjuFqrJIMmr/0Pmwjlre7kWUexd68cyf4q5csbycX0Iomwe ZGcFQv8fqifd4wrTahp9pxtHy+5DVwNlPvKXFL2KvoaWz5Samp/zgyJsfgDY5jyIdmVT qhfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i2YHbv1R; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-131897-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131897-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s12-20020a05622a018c00b0043433f31c8fsi6495292qtw.5.2024.04.04.10.39.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 10:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131897-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i2YHbv1R; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-131897-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131897-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 228BA1C26AA1 for ; Thu, 4 Apr 2024 17:39:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88F1812CDB0; Thu, 4 Apr 2024 17:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i2YHbv1R" 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 B47BE848A for ; Thu, 4 Apr 2024 17:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712252341; cv=none; b=lZUmSFYoY2KzrYGIYiYX5uFt3nTSput7eVzYuF48FM8NR7bZvRZjTY9iE37oDDXLyxLc+RE4Fz/74M6rURRSqwg7Y6Jc0DbGxjs0Y84u50miu30R4EfpB5tk6qOBP+AOWLdx3apTHTI8qZNzlw1woB63p4V3A/0juRXmAKbO7pc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712252341; c=relaxed/simple; bh=Gwc7Mbp5isXbI0Uoz22ItrePrRCxrLBZd8oPSQyBVUs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bd7jYpxqPnVNdLYeN4Ov7ASnHbLCL+3xerEOzohgnkkhqhkKFqIFslwU1vhcU7owzrqXIVKWZY7goaulM6LTSaXWntb1ak3kZSPuQONQTkThGTvnnDjxs4HCQlCvxGEhs7WAVJjz1A6UEO3ONJQrrxhXDcd/8kdi7Ih694nt2jk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i2YHbv1R; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA41C433C7; Thu, 4 Apr 2024 17:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712252341; bh=Gwc7Mbp5isXbI0Uoz22ItrePrRCxrLBZd8oPSQyBVUs=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=i2YHbv1RudOFgqsTfPM2H/xiYgpmhLNKeOCiYaHUVbS8Thh+oPjPFRclhGhP9dFYR CaKv3+/UhGRnH0EtkJRr1jfEAbyS+L5eCMwzV66O8lKcJUOS2uccQUKmmx0BZ+CaCu v/xhGvT/HVnH11lcEm6nzY37205VS5vuiQ8LzT8Syro3jyZ1CmDtuZrxv0Hf3g5+/z VzO6HZLo+P31NH6PZyAU5Qa3DDR78rOVQlhECw1pvmk1KppseAbGxakOXjX/0ejZ/k xki8JF+RRslLEp7MrgWuxBUjNZvcVcuqteXbchRzurFaVwDtjWTcJFMChmafAYXC+k fLiw1HHye88CA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D6F42CE0D0C; Thu, 4 Apr 2024 10:39:00 -0700 (PDT) Date: Thu, 4 Apr 2024 10:39:00 -0700 From: "Paul E. McKenney" To: Feng Tang Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Zhengxu Chen , Danielle Costantino , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Peter Zijlstra , Waiman Long , John Stultz , Boqun Feng , Neeraj Upadhyay Subject: Re: [PATCH RFC v2 tsc] Check for sockets instead of CPUs to make code match comment Message-ID: <4b6724fb-2fb7-4081-ba1d-0797d746d9b8@paulmck-laptop> Reply-To: paulmck@kernel.org References: <62a0a0cd-3103-4e8f-b4c8-a91f12121e92@paulmck-laptop> 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: On Thu, Apr 04, 2024 at 01:08:56PM +0800, Feng Tang wrote: > On Wed, Apr 03, 2024 at 12:10:41PM -0700, Paul E. McKenney wrote: > > 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. > > > > Changes since v1: > > > > o Forward-port to v6.9-rc1. > > > > Reported-by: Zhengxu Chen > > Reported-by: Danielle Costantino > > Signed-off-by: Paul E. McKenney > > Cc: Thomas Gleixner > > Cc: Ingo Molnar > > Cc: Borislav Petkov > > Cc: Dave Hansen > > Cc: "H. Peter Anvin" > > Cc: Peter Zijlstra > > Cc: Feng Tang > > Cc: Waiman Long > > Cc: John Stultz > > Cc: Neeraj Upadhyay > > Cc: > > > > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > > index 5a69a49acc963..e938b990bea19 100644 > > --- a/arch/x86/kernel/tsc.c > > +++ b/arch/x86/kernel/tsc.c > > @@ -1289,7 +1289,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) > > Regarding package/socket number, Thomas' topology refactoring patchset > (merged in 6.9-rc1) makes topology_max_packages() more accurate than > nr_online_nodes(), more details in https://lore.kernel.org/lkml/20240327025105.2861341-1-feng.tang@intel.com/ Thank you, and updated with attribution. Thanx, Paul