public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org,
	Stephane Eranian <eranian@google.com>,
	Andi Kleen <ak@linux.intel.com>,
	Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Subject: Re: [PATCH 3/3] perf report: Add weight[123] output fields
Date: Tue, 9 Apr 2024 14:18:19 -0400	[thread overview]
Message-ID: <16587efd-ab12-463a-bd87-7721adfc731d@linux.intel.com> (raw)
In-Reply-To: <CAM9d7cizZLMNa82VxuuvEWEY3vwdbs_iTG9jsogJQBoWMLP7Fw@mail.gmail.com>



On 2024-04-09 12:53 p.m., Namhyung Kim wrote:
> Hi Kan,
> 
> On Tue, Apr 9, 2024 at 9:37 AM Liang, Kan <kan.liang@linux.intel.com> wrote:
>>
>>
>>
>> On 2024-04-08 8:06 p.m., Namhyung Kim wrote:
>>> Add weight1, weight2 and weight3 fields to -F/--fields and their aliases
>>> like 'ins_lat', 'p_stage_cyc' and 'retire_lat'.  Note that they are in
>>> the sort keys too but the difference is that output fields will sum up
>>> the weight values and display the average.
>>>
>>> In the sort key, users can see the distribution of weight value and I
>>> think it's confusing we have local vs. global weight for the same weight.
>>>
>>> For example, I experiment with mem-loads events to get the weights.  On
>>> my laptop, it seems only weight1 field is supported.
>>>
>>>   $ perf mem record -- perf test -w noploop
>>>
>>> Let's look at the noploop function only.  It has 7 samples.
>>>
>>>   $ perf script -F event,ip,sym,weight | grep noploop
>>>   # event                         weight     ip           sym
>>>   cpu/mem-loads,ldlat=30/P:           43     55b3c122bffc noploop
>>>   cpu/mem-loads,ldlat=30/P:           48     55b3c122bffc noploop
>>>   cpu/mem-loads,ldlat=30/P:           38     55b3c122bffc noploop    <--- same weight
>>>   cpu/mem-loads,ldlat=30/P:           38     55b3c122bffc noploop    <--- same weight
>>>   cpu/mem-loads,ldlat=30/P:           59     55b3c122bffc noploop
>>>   cpu/mem-loads,ldlat=30/P:           33     55b3c122bffc noploop
>>>   cpu/mem-loads,ldlat=30/P:           38     55b3c122bffc noploop    <--- same weight
>>>
>>> When you use the 'weight' sort key, it'd show entries with a separate
>>> weight value separately.  Also note that the first entry has 3 samples
>>> with weight value 38, so they are displayed together and the weight
>>> value is the sum of 3 samples (114 = 38 * 3).
>>>
>>>   $ perf report -n -s +weight | grep -e Weight -e noploop
>>>   # Overhead  Samples  Command   Shared Object   Symbol         Weight
>>>        0.53%        3     perf   perf            [.] noploop    114
>>>        0.18%        1     perf   perf            [.] noploop    59
>>>        0.18%        1     perf   perf            [.] noploop    48
>>>        0.18%        1     perf   perf            [.] noploop    43
>>>        0.18%        1     perf   perf            [.] noploop    33
>>>
>>> If you use 'local_weight' sort key, you can see the actualy weight.
>>>
>>>   $ perf report -n -s +local_weight | grep -e Weight -e noploop
>>>   # Overhead  Samples  Command   Shared Object   Symbol         Local Weight
>>>        0.53%        3     perf   perf            [.] noploop    38
>>>        0.18%        1     perf   perf            [.] noploop    59
>>>        0.18%        1     perf   perf            [.] noploop    48
>>>        0.18%        1     perf   perf            [.] noploop    43
>>>        0.18%        1     perf   perf            [.] noploop    33
>>>
>>> But when you use the -F/--field option instead, you can see the average
>>> weight for the while noploop funciton (as it won't group samples by
>>
>> %s/funciton/function/
>>
>>> weight value and use the default 'comm,dso,sym' sort keys).
>>>
>>>   $ perf report -n -F +weight | grep -e Weight -e noploop
>>>   # Overhead  Samples  Weight1  Command  Shared Object  Symbol
>>>        1.23%        7     42.4  perf     perf           [.] noploop
>>
>> I think the current +weight shows the sum of weight1 of all samples,
>> (global weight). With this patch, it becomes an average (local_weight).
>> The definition change may break the existing user script.
>>
>> Ideally, I think we should keep the meaning of the weight and
>> local_weight as is.
> 
> Hmm.. then we may add 'avg_weight' or something.
> 
> But note that there's a subtle difference in the usage.  If you use
> 'weight' as a sort key (-s weight) it'd keep the existing behavior
> that shows the sum (global_weight).  It'd show average only if
> you use it as an output field (-F weight).
>

As my understanding, the -F weight is implicitly replaced by the -F
weight1 with this patch. There is no way to get the sum of weight with
-F anymore.

I think that's a user visible behavior change. At least, we have to warn
the end user with a message, e.g., "weight is not supported with -F
anymore. Using weight1 to instead". Only updating the doc may not be enough.

> The issue of the sort key is that it cannot have the total sum
> of weights for a function.  It'll have separate entries for each
> weight for each function like in the above example.
> 

That seems to be a different issue. If the total sum of weights for a
function is required, we should fix the existing "weight".

Thanks,
Kan

  reply	other threads:[~2024-04-09 18:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09  0:06 [PATCH 1/3] perf hist: Move histogram related code to hist.h Namhyung Kim
2024-04-09  0:06 ` [PATCH 2/3] perf hist: Add weight fields to hist entry stats Namhyung Kim
2024-04-09  0:06 ` [PATCH 3/3] perf report: Add weight[123] output fields Namhyung Kim
2024-04-09 16:37   ` Liang, Kan
2024-04-09 16:53     ` Namhyung Kim
2024-04-09 18:18       ` Liang, Kan [this message]
2024-04-09 19:27         ` Namhyung Kim
2024-04-10 13:40           ` Liang, Kan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16587efd-ab12-463a-bd87-7721adfc731d@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox