aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/util/expr.h
diff options
context:
space:
mode:
authorGravatar Jiri Olsa <jolsa@kernel.org> 2020-07-19 20:13:16 +0200
committerGravatar Arnaldo Carvalho de Melo <acme@redhat.com> 2020-07-30 07:01:49 -0300
commitf6fb0960f920e3040088992f32bbceded7a74322 (patch)
tree3a3827acaa67f85cde9d495fe18613eeb3e4907c /tools/perf/util/expr.h
parentperf metric: Add DCache_L2 to metric parse test (diff)
downloadlinux-f6fb0960f920e3040088992f32bbceded7a74322.tar.gz
linux-f6fb0960f920e3040088992f32bbceded7a74322.tar.bz2
linux-f6fb0960f920e3040088992f32bbceded7a74322.zip
perf metric: Add recursion check when processing nested metrics
Keeping the stack of nested metrics via 'struct expr_id' objects and checking if we are in recursion via already processed metric. The stack is implemented as static array within the struct egroup with 100 entries, which should be enough nesting depth for any metric we have or plan to have at the moment. Adding test that simulates the recursion and checks we can detect it. Committer notes: Bumped RECURSION_ID_MAX to 1000 as per Jiri's reply to Paul Clark on the patch series e-mail discussion. Fixed these: tests/parse-metric.c:308:7: error: missing field 'val' initializer [-Werror,-Wmissing-field-initializers] { 0 }, ^ util/metricgroup.c:924:28: error: missing field 'parent' initializer [-Werror,-Wmissing-field-initializers] struct expr_ids ids = { 0 }; ^ util/metricgroup.c:924:26: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] struct expr_ids ids = { 0 }; ^ {} util/metricgroup.c:924:26: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] struct expr_ids ids = { 0 }; ^ {} util/metricgroup.c:924:28: error: missing field 'cnt' initializer [-Werror,-Wmissing-field-initializers] struct expr_ids ids = { 0 }; ^ Signed-off-by: Jiri Olsa <jolsa@kernel.org> Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Acked-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: John Garry <john.garry@huawei.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Clarke <pc@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lore.kernel.org/lkml/20200719181320.785305-16-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/expr.h')
-rw-r--r--tools/perf/util/expr.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
index 9ed208d93418..fc2b5e824a66 100644
--- a/tools/perf/util/expr.h
+++ b/tools/perf/util/expr.h
@@ -13,8 +13,14 @@
struct metric_ref;
+struct expr_id {
+ char *id;
+ struct expr_id *parent;
+};
+
struct expr_parse_ctx {
- struct hashmap ids;
+ struct hashmap ids;
+ struct expr_id *parent;
};
struct expr_id_data {
@@ -25,6 +31,7 @@ struct expr_id_data {
const char *metric_expr;
bool counted;
} ref;
+ struct expr_id *parent;
};
bool is_ref;