Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp4229686rba; Tue, 2 Apr 2024 10:46:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXO33FdZQUV8pENzbfB5Xp5KN8uN52Fwb6iOvO48AreuFUOa7yytnn/kSdGbxXWfqEbBeOk31gmv+6W7cmOo8RZBkncvWPr1pj5EqfViw== X-Google-Smtp-Source: AGHT+IGnwRxaW8+jCPBjiL4AyHYVyxkRpp3T2vEMDutnzX7LQqpOZOhMgsbsdNvAqpStkVVVzE9s X-Received: by 2002:a17:906:5487:b0:a4e:e7:20e4 with SMTP id r7-20020a170906548700b00a4e00e720e4mr7183268ejo.77.1712079996991; Tue, 02 Apr 2024 10:46:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712079996; cv=pass; d=google.com; s=arc-20160816; b=XZ3qUHy+KHgaOsThWjTjoyhFYW/dMQM0J6JOYaqY7aDAVFmSq/cMBA3K6L6qq3tDD7 YbkxcJ1FJVa8MmrfRgoMreyW+DNOg5rvGKoHU7CZ9hUgEiaz9TFcA+taJwo2bbBd6F0E DEyPxw4pNtB5IVHh1AjdbL+qhb8wXU59C6UdTMC516+urKIItwcXT4/JElr3avTr5bLG sV3twHTkpGl04gsoMtmnDS3ggQYlM753Rc06CaJadV24Zsrkl5oTl1f/LgeYp90VkhaI yAlETHtKZ87KFbz8oho02bSRqGO1s9urrUNId/tOcspeFVqPvAcx3dBDaoCyfEzZIq91 w4tA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=2uQrT4OPUnJJ7qwQbuOJ3w/i96EgMem11ZKbGpAMb2I=; fh=P6CRCaiYvvE94J14DbO8l4OdMby/5kfG5jfSs+1/2sQ=; b=Ls7xl9U7kxh+QdQcrACpAF/nHZmCKLqhz2xB/9t+i6PKg2zkjRGpagDenRHVXSoHHc AUVMVcB3gAc9JHsSDSUUSkAmpuRDga3L1674TvM7DYU2Xn6FhtLP/ObmlT3ILPCliLy/ GVE6bDAZRQ0nYPkha9YG5YpuJ9ddSDQVk3mxzfVwJyt6kNn68g8mFGvb965N/RU6NGIE q3c1iP3/9tHn4V0HTLXL8cOGsx7IXQBaWjwLceyzAYWmD3nCTn8Ldw8HG1Q6tY2/i4cR ts4UkTwwGlts71gqIB0zLZjiKHWC/IXnkfhzz43iTE0BYjOml/SSf2+NGTUVP9WMUrew U05A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-128453-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hr20-20020a1709073f9400b00a4e34cd0fa7si4720487ejc.562.2024.04.02.10.46.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 10:46:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128453-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-128453-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128453-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 am.mirrors.kernel.org (Postfix) with ESMTPS id BF13A1F22D8E for ; Tue, 2 Apr 2024 17:46:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B3EA15A4B3; Tue, 2 Apr 2024 17:46:06 +0000 (UTC) Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 538CD159910; Tue, 2 Apr 2024 17:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712079965; cv=none; b=haqs8ZSXLYmJqmS48c/w9ovTKUf5K+D0F9yPImD4CsvKVEkjwe+9Lwya7XPGaDEcMk9qKYpBGgHPXONUBvAb8fzhWnyePkEGJQ6vPD+d3Cll9CHDokF3RO6/C8uGFVa+MB76djUi4gDTI0dBD7ngFv6LRooLE/Ejk40FzIWNUp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712079965; c=relaxed/simple; bh=y93SZIbrnH2U1PRuoMZgbJFzq72nN3iSwDY/ntn2yG4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=g4MhYki6EqtD3XOY2bCm7m4pLUsq7DZZzCYnfD29PehkUiPLVFC85hE88YeL0Mui3ismoHF5yqhynf2yLcXBsMdenykK0drrRhiYO+puMdGhIvdRNFv/IMCEKEbSIKChhmA9Z0VImfGPXlGrfUwj9+bKTJ5c77K370KZ7+CbKWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-22e82734a13so340260fac.2; Tue, 02 Apr 2024 10:46:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712079962; x=1712684762; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2uQrT4OPUnJJ7qwQbuOJ3w/i96EgMem11ZKbGpAMb2I=; b=aFFTkTSB8K5BO/G7LsPLPxGWr+JEEIXSYsAFAYbp+XilZztyq87tJ3IpcYWGB4EcLq 6a/DhiyV47XRICYWOUi8qzH40IouOTqNgIMOsbiFBULMJubxWWaIu+RkQ24qm17nwQCN QiJtAo2tT9gs/trxNiXfP0vAEXBsDmpVgTJl/fKAiw8wLOOMQFVi8+SzWrgCGRq1NCsh TB8n4e0r1fFdl/5V7NJ2KHEdZw61+1FD6/iiDZA6aM8y8kVGGk+PNam217/xc61PGMhV MqU4lhhinEI3/9xiDDb+SpVoEaFGD1uLoZEqqqhe3wXwovWi1kdnOs0I4koH7dDHvD+c vLsg== X-Forwarded-Encrypted: i=1; AJvYcCX2UGh81Ai+h0ylBCJDvhF2DKdynhJguRjrz6zR7Tw/HjEKmstA3vE14V0cKyxrggtwM175u5rLs5H+10OSycVFPWCkDvXpDXsPSIdn X-Gm-Message-State: AOJu0YyC1xzLwdsfErStwyhSwvt4jleJQlKB/v5OyH6p7550UVgamkFb JS+Ingvwo3wEEEvmiISd15qzJbEQ/Ijpjb/WcfS7afEJ2Bq9rlwUmNVSgKvKwNy1GJF1yM4Ca7t miTvdHD6raEgMS5vr26KcWqLAvO0= X-Received: by 2002:a05:6871:7a2:b0:222:a91a:63cd with SMTP id o34-20020a05687107a200b00222a91a63cdmr12864139oap.45.1712079962239; Tue, 02 Apr 2024 10:46:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240308204957.2007212-1-justin.ernst@hpe.com> In-Reply-To: <20240308204957.2007212-1-justin.ernst@hpe.com> From: Len Brown Date: Tue, 2 Apr 2024 13:45:50 -0400 Message-ID: Subject: Re: [PATCH] tools/power/turbostat: Fix uncore frequency file string To: Justin Ernst Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the patch, Justin, Looks like the probe part of this was already fixed in my git tree, so I lopped off that hunk and kept your 1st hunk. Let me know if it works, or if I screwed it up. latest is in this tree: https://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git/ thanks, -Len On Fri, Mar 8, 2024 at 3:50=E2=80=AFPM Justin Ernst = wrote: > > Running turbostat on a 16 socket HPE Scale-up Compute 3200 (SapphireRapid= s) fails with: > turbostat: /sys/devices/system/cpu/intel_uncore_frequency/package_010_die= _00/current_freq_khz: open failed: No such file or directory > > We observe the sysfs uncore frequency directories named: > ... > package_09_die_00/ > package_10_die_00/ > package_11_die_00/ > ... > package_15_die_00/ > > The culprit is an incorrect sprintf format string "package_0%d_die_0%d" u= sed > with each instance of reading uncore frequency files. uncore-frequency-co= mmon.c > creates the sysfs directory with the format "package_%02d_die_%02d". Once= the > package value reaches double digits, the formats diverge. > > Change each instance of "package_0%d_die_0%d" to "package_%02d_die_%02d". > > Signed-off-by: Justin Ernst > --- > tools/power/x86/turbostat/turbostat.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turb= ostat/turbostat.c > index 7a334377f92b..2a15a23cb726 100644 > --- a/tools/power/x86/turbostat/turbostat.c > +++ b/tools/power/x86/turbostat/turbostat.c > @@ -2599,7 +2599,7 @@ unsigned long long get_uncore_mhz(int package, int = die) > { > char path[128]; > > - sprintf(path, "/sys/devices/system/cpu/intel_uncore_frequency/pac= kage_0%d_die_0%d/current_freq_khz", package, > + sprintf(path, "/sys/devices/system/cpu/intel_uncore_frequency/pac= kage_%02d_die_%02d/current_freq_khz", package, > die); > > return (snapshot_sysfs_counter(path) / 1000); > @@ -4589,20 +4589,20 @@ static void probe_intel_uncore_frequency(void) > for (j =3D 0; j < topo.num_die; ++j) { > int k, l; > > - sprintf(path, "/sys/devices/system/cpu/intel_unco= re_frequency/package_0%d_die_0%d/min_freq_khz", > + sprintf(path, "/sys/devices/system/cpu/intel_unco= re_frequency/package_%02d_die_%02d/min_freq_khz", > i, j); > k =3D read_sysfs_int(path); > - sprintf(path, "/sys/devices/system/cpu/intel_unco= re_frequency/package_0%d_die_0%d/max_freq_khz", > + sprintf(path, "/sys/devices/system/cpu/intel_unco= re_frequency/package_%02d_die_%02d/max_freq_khz", > i, j); > l =3D read_sysfs_int(path); > fprintf(outf, "Uncore Frequency pkg%d die%d: %d -= %d MHz ", i, j, k / 1000, l / 1000); > > sprintf(path, > - "/sys/devices/system/cpu/intel_uncore_fre= quency/package_0%d_die_0%d/initial_min_freq_khz", > + "/sys/devices/system/cpu/intel_uncore_fre= quency/package_%02d_die_%02d/initial_min_freq_khz", > i, j); > k =3D read_sysfs_int(path); > sprintf(path, > - "/sys/devices/system/cpu/intel_uncore_fre= quency/package_0%d_die_0%d/initial_max_freq_khz", > + "/sys/devices/system/cpu/intel_uncore_fre= quency/package_%02d_die_%02d/initial_max_freq_khz", > i, j); > l =3D read_sysfs_int(path); > fprintf(outf, "(%d - %d MHz)\n", k / 1000, l / 10= 00); > -- > 2.26.2 > --=20 Len Brown, Intel