2019-08-21 21:54:14 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2017-09-01 03:40:31 +08:00
|
|
|
#ifndef METRICGROUP_H
|
|
|
|
#define METRICGROUP_H 1
|
|
|
|
|
2019-08-21 21:54:14 +08:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/rbtree.h>
|
|
|
|
#include <stdbool.h>
|
2020-09-07 14:41:32 +08:00
|
|
|
#include "pmu-events/pmu-events.h"
|
2019-08-21 21:54:14 +08:00
|
|
|
|
2020-09-24 20:44:53 +08:00
|
|
|
struct evlist;
|
2019-08-21 21:54:14 +08:00
|
|
|
struct evsel;
|
|
|
|
struct option;
|
|
|
|
struct rblist;
|
2020-06-03 05:47:36 +08:00
|
|
|
struct pmu_events_map;
|
2020-09-24 20:44:53 +08:00
|
|
|
struct cgroup;
|
2017-09-01 03:40:31 +08:00
|
|
|
|
|
|
|
struct metric_event {
|
|
|
|
struct rb_node nd;
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *evsel;
|
2017-09-01 03:40:31 +08:00
|
|
|
struct list_head head; /* list of metric_expr */
|
|
|
|
};
|
|
|
|
|
2020-07-20 02:13:10 +08:00
|
|
|
struct metric_ref {
|
|
|
|
const char *metric_name;
|
|
|
|
const char *metric_expr;
|
|
|
|
};
|
|
|
|
|
2017-09-01 03:40:31 +08:00
|
|
|
struct metric_expr {
|
|
|
|
struct list_head nd;
|
|
|
|
const char *metric_expr;
|
|
|
|
const char *metric_name;
|
perf metricgroup: Scale the metric result
Some metrics define the scale unit, such as
{
"BriefDescription": "Intel Optane DC persistent memory read latency (ns). Derived from unc_m_pmm_rpq_occupancy.all",
"Counter": "0,1,2,3",
"EventCode": "0xE0",
"EventName": "UNC_M_PMM_READ_LATENCY",
"MetricExpr": "UNC_M_PMM_RPQ_OCCUPANCY.ALL / UNC_M_PMM_RPQ_INSERTS / UNC_M_CLOCKTICKS",
"MetricName": "UNC_M_PMM_READ_LATENCY",
"PerPkg": "1",
"ScaleUnit": "6000000000ns",
"UMask": "0x1",
"Unit": "iMC"
},
For above example, the ratio should be,
ratio = (UNC_M_PMM_RPQ_OCCUPANCY.ALL / UNC_M_PMM_RPQ_INSERTS / UNC_M_CLOCKTICKS) * 6000000000
But in current code, the ratio is not scaled ( * 6000000000)
With this patch, the ratio is scaled and the unit (ns) is printed.
For example,
# 219.4 ns UNC_M_PMM_READ_LATENCY
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20190828055932.8269-4-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-08-28 13:59:31 +08:00
|
|
|
const char *metric_unit;
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel **metric_events;
|
2020-07-20 02:13:10 +08:00
|
|
|
struct metric_ref *metric_refs;
|
perf metricgroups: Enhance JSON/metric infrastructure to handle "?"
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.
Patch adds function 'arch_get_runtimeparam' which is a arch specific
function, returns the count of metric events need to be created. By
default it return 1.
This infrastructure needed for hv_24x7 socket/chip level events.
"hv_24x7" chip level events needs specific chip-id to which the data is
requested. Function 'arch_get_runtimeparam' implemented in header.c
which extract number of sockets from sysfs file "sockets" under
"/sys/devices/hv_24x7/interface/".
With this patch basically we are trying to create as many metric events
as define by runtime_param.
For that one loop is added in function 'metricgroup__add_metric', which
create multiple events at run time depend on return value of
'arch_get_runtimeparam' and merge that event in 'group_list'.
To achieve that we are actually passing this parameter value as part of
`expr__find_other` function and changing "?" present in metric
expression with this value.
As in our JSON file, there gonna be single metric event, and out of
which we are creating multiple events.
To understand which data count belongs to which parameter value,
we also printing param value in generic_metric function.
For example,
command:# ./perf stat -M PowerBUS_Frequency -C 0 -I 1000
1.000101867 9,356,933 hv_24x7/pm_pb_cyc,chip=0/ # 2.3 GHz PowerBUS_Frequency_0
1.000101867 9,366,134 hv_24x7/pm_pb_cyc,chip=1/ # 2.3 GHz PowerBUS_Frequency_1
2.000314878 9,365,868 hv_24x7/pm_pb_cyc,chip=0/ # 2.3 GHz PowerBUS_Frequency_0
2.000314878 9,366,092 hv_24x7/pm_pb_cyc,chip=1/ # 2.3 GHz PowerBUS_Frequency_1
So, here _0 and _1 after PowerBUS_Frequency specify parameter value.
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lore.kernel.org/lkml/20200401203340.31402-5-kjain@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-04-02 04:33:37 +08:00
|
|
|
int runtime;
|
2017-09-01 03:40:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct metric_event *metricgroup__lookup(struct rblist *metric_events,
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *evsel,
|
2017-09-01 03:40:31 +08:00
|
|
|
bool create);
|
|
|
|
int metricgroup__parse_groups(const struct option *opt,
|
2020-05-21 02:20:10 +08:00
|
|
|
const char *str,
|
|
|
|
bool metric_no_group,
|
|
|
|
bool metric_no_merge,
|
|
|
|
struct rblist *metric_events);
|
2021-10-16 01:21:15 +08:00
|
|
|
const struct pmu_event *metricgroup__find_metric(const char *metric,
|
|
|
|
const struct pmu_events_map *map);
|
2020-06-03 05:47:36 +08:00
|
|
|
int metricgroup__parse_groups_test(struct evlist *evlist,
|
2021-10-16 01:21:13 +08:00
|
|
|
const struct pmu_events_map *map,
|
2020-06-03 05:47:36 +08:00
|
|
|
const char *str,
|
|
|
|
bool metric_no_group,
|
|
|
|
bool metric_no_merge,
|
|
|
|
struct rblist *metric_events);
|
|
|
|
|
2019-02-13 20:32:41 +08:00
|
|
|
void metricgroup__print(bool metrics, bool groups, char *filter,
|
|
|
|
bool raw, bool details);
|
2018-06-26 15:17:01 +08:00
|
|
|
bool metricgroup__has_metric(const char *metric);
|
2021-10-16 01:21:15 +08:00
|
|
|
int arch_get_runtimeparam(const struct pmu_event *pe __maybe_unused);
|
2020-06-03 05:47:38 +08:00
|
|
|
void metricgroup__rblist_exit(struct rblist *metric_events);
|
2020-09-24 20:44:53 +08:00
|
|
|
|
|
|
|
int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp,
|
|
|
|
struct rblist *new_metric_events,
|
|
|
|
struct rblist *old_metric_events);
|
2017-09-01 03:40:31 +08:00
|
|
|
#endif
|