From patchwork Fri Mar 1 03:36:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Chen X-Patchwork-Id: 208669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp898095dyb; Thu, 29 Feb 2024 22:45:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUC7JBk3cJw7xj2PEVoDzcw+glcnKCg91QMpc5frMGaty1ZB2Q//x+8j+/F8AqdO0YJOWW5HorS1BHRKBEC7oTKCihbsQ== X-Google-Smtp-Source: AGHT+IElkjw6xvCPi5xPusCEAqiqUSIKyOA/FroHjBKUJSPNoGZ55QJsvAJOV3ME7uUvBmtyPVi9 X-Received: by 2002:a17:902:d50e:b0:1dc:7bc:3527 with SMTP id b14-20020a170902d50e00b001dc07bc3527mr1043282plg.19.1709275559538; Thu, 29 Feb 2024 22:45:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709275559; cv=pass; d=google.com; s=arc-20160816; b=zUljkO4Rn9FUBLN8GuTtwMEL16k/1/2PNv8OFEsRBadElhB/qCR4/XLev+U78P3F+T K41eeijKk2IrfLlfCnf6tmnM6XuKDMATNT+hBH/ARDorLwHMTAO0+G/bLo12rNpm+wHF eI7n/+HzJq3jl/lgAbgar+CPZJnoG6jUR4N8Ofv2b6eUFHwmz/50cA1M/E+aRkY/8iMg vt/alphbZZzTtjberqoKKchQCSlbnrtIF1qONTYYKmxneleRLGvwZa+dIog/pfyIhgxy OLWHYdHJc5io6VzoJNgZ0fIgXPcN7lovzjZsv1RBa6ZwUpW/HO3C1MjFeckgO0hSQw/L yOrQ== 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=TGbzLc9+NihC81SvsTEjc+SAK4C+iurz3FRNgEJKaNQ=; fh=4Qs5kjcN5r7FQE41hwssbkzJ2AplcGMAjmThUx37Ipw=; b=rsXe7Lou91d5aRwiv4R/1L2JoxJmV1P7qVDfp+5SmjpV1a4pDJvdWPS2cgcmzglc4t tyQddkzyGVgcolq4FC9bH+yogJG5WS/hdnSusVUHCMdh4SeOI8iPpPe1n1XQAn5Ha1Mc pyRn2gAnWc4nazOCd+7eEIVTV7rHgcKNUVU5w3vPawi5Sbwx+nYxeZ2BYh6L8KqFj4aB TZKbNvjxNSy33auLJ+qdc158eEXGNrh8C4m0/YFI/ICeav+CIK8Ri4uPePogv/X50cKQ ZA2OeDQQE5yA7+VsZLQwOG1vhavbZJWM3i/FDzUfpybnsIWvXtHTd7JtwheNgHPInbsZ Pnlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@smartx-com.20230601.gappssmtp.com header.s=20230601 header.b=n4dYeRjg; arc=pass (i=1 dkim=pass dkdomain=smartx-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-87876-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87876-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l19-20020a170902f69300b001d8ecf3d0fbsi3086673plg.511.2024.02.29.22.45.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 22:45:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87876-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@smartx-com.20230601.gappssmtp.com header.s=20230601 header.b=n4dYeRjg; arc=pass (i=1 dkim=pass dkdomain=smartx-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-87876-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87876-ouuuleilei=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 0954DB2423A for ; Fri, 1 Mar 2024 03:40:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0507C50279; Fri, 1 Mar 2024 03:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.b="n4dYeRjg" Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 104804EB3A for ; Fri, 1 Mar 2024 03:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709264276; cv=none; b=SoiEzF2kz4K6Lfuj+3avjRxy4mjZb7prmITXrINLdf+EFs/v/BmBHPXHlV++ZwBcMm1CLoxZ0RNuCUR6xGXQOtYy9irzGESML2Ui5Rozp22BwqPAVeXlvrkpDhPobg1x+eY1gKR+rAq7VoEfhRLWsAiDR5pl+MISk/zVgQ8xgXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709264276; c=relaxed/simple; bh=OWjOUeXIrnaIZjrBhzUDk1/hM5siEVz3QO+rz/2I9uo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hkbabb3LCXPbOyRuB2YSJ49EUCDinrLs1KFDBHs9fixniK5XEO+Ty46M2+1RYRIJJ3O5xEVvIFE+LGerNXuLfzh88l5glW+yqmWqt/ilKXplYqerXvf5cD/6AfOlnkrDJTb+mvY+d0+6YLNcEtHJAAaZU6TU3kZaOo/tIfW7nxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com; spf=none smtp.mailfrom=smartx.com; dkim=pass (2048-bit key) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.b=n4dYeRjg; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=smartx.com Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e5a50d91b4so1036693b3a.2 for ; Thu, 29 Feb 2024 19:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1709264273; x=1709869073; 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=TGbzLc9+NihC81SvsTEjc+SAK4C+iurz3FRNgEJKaNQ=; b=n4dYeRjg4d5bnqwsfJDa2H7gxENGSmaTmFZIClv/flA/T+Hs9dvxLkGL1D6psCzb8y WNztgwqJj7qHAsvPs30yHd7cgEABieMNWxuloRqfPS5lwq6J9xs/Z13FUu52i6hdfK8H I6u0cEptVyJWRbKjT78Djebd+nwNnmnskmAjzp1VkGoFw8MCFjzW1y1U5ZbUW1GfnpDP 9FfssXkMkB2t3cO5B1/zWijm9DjBbfbGBQLi40aNus/6BMW+aoa36l0QPnbOis5VNq4P WKviT3rVlc1hWGk0z/poHz4JesIHPeJjh+Mgzb1sIOvV/4E3uLVD5NRbENWoa8FKlR40 4iiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709264273; x=1709869073; 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=TGbzLc9+NihC81SvsTEjc+SAK4C+iurz3FRNgEJKaNQ=; b=trusih1KM8EoiVWka0IfbVwytc2K+qZUUsPf2WRKyiHo3Q4zT4NWzgX5+sRQdkvIdN q8Qn1+0pD72nlutI4fyfI+0QCofNdR4+Lek8D6snfC9mnHqjc6+fKFjLq64linQ9W+Ti SsNawth+SXFyfuKYrWHLg0t3kvah7+H+nyzls3INap33KHjUAXTy73FECbXK/rBLjH1l WHpaNYb8osuyKDuwk+e+T0dnUXiHi9DG4BEgBRXC/HcwvIsrv3EV1P4NwQ+PwskPgwrX k4sOFGMRFl9qM9a+xNpC79+Wfs8tzwCdx/BSHDNz2yGdp52vKA2B2eOHXDF0Y+Z0QbLu L87g== X-Forwarded-Encrypted: i=1; AJvYcCU8KecU6Aev4Kex35V3bi/+vYsEnsFJd2QnhaQu6OQxw7ZdNmUE6peIUBebHwuC2Ve3RYLI1MertoGoClEigrqTovDJkh/5CDMKQHvA X-Gm-Message-State: AOJu0YwCu6EBZ+Wr7UhUfHyxAXAMT+JHbvyyybp7N8grMMaD7z+eWTst IMjqDsrq93NOz0gWWujWTo2aXpNImszHfyktpIXTSEZ6KVUaBR6TpDUaaSOBtnE= X-Received: by 2002:aa7:88cd:0:b0:6e5:58a5:ceb2 with SMTP id k13-20020aa788cd000000b006e558a5ceb2mr722202pff.29.1709264272912; Thu, 29 Feb 2024 19:37:52 -0800 (PST) Received: from localhost.localdomain ([8.210.91.195]) by smtp.googlemail.com with ESMTPSA id t34-20020a056a0013a200b006e554f91e66sm1980995pfg.49.2024.02.29.19.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 19:37:52 -0800 (PST) From: Lei Chen To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: Lei Chen , linux-kernel@vger.kernel.org Subject: [PATCH] x86/tsc: print some log if calibrated tsc freq deviates from original too much Date: Thu, 29 Feb 2024 22:36:09 -0500 Message-ID: <20240301033610.1719052-1-lei.chen@smartx.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792305329459125205 X-GMAIL-MSGID: 1792305329459125205 In most cases, tsc_khz is refined by hpet on boot. But in a few production-level nodes, the refinement fails because calibrated freq diviates from origin tsc freq more than 1%. Printing some logs will help get this info. Signed-off-by: Lei Chen --- arch/x86/kernel/tsc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 15f97c0abc9d..a68b16e72df1 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -1435,8 +1435,15 @@ static void tsc_refine_calibration_work(struct work_struct *work) } /* Make sure we're within 1% */ - if (abs(tsc_khz - freq) > tsc_khz/100) + if (abs(tsc_khz - freq) > tsc_khz/100) { + pr_warn("Warning: TSC freq calibrated by [%s]: %lu.%03lu MHz deviates too much from original freq: %lu.%03lu MHz\n", + hpet ? "HPET" : "PM_TIMER", + (unsigned long)freq / 1000, + (unsigned long)freq % 1000, + (unsigned long)tsc_khz / 1000, + (unsigned long)tsc_khz % 1000); goto out; + } tsc_khz = freq; pr_info("Refined TSC clocksource calibration: %lu.%03lu MHz\n",