Re: [PATCH v3 1/5] perf/pmu-events/jevents: Add enum to store aggregation like PerPkg
From: Jiri Olsa
Date: Fri Jul 17 2020 - 04:53:15 EST
On Thu, Jul 16, 2020 at 03:12:12PM +0530, Kajol Jain wrote:
> 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 perpkg/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@xxxxxxxxxxxxx>
> ---
> tools/perf/pmu-events/jevents.c | 39 +++++++++++++++++++-----------
> tools/perf/pmu-events/jevents.h | 2 +-
> tools/perf/pmu-events/pmu-events.h | 6 ++++-
> tools/perf/tests/pmu-events.c | 8 +++---
> tools/perf/util/pmu.c | 6 ++---
> 5 files changed, 38 insertions(+), 23 deletions(-)
>
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index fa86c5f997cc..b2f59f0af63d 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -53,6 +53,17 @@
> int verbose;
> char *prog;
>
> +enum aggr_mode_class {
> + PerPkg = 1
> +};
> +
> +enum aggr_mode_class convert(const char *aggr_mode)
> +{
> + if (!strcmp(aggr_mode, "PerPkg"))
> + return PerPkg;
> + return -1;
> +}
I just noticed you define aggr_mode_class twice,
I think we should keep it just in pmu-events.h
like in change below (compiles for me)
thanks,
jirka
---
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index e1c43f739083..2f48b783a64d 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -49,16 +49,11 @@
#include "jsmn.h"
#include "json.h"
#include "jevents.h"
+#include "pmu-events.h"
int verbose;
char *prog;
-enum aggr_mode_class {
- PerPkg = 1,
- PerChip,
- PerCore
-};
-
enum aggr_mode_class convert(const char *aggr_mode)
{
if (!strcmp(aggr_mode, "PerPkg"))