Commit a4d8c985 authored by David Carrillo-Cisneros's avatar David Carrillo-Cisneros Committed by Arnaldo Carvalho de Melo

perf header: Change FEAT_OP* macros

There are three FEAT_OP* macros:
  - FEAT_OPA: for features without process record.
  - FEAT_OPP: for features with process record.
  - FEAT_OPF: like FEAT_OPP but to show only if show_full_info flags
    is set.

To add pipe-mode headers we need yet another variation of the macros
(one to specify whether a feature generates an auxiliar record).

Instead, we redefine macros so that:
  - show_full_info is specified as an argument (to remove the
  FEAT_OPF variation) and,
  - it always sets "process" handler (to remove the FEAT_OPA variation).
  Individual process handlers can be NULLed individually.

This allows to define two variations only:
  - FEAT_OPR: synthesizes auxiliar event record.
  - FEAT_OPN: doesn't synthesize an auxiliar event record.
Signed-off-by: default avatarDavid Carrillo-Cisneros <davidcc@google.com>
Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Simon Que <sque@chromium.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20170718042549.145161-14-davidcc@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0b3d3410
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/stringify.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/utsname.h> #include <sys/utsname.h>
...@@ -2139,42 +2140,57 @@ struct feature_ops { ...@@ -2139,42 +2140,57 @@ struct feature_ops {
int (*process)(struct feat_fd *ff, void *data); int (*process)(struct feat_fd *ff, void *data);
const char *name; const char *name;
bool full_only; bool full_only;
bool synthesize;
}; };
#define FEAT_OPA(n, func) \ #define FEAT_OPR(n, func, __full_only) \
[n] = { .name = #n, .write = write_##func, .print = print_##func } [HEADER_##n] = { \
#define FEAT_OPP(n, func) \ .name = __stringify(n), \
[n] = { .name = #n, .write = write_##func, .print = print_##func, \ .write = write_##func, \
.process = process_##func } .print = print_##func, \
#define FEAT_OPF(n, func) \ .full_only = __full_only, \
[n] = { .name = #n, .write = write_##func, .print = print_##func, \ .process = process_##func, \
.process = process_##func, .full_only = true } .synthesize = true \
}
#define FEAT_OPN(n, func, __full_only) \
[HEADER_##n] = { \
.name = __stringify(n), \
.write = write_##func, \
.print = print_##func, \
.full_only = __full_only, \
.process = process_##func \
}
/* feature_ops not implemented: */ /* feature_ops not implemented: */
#define print_tracing_data NULL #define print_tracing_data NULL
#define print_build_id NULL #define print_build_id NULL
#define process_branch_stack NULL
#define process_stat NULL
static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
FEAT_OPP(HEADER_TRACING_DATA, tracing_data), FEAT_OPN(TRACING_DATA, tracing_data, false),
FEAT_OPP(HEADER_BUILD_ID, build_id), FEAT_OPN(BUILD_ID, build_id, false),
FEAT_OPP(HEADER_HOSTNAME, hostname), FEAT_OPR(HOSTNAME, hostname, false),
FEAT_OPP(HEADER_OSRELEASE, osrelease), FEAT_OPR(OSRELEASE, osrelease, false),
FEAT_OPP(HEADER_VERSION, version), FEAT_OPR(VERSION, version, false),
FEAT_OPP(HEADER_ARCH, arch), FEAT_OPR(ARCH, arch, false),
FEAT_OPP(HEADER_NRCPUS, nrcpus), FEAT_OPR(NRCPUS, nrcpus, false),
FEAT_OPP(HEADER_CPUDESC, cpudesc), FEAT_OPR(CPUDESC, cpudesc, false),
FEAT_OPP(HEADER_CPUID, cpuid), FEAT_OPR(CPUID, cpuid, false),
FEAT_OPP(HEADER_TOTAL_MEM, total_mem), FEAT_OPR(TOTAL_MEM, total_mem, false),
FEAT_OPP(HEADER_EVENT_DESC, event_desc), FEAT_OPR(EVENT_DESC, event_desc, false),
FEAT_OPP(HEADER_CMDLINE, cmdline), FEAT_OPR(CMDLINE, cmdline, false),
FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology), FEAT_OPR(CPU_TOPOLOGY, cpu_topology, true),
FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology), FEAT_OPR(NUMA_TOPOLOGY, numa_topology, true),
FEAT_OPA(HEADER_BRANCH_STACK, branch_stack), FEAT_OPN(BRANCH_STACK, branch_stack, false),
FEAT_OPP(HEADER_PMU_MAPPINGS, pmu_mappings), FEAT_OPR(PMU_MAPPINGS, pmu_mappings, false),
FEAT_OPP(HEADER_GROUP_DESC, group_desc), FEAT_OPN(GROUP_DESC, group_desc, false),
FEAT_OPP(HEADER_AUXTRACE, auxtrace), FEAT_OPN(AUXTRACE, auxtrace, false),
FEAT_OPA(HEADER_STAT, stat), FEAT_OPN(STAT, stat, false),
FEAT_OPF(HEADER_CACHE, cache), FEAT_OPN(CACHE, cache, true),
}; };
struct header_print_data { struct header_print_data {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment