237 lines
7.1 KiB
Diff
237 lines
7.1 KiB
Diff
From 272232b23a91bc246d17a1117162180670de1c92 Mon Sep 17 00:00:00 2001
|
|
From: Ian Rogers <irogers@google.com>
|
|
Date: Tue, 22 Oct 2019 17:53:32 -0700
|
|
Subject: [PATCH 033/201] perf tools: Move ALLOC_LIST into a function
|
|
|
|
mainline inclusion
|
|
from mainline-v5.5-rc1
|
|
commit a26e47162d7670ddea4f67978ecf848dc23ef671
|
|
category: cleanup
|
|
bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a26e47162d7670ddea4f67978ecf848dc23ef671
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
Having a YYABORT in a macro makes it hard to free memory for components
|
|
of a rule. Separate the logic out.
|
|
|
|
Signed-off-by: Ian Rogers <irogers@google.com>
|
|
Acked-by: Jiri Olsa <jolsa@kernel.org>
|
|
Cc: Adrian Hunter <adrian.hunter@intel.com>
|
|
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
|
|
Cc: Alexei Starovoitov <ast@kernel.org>
|
|
Cc: Andi Kleen <ak@linux.intel.com>
|
|
Cc: Daniel Borkmann <daniel@iogearbox.net>
|
|
Cc: Jin Yao <yao.jin@linux.intel.com>
|
|
Cc: John Garry <john.garry@huawei.com>
|
|
Cc: Kan Liang <kan.liang@linux.intel.com>
|
|
Cc: Mark Rutland <mark.rutland@arm.com>
|
|
Cc: Martin KaFai Lau <kafai@fb.com>
|
|
Cc: Namhyung Kim <namhyung@kernel.org>
|
|
Cc: Peter Zijlstra <peterz@infradead.org>
|
|
Cc: Song Liu <songliubraving@fb.com>
|
|
Cc: Stephane Eranian <eranian@google.com>
|
|
Cc: Yonghong Song <yhs@fb.com>
|
|
Cc: bpf@vger.kernel.org
|
|
Cc: clang-built-linux@googlegroups.com
|
|
Cc: netdev@vger.kernel.org
|
|
Link: http://lore.kernel.org/lkml/20191023005337.196160-5-irogers@google.com
|
|
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
|
|
---
|
|
tools/perf/util/parse-events.y | 65 ++++++++++++++++++++++------------
|
|
1 file changed, 43 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
|
|
index a2c7b6fb1fd5..ef4c83b07c22 100644
|
|
--- a/tools/perf/util/parse-events.y
|
|
+++ b/tools/perf/util/parse-events.y
|
|
@@ -27,12 +27,17 @@ do { \
|
|
YYABORT; \
|
|
} while (0)
|
|
|
|
-#define ALLOC_LIST(list) \
|
|
-do { \
|
|
- list = malloc(sizeof(*list)); \
|
|
- ABORT_ON(!list); \
|
|
- INIT_LIST_HEAD(list); \
|
|
-} while (0)
|
|
+static struct list_head* alloc_list()
|
|
+{
|
|
+ struct list_head *list;
|
|
+
|
|
+ list = malloc(sizeof(*list));
|
|
+ if (!list)
|
|
+ return NULL;
|
|
+
|
|
+ INIT_LIST_HEAD(list);
|
|
+ return list;
|
|
+}
|
|
|
|
static void inc_group_count(struct list_head *list,
|
|
struct parse_events_state *parse_state)
|
|
@@ -240,7 +245,8 @@ PE_NAME opt_pmu_config
|
|
if (error)
|
|
error->idx = @1.first_column;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
|
|
struct perf_pmu *pmu = NULL;
|
|
int ok = 0;
|
|
@@ -308,7 +314,8 @@ value_sym '/' event_config '/'
|
|
int type = $1 >> 16;
|
|
int config = $1 & 255;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, $3));
|
|
parse_events_terms__delete($3);
|
|
$$ = list;
|
|
@@ -320,7 +327,8 @@ value_sym sep_slash_slash_dc
|
|
int type = $1 >> 16;
|
|
int config = $1 & 255;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_numeric(_parse_state, list, type, config, NULL));
|
|
$$ = list;
|
|
}
|
|
@@ -329,7 +337,8 @@ PE_VALUE_SYM_TOOL sep_slash_slash_dc
|
|
{
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_tool(_parse_state, list, $1));
|
|
$$ = list;
|
|
}
|
|
@@ -341,7 +350,8 @@ PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_e
|
|
struct parse_events_error *error = parse_state->error;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6));
|
|
parse_events_terms__delete($6);
|
|
$$ = list;
|
|
@@ -353,7 +363,8 @@ PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config
|
|
struct parse_events_error *error = parse_state->error;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4));
|
|
parse_events_terms__delete($4);
|
|
$$ = list;
|
|
@@ -365,7 +376,8 @@ PE_NAME_CACHE_TYPE opt_event_config
|
|
struct parse_events_error *error = parse_state->error;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2));
|
|
parse_events_terms__delete($2);
|
|
$$ = list;
|
|
@@ -377,7 +389,8 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
|
|
struct parse_events_state *parse_state = _parse_state;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
|
|
(void *) $2, $6, $4));
|
|
$$ = list;
|
|
@@ -388,7 +401,8 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
|
|
struct parse_events_state *parse_state = _parse_state;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
|
|
(void *) $2, NULL, $4));
|
|
$$ = list;
|
|
@@ -399,7 +413,8 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
|
|
struct parse_events_state *parse_state = _parse_state;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
|
|
(void *) $2, $4, 0));
|
|
$$ = list;
|
|
@@ -410,7 +425,8 @@ PE_PREFIX_MEM PE_VALUE sep_dc
|
|
struct parse_events_state *parse_state = _parse_state;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_breakpoint(list, &parse_state->idx,
|
|
(void *) $2, NULL, 0));
|
|
$$ = list;
|
|
@@ -423,7 +439,8 @@ tracepoint_name opt_event_config
|
|
struct parse_events_error *error = parse_state->error;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
if (error)
|
|
error->idx = @1.first_column;
|
|
|
|
@@ -459,7 +476,8 @@ PE_VALUE ':' PE_VALUE opt_event_config
|
|
{
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_numeric(_parse_state, list, (u32)$1, $3, $4));
|
|
parse_events_terms__delete($4);
|
|
$$ = list;
|
|
@@ -470,7 +488,8 @@ PE_RAW opt_event_config
|
|
{
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_add_numeric(_parse_state, list, PERF_TYPE_RAW, $1, $2));
|
|
parse_events_terms__delete($2);
|
|
$$ = list;
|
|
@@ -483,7 +502,8 @@ PE_BPF_OBJECT opt_event_config
|
|
struct parse_events_error *error = parse_state->error;
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_load_bpf(parse_state, list, $1, false, $2));
|
|
parse_events_terms__delete($2);
|
|
$$ = list;
|
|
@@ -493,7 +513,8 @@ PE_BPF_SOURCE opt_event_config
|
|
{
|
|
struct list_head *list;
|
|
|
|
- ALLOC_LIST(list);
|
|
+ list = alloc_list();
|
|
+ ABORT_ON(!list);
|
|
ABORT_ON(parse_events_load_bpf(_parse_state, list, $1, true, $2));
|
|
parse_events_terms__delete($2);
|
|
$$ = list;
|
|
--
|
|
2.27.0
|
|
|