From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.119 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796036125; b=GZ6JHVUo3avh0xqbBtOT9SnkHY4NWzeHQ4vlxHz2KDHo9Ts0vHM/RO/Ug2TYgy++pWet niDW9eCyiFcMNZ5cH1LM088oXORcRS9da1cffA4PLRqrU/czsRkVdBC7nnRyhAWgyi8kb ous7r82mYRMTDeZQg6VPmU70WOSkqTCortaSe3sLOEFeF0gknR2i3I+j8HGQSlec3Poel KQNEgY5C4ARUKPFMowVKaNesVCeNy8MfubwsM6AVU54xlcpzpoLZvl7VJgfCXafoLio2z VhrXWCP5Q1SlTvFent90M0kiGQJRBM5kAbaXWfu4t2CxbWpMWf58dQ8MdKh7cV4eAmw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796036125; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=yAMUI7RJjSftZlsnA5CcRqTEysy8bdtsXQM8XzTC3N0=; b=GYcGlBaeJVgdHIXfxlVCdphYPXl52KuOqHdUTCwf5cFPswrfBkTkxbNq2pWlW2Vo2+uH 1sVddp7/9dsVIRKS7k8NDx5E9C20Jn42qeEROL2fBg+61KDspztlIYQLL0On9lYgJ6Pbq c7NCpFGmFa0tAi2majvjUyyJlJ8Jn+uBezhTLAAPSRv5dwpjWyU+r6S+AN46C0UxNSLkI Ge/Ik/1lm0BmeTllGHQnHYow9qUPhoZwdpKPm73CpZD2pjy9UCM/81wkNl8bowLFrr6yx 85cO0hMYBO7Tmb0ZrNrn8JjfkwS/ZPYy+gWiL0U58us4AqUpl1PaRmA4MG/HLUfigkw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=b8RbNfcM; arc=none smtp.remote-ip=115.124.30.119 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D13B606A31C; Mon, 30 Nov 2026 10:55:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1D13B606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=b8RbNfcM DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796036119; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=yAMUI7RJjSftZlsnA5CcRqTEysy8bdtsXQM8XzTC3N0=; b=b8RbNfcMb5XTgq/yvhM22u75BDkUUhfZswPHdi1GDYNHAtZ7m9YAQcsNZJHS+RHyBjnThKPrqGpRkCDu+DT7pbGa2ZayuM7o6zhkc8afpcBM6nUCApT9v/Qgpet8JIdfpU6VloxNzuwVIQkOdomtYaEycROlbdrMSuE3F72iWrM= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R291e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=qinyuntan@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0XFk0N6F_1796036118; Received: from 30.178.69.131(mailfrom:qinyuntan@linux.alibaba.com fp:SMTPD_---0XFk0N6F_1796036118 cluster:ay36) by smtp.aliyun-inc.com; Mon, 30 Nov 2026 18:55:19 +0800 Message-ID: <6b2e7e63-56a0-4bfe-a86c-67cbfd5f83b1@linux.alibaba.com> Date: Mon, 30 Nov 2026 18:55:16 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] tools/power turbostat: Fix average format for CPU/core perf counters To: "Zhang, Rui" , "lenb@kernel.org" Cc: "michael.hebenstreit@intel.com" , "linux-pm@vger.kernel.org" , "xlpang@linux.alibaba.com" , "linux-kernel@vger.kernel.org" References: <20261124032723.157254-1-qinyuntan@linux.alibaba.com> <20261124032723.157254-2-qinyuntan@linux.alibaba.com> <766176a7044fcb1886bf65b3a908c7f0a354fd6a.camel@intel.com> From: Qinyun Tan In-Reply-To: <766176a7044fcb1886bf65b3a908c7f0a354fd6a.camel@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/27/26 1:53 PM, Zhang, Rui wrote: > On Tue, 2026-11-24 at 11:27 +0800, Qinyun Tan wrote: >> Perf counters added with the average format report interval deltas at >> CPU and core scope instead of the latest counter values. Their >> summary >> rows consequently average the deltas rather than the counter values. >> >> delta_thread() and delta_core() only preserve FORMAT_RAW perf >> counters. >> FORMAT_AVERAGE falls through to subtraction before the summary is >> calculated. >> >> Preserve FORMAT_AVERAGE values in both perf counter loops, matching >> the >> existing handling in delta_package() and the MSR counter loops. >> >> Fixes: dcd1c379b0f1 ("tools/power turbostat: add format "average" for >> external attributes") >> Signed-off-by: Qinyun Tan > > Then what about the PMT counters? > > This is an interesting finding. It appears to reveal a broader > inconsistency in RAW/AVERAGE handling across the regular, perf and PMT > counter loops in delta_package(), delta_core() and delta_thread(). > > Len, > is there any intentional reason for FORMAT_AVERAGE perf or PMT counters > to undergo subtraction? or we didnt assume they exist? > > If no source-specific handling is needed here, could we use a common > macro for the preserve-versus-subtract operation? That would simplify > these loops and keep their format handling consistent: > > #define UPDATE_COUNTER(ptr, i, member) \ > do { \ > if ((ptr)->format == FORMAT_RAW || \ > (ptr)->format == FORMAT_AVERAGE) \ > old->member[i] = new->member[i]; \ > else \ > old->member[i] = new->member[i] - old->member[i]; \ > } while (0) > > The callers would use UPDATE_COUNTER(mp, i, counter), > UPDATE_COUNTER(pp, i, perf_counter) and UPDATE_COUNTER(ppmt, i, > pmt_counter), retaining any counter-specific processing around them. > Hi Rui, Len, Thanks for pointing this out. I checked the PMT path: dcd1c379b0f1 added "average" to parse_add_command_pmt(), but the PMT loops in delta_thread(), delta_core() and delta_package() still only preserve FORMAT_RAW. pmt_read_counter() returns the current field value. This appears inconsistent with the intended meaning of "average", but I may be missing a PMT-specific reason. Len, should FORMAT_AVERAGE preserve the latest reading for PMT as well? If so, I can extend the fix to cover these paths. We could also consolidate the preserve-versus-subtract logic as Rui suggested. Thanks, Qinyun Tan > thanks, > rui >