Re: [RFC 5/6] perf/tools: Enhance JSON/metric infrastructure to handle "?"

From: kajoljain
Date: Tue Jan 21 2020 - 05:18:26 EST



On 1/17/20 9:58 PM, Andi Kleen wrote:
On Fri, Jan 17, 2020 at 06:16:19PM +0530, Kajol Jain wrote:
Patch enhances current metric infrastructure to handle "?" in the metric
expression. The "?" can be use for parameters whose value not known while
creating metric events and which can be replace later at runtime to
the proper value. It also add flexibility to create multiple events out
of single metric event added in json file.
Please add a proper specification how this ? thing is supposed to work,
what the exact semantics are, how it is different from the existing
# mechanism etc.

The standard way to do similar things before was to define an explicit
# name and let the expr code take care of it.

Hi Andi,

ÂÂÂ Thanks for reviewing my patchset.

I did review the existing '#' mechanism. It is quiet useful for runtime
dependency (like ex. event selection based on a return value). But I want
to handle couple of more things. Meaning, filling in parameter of event code
based on runtime value and replicating events at runtime.

So the '?' can handle, 1) replacement of a value in the event code based on runtime

and 2) replicate the event (metric expr) at runtime (handled in new metricgroup__add_metric()).

This patchset add an arch specific function called 'arch_get_runtimeparam'. Ideally,
arch_get_runtimeparm() returns the number of metric exps one want to create (it defaults to 1).
The loop added in 'metricgroup__add_metric' will handle the event addition.

Example ppc64 hv_24x7 pmu metric event using '?':

(hv_24x7@PM_MCS01_128B_RD_DISP_PORT01\\,chip\\=?@ + hv_24x7@PM_MCS01_128B_RD_DISP_PORT23\\,chip\\=?@)

Here, '?' will be replaced with a runtime value and metric expression will be replicated.

Thanks,

Kajol

-Andi