Initially, every time we want to add new terms like chip, core thread etc,
we need to create corrsponding fields in pmu_events and event struct.
This patch adds an enum called 'aggr_mode_class' which store all these
aggregation like perchip/percore. It also adds new field 'aggr_mode'
to capture these terms.
Now, if user wants to add any new term, they just need to add it in
the enum defined.
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: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20200907064133.75090-4-kjain@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
#include <linux/list.h>
#include "jsmn.h"
#include "json.h"
#include <linux/list.h>
#include "jsmn.h"
#include "json.h"
char *pmu;
char *unit;
char *perpkg;
char *pmu;
char *unit;
char *perpkg;
char *metric_expr;
char *metric_name;
char *metric_group;
char *metric_expr;
char *metric_name;
char *metric_group;
char *metric_constraint;
};
char *metric_constraint;
};
+enum aggr_mode_class convert(const char *aggr_mode)
+{
+ if (!strcmp(aggr_mode, "PerCore"))
+ return PerCore;
+ else if (!strcmp(aggr_mode, "PerChip"))
+ return PerChip;
+
+ pr_err("%s: Wrong AggregationMode value '%s'\n", prog, aggr_mode);
+ return -1;
+}
+
typedef int (*func)(void *data, struct json_event *je);
int eprintf(int level, int var, const char *fmt, ...)
typedef int (*func)(void *data, struct json_event *je);
int eprintf(int level, int var, const char *fmt, ...)
fprintf(outfp, "\t.unit = \"%s\",\n", je->unit);
if (je->perpkg)
fprintf(outfp, "\t.perpkg = \"%s\",\n", je->perpkg);
fprintf(outfp, "\t.unit = \"%s\",\n", je->unit);
if (je->perpkg)
fprintf(outfp, "\t.perpkg = \"%s\",\n", je->perpkg);
+ if (je->aggr_mode)
+ fprintf(outfp, "\t.aggr_mode = \"%d\",\n", convert(je->aggr_mode));
if (je->metric_expr)
fprintf(outfp, "\t.metric_expr = \"%s\",\n", je->metric_expr);
if (je->metric_name)
if (je->metric_expr)
fprintf(outfp, "\t.metric_expr = \"%s\",\n", je->metric_expr);
if (je->metric_name)
char *pmu;
char *unit;
char *perpkg;
char *pmu;
char *unit;
char *perpkg;
char *metric_expr;
char *metric_name;
char *metric_group;
char *metric_expr;
char *metric_name;
char *metric_group;
op(pmu); \
op(unit); \
op(perpkg); \
op(pmu); \
op(unit); \
op(perpkg); \
op(metric_expr); \
op(metric_name); \
op(metric_group); \
op(metric_expr); \
op(metric_name); \
op(metric_group); \
addfield(map, &je.unit, "", "", val);
} else if (json_streq(map, field, "PerPkg")) {
addfield(map, &je.perpkg, "", "", val);
addfield(map, &je.unit, "", "", val);
} else if (json_streq(map, field, "PerPkg")) {
addfield(map, &je.perpkg, "", "", val);
+ } else if (json_streq(map, field, "AggregationMode")) {
+ addfield(map, &je.aggr_mode, "", "", val);
} else if (json_streq(map, field, "Deprecated")) {
addfield(map, &je.deprecated, "", "", val);
} else if (json_streq(map, field, "MetricName")) {
} else if (json_streq(map, field, "Deprecated")) {
addfield(map, &je.deprecated, "", "", val);
} else if (json_streq(map, field, "MetricName")) {
free(je.pmu);
free(filter);
free(je.perpkg);
free(je.pmu);
free(filter);
free(je.perpkg);
free(je.deprecated);
free(je.unit);
free(je.metric_expr);
free(je.deprecated);
free(je.unit);
free(je.metric_expr);
#ifndef PMU_EVENTS_H
#define PMU_EVENTS_H
#ifndef PMU_EVENTS_H
#define PMU_EVENTS_H
+enum aggr_mode_class {
+ PerChip = 1,
+ PerCore
+};
+
/*
* Describe each PMU event. Each CPU has a table of PMU events.
*/
/*
* Describe each PMU event. Each CPU has a table of PMU events.
*/
const char *pmu;
const char *unit;
const char *perpkg;
const char *pmu;
const char *unit;
const char *perpkg;
const char *metric_expr;
const char *metric_name;
const char *metric_group;
const char *metric_expr;
const char *metric_name;
const char *metric_group;