Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp505717rdb; Fri, 26 Jan 2024 02:14:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwrsXo91NScBPTBv1DgQzEm0TxoIuShX7d83ZdgeVzz8h7CGavFll+4GZUBtVs+X38PqqZ X-Received: by 2002:a05:620a:1a26:b0:77f:6e1f:bf68 with SMTP id bk38-20020a05620a1a2600b0077f6e1fbf68mr1339347qkb.111.1706264060888; Fri, 26 Jan 2024 02:14:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706264060; cv=pass; d=google.com; s=arc-20160816; b=FTTZUuMvRH8DP2Ck3hBXb73P22YUCpBtmiY1JYAnvUmsbZjftiDKM9M4kZPpB0hySa CeT3hFV2afnyruTBNmno7VQFzWFizp9IgcBWrjcMIbIIuBGbbAjgl5aXgNqfGq8a1kKQ jkQQRAn8Io2ClWp+xAjUyjA7kBA6gKhJkOaOtn/+dVLPmDKCnA9aCaqM2uY+iz1nCxan LMyXNlu2TilCLHChDQ35UjhdzSmm8g6rdMx3dNrrdUZHO5oy5GHZJh5mt3Et17hfiSSC F+dA/BMis//2g6KtFV1bAv9qHOQxQ+W96XQu3ezexmwztK8humV5xK1FSqgh5ekPSyxX P6iA== 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=eGMcpXe5TeykGP5mKsy5j8/AQ/YhaytXUJs4t665ld0=; fh=tFLw/PNlbwIAo2DPswVgp6UP3lE4UT5uXm0FtmzcPZ8=; b=00j3EBkVDGdbtzVlzhDsgOfpeXQz8MGAnaJuhrSpv3s28hYOYuQIbcG/fVkAY/kiqL 0hS7F9ywNBbEVkC6YMAaJrnB12Z3mA9jsSTep2A2+seKt5zrWjdXv6vER5WIJKS0QRBL YV3TTyNEOtS/FSc0NITe8CVNmnzRKvB9kYeSB4HAuKoPtPEu3Wx7nptepmz1eFqPJZd8 hdfG0QU7ApzxTIrjK2c1XMrUCMOBK4v5d8udYRfS4UU2Ct+wrY57VDOzFf7Zk203dG2h D56qQJuSVt3fS7Z+vKC6Fd37Han7B1p5muK01lqcFs/5BAJ2mcf1SJ0CbXmdLivMigLo xOZQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Xuut1Wzs; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39908-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r15-20020a05620a298f00b0078331069e2esi1017045qkp.555.2024.01.26.02.14.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 02:14:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Xuut1Wzs; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39908-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E49EC1C2ABFC for ; Fri, 26 Jan 2024 10:06:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AF7D1BDC0; Fri, 26 Jan 2024 09:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Xuut1Wzs" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 B99C91BC34 for ; Fri, 26 Jan 2024 09:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706260885; cv=none; b=cxjv02lbD5cqgPULHx/nLqEStXWstyxaAnhBGcHCAg7IsFYXYJA1Ot/zAS+6edhxgTV+rrsRulSuZIee5khLAl6rimHBfMvCRoXjtRKCIV9rBwRDz9SRndZxLPMhTCmj4EfQTFT0cQ/Ya4n5qvxyq7OMXsJq4GeY34aWbMvyYXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706260885; c=relaxed/simple; bh=6mV7VNYt7HwWXFfXqjQflzG59MR/XQAJ7cn2D6yJLfs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hhp3s3sGjHDLDXObWIf9V6q88cQW1WiY2DRjYdcfe00/AyxKVEuBtkCzlUK/+9dBh8cDBNvVIEHDDYhLAx1hbj4V1XwHQJX20NYhTVo0CmBS+oLWgDDERzi5ygzwqFGuRHRn/rgYH2zoESmBoX+YC4wnVZlGL05OyJ8JFAHVeuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Xuut1Wzs; arc=none smtp.client-ip=192.55.52.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706260883; x=1737796883; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6mV7VNYt7HwWXFfXqjQflzG59MR/XQAJ7cn2D6yJLfs=; b=Xuut1Wzs8V+OSZhANLhR1xRFeXyPNv069YvHd3sFyeoXS8GCv1xZxjfl A/1UeKxroVoZpf4EX7p+wS5ICZz9EdnjKBGpX/Ubfk7xqdCd45jzxUhRL hSLf+WWhZJg66j8emnE5eAysym4V7vvJlzhzzsPyzLBDJ1b5EPIw7qHRo tijhnwfilCA1PhPhFzp6spKJaUXF1h2w46FYtid7C6odMRlRc/NJMm8dW qgOc3noozfUMY5NQeCVQ0/9agkCpJwjnFHxAt221J9xD6VSv6s+8rYR4g Wq0q+tCdVVDnPmIhuZ6rIMYD4qQBDNSF9TOaJ/GH4oAXstA/FUw1SqMBj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="401279180" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="401279180" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 01:21:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="906261352" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="906261352" Received: from feng-clx.sh.intel.com ([10.239.159.50]) by fmsmga002.fm.intel.com with ESMTP; 26 Jan 2024 01:21:20 -0800 From: Feng Tang To: John Stultz , Thomas Gleixner , Stephen Boyd , linux-kernel@vger.kernel.org, paulmck@kernel.org, Peter Zijlstra , Waiman Long Cc: Feng Tang , Jin Wang Subject: [PATCH] clocksource: Scale the max retry number of watchdog read according to CPU numbers Date: Fri, 26 Jan 2024 17:12:50 +0800 Message-Id: <20240126091250.79985-1-feng.tang@intel.com> X-Mailer: git-send-email 2.34.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 There was a bug on one 8-socket server that the TSC is wrongly marked as 'unstable' and disabled during boot time. (reproduce rate is every 120 rounds of reboot tests), with log: clocksource: timekeeping watchdog on CPU227: wd-tsc-wd excessive read-back delay of 153560ns vs. limit of 125000ns, wd-wd read-back delay only 11440ns, attempt 3, marking tsc unstable tsc: Marking TSC unstable due to clocksource watchdog TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'. sched_clock: Marking unstable (119294969739, 159204297)<-(125446229205, -5992055152) clocksource: Checking clocksource tsc synchronization from CPU 319 to CPUs 0,99,136,180,210,542,601,896. clocksource: Switched to clocksource hpet The reason is for platform with lots of CPU, there are sporadic big or huge read latency of read watchog/clocksource during boot or when system is under stress work load, and the frequency and maximum value of the latency goes up with the increasing of CPU numbers. Current code already has logic to detect and filter such high latency case by reading 3 times of watchdog, and check the 2 deltas. Due to the randomness of the latency, there is a low possibility situation that the first delta (latency) is big, but the second delta is small and looks valid, which can escape from the check, and there is a 'max_cswd_read_retries' for retrying that check covering this case, whose default value is only 2 and may be not enough for machines with huge number of CPUs. So scale and enlarge the max retry number according to CPU number to better filter those latency noise on large system, which has been verified fine in 4 days and 670 rounds of reboot test on the 8-socket machine. Tested-by: Jin Wang Signed-off-by: Feng Tang --- kernel/time/clocksource.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index c108ed8a9804..f15283101906 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -226,6 +226,15 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 wd_end, wd_end2, wd_delta; int64_t wd_delay, wd_seq_delay; + /* + * If no user changes the default value, scale the retry threshold + * according to CPU numbers. As per test, the more CPU a platform has, + * the bigger read latency is found during boot time or under stress + * work load. Increase the try nubmer to reduce false alarms. + */ + if (max_cswd_read_retries == 2) + max_cswd_read_retries = max(2, ilog2(num_online_cpus())); + for (nretries = 0; nretries <= max_cswd_read_retries; nretries++) { local_irq_disable(); *wdnow = watchdog->read(watchdog); -- 2.34.1