• Jiri Olsa's avatar
    perf metric: Add recursion check when processing nested metrics · f6fb0960
    Jiri Olsa authored
    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: default avatarJiri Olsa <jolsa@kernel.org>
    Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
    Acked-by: default avatarIan 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    f6fb0960
expr.c 5.24 KB