Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2620405lqt; Mon, 22 Apr 2024 17:03:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWhOrT5PVTtLJ1nrRWm7wBxxvCLgkpn1K92JCh1MONvuGg6/laxr+LFsjWxYlFiCgbtAfQaKYNshKMCrgwQnMLks//f5wX3omrOXhkKg== X-Google-Smtp-Source: AGHT+IGKRZz4yXsJKBu1YrhdOOu2ZgvYrAvLWnLYvDJGeOHTH7Hy5qCH4QgU88w44tHuCup05+Nh X-Received: by 2002:a05:6a00:398e:b0:6ed:4aaa:3cbf with SMTP id fi14-20020a056a00398e00b006ed4aaa3cbfmr16441158pfb.3.1713830635509; Mon, 22 Apr 2024 17:03:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713830635; cv=pass; d=google.com; s=arc-20160816; b=FQiVaKv7gpys+a1288upLv05HKO/yC0ba1A31toBkNbkC7Iv0afM2rYFJJcqiNC5AH hYZbDn+Av4Vkr4IbV8NdkMz90yKkg7OUajkSWVOXq0zeB1NpKbz88AD16J9VEyLwFmpY DctxFf+L4hwL4hOutIq+nAubTWyWcs2nWTC/PvSL4PLYldzWbk5EgIfEO8FyWmDymJuW jYC2oE251YJZJVvRGH/arO4jpjEc3A5FPuMdtQ+NNB5LrIowqzGb0CCCvtlQV3J9fzd2 Z7XUpF/8bA9l/ZtdBZzki0jkHsx7r4hZeYePxhxP82+/s6PcqZ//FnWOg4VpOKLUrCZb MIJg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hJG3AKMEOs23woq+5biKvwnvoSDM4TKucn9QUFriDew=; fh=THIdcIsvB896trHcfDOoOTou3SggOqc5rufOTuh8aOo=; b=u2/p6gH3oqwe6WSr96fBxe6spsMgufnw0wEBH7ugD1V9JMIdN/AJjmxtlFQI/Z5J9L gO81VWNJTYeWIPHrspkbn2nSZ+tcH6owYl1q7dQPK+tSpb8HFcXIJlHmc10df4AKHHPQ SJ4wxexSEulf4EMvu4D5gmicr+eb0kEZWZnwCu6yfDHWFPimSOS4bYYu5d0QBwq2aAq5 A+xH9dFtMd7Y+c+p2BByOiCKtpeC9Hc5VIgnKIh1e5pJ8dDVYsNASKIboeDR09ckBl5X igFEyZK8FK0hsvItdH14upIPn+qkvaJ0G3v4YE4OzgRoQGaUx84HbTZUICgrd8yDSADh NM/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A4HPjKq9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l33-20020a635721000000b005f7599d981fsi8547845pgb.259.2024.04.22.17.03.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 17:03:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154222-linux.lists.archive=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=@kernel.org header.s=k20201202 header.b=A4HPjKq9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154222-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0F543B23F46 for ; Mon, 22 Apr 2024 23:55:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F50315380D; Mon, 22 Apr 2024 23:54:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A4HPjKq9" 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 ABD1745BE6; Mon, 22 Apr 2024 23:54:09 +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=1713830049; cv=none; b=ThHroU6E6d5HgARdfSZHmXzo7SUl2WXbomM86riW1gaVue1DACvAcljsQ7DaSNl+7brVCEaUAxJVVk55eqnriro1pcOX7wbf56xVMROIIc10aPx2MMK5GjbnYW85Ua7/FdmEX6lB5dyz9YlUxElh8amAbtoC6JqY03kTl2IXis0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713830049; c=relaxed/simple; bh=qnDKUlHMSb5MO6Fab/lvnAJUlwxF6Ou6HrkWgUUcltE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JIhzw/7USGGAQQ/OX2YzLbbiqq6ff+eLlcDF+tMj0VXeUhEEJMI/jQsBuL4NJn2dn/JCVFTHfIoweidNEe2GPpLtCYdPD9GAlP9L72u2GYT+OJtF4eaRx2ALW2YBnFAUlSl3No82DuKy7P+SjwFf0+h9Yc5rWqjhc5EBQuv+mpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A4HPjKq9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCFB0C4AF07; Mon, 22 Apr 2024 23:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713830049; bh=qnDKUlHMSb5MO6Fab/lvnAJUlwxF6Ou6HrkWgUUcltE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4HPjKq9qPGA35ctPq9GUZ/0TYkmbtujyINGCDr8W107YAwXFI9mS53/WAhE2sA9W 0zjdzEOcBAWrnCViQsN2fYGNYPTwUj/fxsW1MYZN+E18gXZf1rLiS1AIC1N3wFKRGp pehR3+I7YQSrygN9y1Wx3iCKNp+AtqRdW77xsOzzxOPog1JW62Ikj77y1fnr6OuPca A/pWFqjqhVsocThqvF/eOpLF4n0xZfuvYoA0JI4perAtHBoQ4+mVlt6lF3y0tATtxm OvlzwaB4Pi+SZS1qgXzQATTk5PIiK5/MSxNvZo9wKRjNMgwnm45yN2rb6soKxDxzu5 vEGhv7F3fKfoA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Len Brown , Sasha Levin , lenb@kernel.org, linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 6.8 05/43] tools/power turbostat: Expand probe_intel_uncore_frequency() Date: Mon, 22 Apr 2024 19:13:51 -0400 Message-ID: <20240422231521.1592991-5-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422231521.1592991-1-sashal@kernel.org> References: <20240422231521.1592991-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.7 Content-Transfer-Encoding: 8bit From: Len Brown [ Upstream commit bb6181fa6bc942aac3f7f2fa8e3831952a2ef118 ] Print current frequency along with the current (and initial) limits Probe and print uncore config also for machines using the new cluster API Signed-off-by: Len Brown Signed-off-by: Sasha Levin --- tools/power/x86/turbostat/turbostat.c | 84 ++++++++++++++++++++------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index c23703dd54aa1..bbd2e0edadfae 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -4581,20 +4581,15 @@ static void dump_sysfs_file(char *path) static void probe_intel_uncore_frequency(void) { int i, j; - char path[128]; + char path[256]; if (!genuine_intel) return; - if (access("/sys/devices/system/cpu/intel_uncore_frequency/package_00_die_00", R_OK)) - return; - - /* Cluster level sysfs not supported yet. */ - if (!access("/sys/devices/system/cpu/intel_uncore_frequency/uncore00", R_OK)) - return; + if (access("/sys/devices/system/cpu/intel_uncore_frequency/package_00_die_00/current_freq_khz", R_OK)) + goto probe_cluster; - if (!access("/sys/devices/system/cpu/intel_uncore_frequency/package_00_die_00/current_freq_khz", R_OK)) - BIC_PRESENT(BIC_UNCORE_MHZ); + BIC_PRESENT(BIC_UNCORE_MHZ); if (quiet) return; @@ -4602,26 +4597,73 @@ static void probe_intel_uncore_frequency(void) for (i = 0; i < topo.num_packages; ++i) { for (j = 0; j < topo.num_die; ++j) { int k, l; + char path_base[128]; + + sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d", i, + j); - sprintf(path, "/sys/devices/system/cpu/intel_uncore_frequency/package_0%d_die_0%d/min_freq_khz", - i, j); + sprintf(path, "%s/min_freq_khz", path_base); k = read_sysfs_int(path); - sprintf(path, "/sys/devices/system/cpu/intel_uncore_frequency/package_0%d_die_0%d/max_freq_khz", - i, j); + sprintf(path, "%s/max_freq_khz", path_base); l = read_sysfs_int(path); - fprintf(outf, "Uncore Frequency pkg%d die%d: %d - %d MHz ", i, j, k / 1000, l / 1000); + fprintf(outf, "Uncore Frequency package%d die%d: %d - %d MHz ", i, j, k / 1000, l / 1000); - sprintf(path, - "/sys/devices/system/cpu/intel_uncore_frequency/package_0%d_die_0%d/initial_min_freq_khz", - i, j); + sprintf(path, "%s/initial_min_freq_khz", path_base); k = read_sysfs_int(path); - sprintf(path, - "/sys/devices/system/cpu/intel_uncore_frequency/package_0%d_die_0%d/initial_max_freq_khz", - i, j); + sprintf(path, "%s/initial_max_freq_khz", path_base); l = read_sysfs_int(path); - fprintf(outf, "(%d - %d MHz)\n", k / 1000, l / 1000); + fprintf(outf, "(%d - %d MHz)", k / 1000, l / 1000); + + sprintf(path, "%s/current_freq_khz", path_base); + k = read_sysfs_int(path); + fprintf(outf, " %d MHz\n", k / 1000); } } + return; + +probe_cluster: + if (access("/sys/devices/system/cpu/intel_uncore_frequency/uncore00/current_freq_khz", R_OK)) + return; + + if (quiet) + return; + + for (i = 0;; ++i) { + int k, l; + char path_base[128]; + int package_id, domain_id, cluster_id; + + sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/uncore%02d", i); + + if (access(path_base, R_OK)) + break; + + sprintf(path, "%s/package_id", path_base); + package_id = read_sysfs_int(path); + + sprintf(path, "%s/domain_id", path_base); + domain_id = read_sysfs_int(path); + + sprintf(path, "%s/fabric_cluster_id", path_base); + cluster_id = read_sysfs_int(path); + + sprintf(path, "%s/min_freq_khz", path_base); + k = read_sysfs_int(path); + sprintf(path, "%s/max_freq_khz", path_base); + l = read_sysfs_int(path); + fprintf(outf, "Uncore Frequency package%d domain%d cluster%d: %d - %d MHz ", package_id, domain_id, + cluster_id, k / 1000, l / 1000); + + sprintf(path, "%s/initial_min_freq_khz", path_base); + k = read_sysfs_int(path); + sprintf(path, "%s/initial_max_freq_khz", path_base); + l = read_sysfs_int(path); + fprintf(outf, "(%d - %d MHz)", k / 1000, l / 1000); + + sprintf(path, "%s/current_freq_khz", path_base); + k = read_sysfs_int(path); + fprintf(outf, " %d MHz\n", k / 1000); + } } static void probe_graphics(void) -- 2.43.0