perf expr: Add d_ratio operation
authorIan Rogers <irogers@google.com>
Wed, 10 Jun 2020 23:58:22 +0000 (16:58 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 22 Jun 2020 19:28:09 +0000 (16:28 -0300)
commit3e21a28a01e227726456a51933ed004c2df31850
tree3790a45c13e4492f2f2e99e09c3505c3eee5e885
parentafdd63f5933b3c970438e8ab6bb0cd9f392f3bf6
perf expr: Add d_ratio operation

d_ratio avoids division by 0 yielding infinity, such as when a counter
doesn't get scheduled. An example usage is:

  {
      "BriefDescription": "DCache L1 misses",
      "MetricExpr": "d_ratio(MEM_LOAD_RETIRED.L1_MISS, MEM_LOAD_RETIRED.L1_HIT + MEM_LOAD_RETIRED.L1_MISS + MEM_LOAD_RETIRED.FB_HIT)",
      "MetricGroup": "DCache;DCache_L1",
      "MetricName": "DCache_L1_Miss",
      "ScaleUnit": "100%",
  }

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.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/20200610235823.52557-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/expr.c
tools/perf/util/expr.l
tools/perf/util/expr.y