Skip to content

Commit f56ef30

Browse files
captain5050acmel
authored andcommitted
perf expr: Add debug logging for literals
Useful for diagnosing problems with metrics. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John Garry <john.garry@huawei.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Konstantin Khlebnikov <koct9i@gmail.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/20211124001231.3277836-1-irogers@google.com [ Fixed up perf_cpu conflict, i.e. we need to append ".cpu" to cpu__max_present_cpu() result ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 6dd8646 commit f56ef30

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

tools/perf/util/expr.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,17 @@ double expr_id_data__source_count(const struct expr_id_data *data)
405405
double expr__get_literal(const char *literal)
406406
{
407407
static struct cpu_topology *topology;
408+
double result = NAN;
408409

409-
if (!strcmp("#smt_on", literal))
410-
return smt_on() > 0 ? 1.0 : 0.0;
410+
if (!strcmp("#smt_on", literal)) {
411+
result = smt_on() > 0 ? 1.0 : 0.0;
412+
goto out;
413+
}
411414

412-
if (!strcmp("#num_cpus", literal))
413-
return cpu__max_present_cpu().cpu;
415+
if (!strcmp("#num_cpus", literal)) {
416+
result = cpu__max_present_cpu().cpu;
417+
goto out;
418+
}
414419

415420
/*
416421
* Assume that topology strings are consistent, such as CPUs "0-1"
@@ -422,16 +427,24 @@ double expr__get_literal(const char *literal)
422427
topology = cpu_topology__new();
423428
if (!topology) {
424429
pr_err("Error creating CPU topology");
425-
return NAN;
430+
goto out;
426431
}
427432
}
428-
if (!strcmp("#num_packages", literal))
429-
return topology->package_cpus_lists;
430-
if (!strcmp("#num_dies", literal))
431-
return topology->die_cpus_lists;
432-
if (!strcmp("#num_cores", literal))
433-
return topology->core_cpus_lists;
433+
if (!strcmp("#num_packages", literal)) {
434+
result = topology->package_cpus_lists;
435+
goto out;
436+
}
437+
if (!strcmp("#num_dies", literal)) {
438+
result = topology->die_cpus_lists;
439+
goto out;
440+
}
441+
if (!strcmp("#num_cores", literal)) {
442+
result = topology->core_cpus_lists;
443+
goto out;
444+
}
434445

435446
pr_err("Unrecognized literal '%s'", literal);
436-
return NAN;
447+
out:
448+
pr_debug2("literal: %s = %f\n", literal, result);
449+
return result;
437450
}

0 commit comments

Comments
 (0)