mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
perf debug: Avoid calling eprintf() in pr_debugN() when verbose < n
pr_debugN() unconditionally evaluated its arguments and called eprintf() -> veprintf() before checking if verbose >= n. In hot paths such as dso__load_sym_internal(), two pr_debug4() calls per symbol accounted for ~15% of total CPU time in 'perf top' even at the default verbose == 0. Guard eprintf() in pr_debugN() with unlikely(verbose >= (n)) and define pr_debug() in terms of pr_debugN(1, ...). In test__parsing_callback() (tools/perf/tests/pmu-events.c), move the test_generic_metric(mexp, 0) call out of the pr_debug() argument list so the metric evaluation continues to run during 'perf test' when verbose == 0. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alessio Podda <aleph.pi.gh@gmail.com> Cc: Alireza Haghdoost <haghdoost@uber.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Michael Liang <mliang@purestorage.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Shimin Guo <shimin.guo@skydio.com> Cc: Tanushree Shah <tshah@linux.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
62d7cdc8d5
commit
2fb45894e8
|
|
@ -906,9 +906,12 @@ static int test__parsing_callback(const struct pmu_metric *pm,
|
|||
struct metric_expr *mexp;
|
||||
|
||||
list_for_each_entry (mexp, &me->head, nd) {
|
||||
double result;
|
||||
|
||||
if (strcmp(mexp->metric_name, pm->metric_name))
|
||||
continue;
|
||||
pr_debug("Result %f\n", test_generic_metric(mexp, 0));
|
||||
result = test_generic_metric(mexp, 0);
|
||||
pr_debug("Result %f\n", result);
|
||||
err = 0;
|
||||
(*failures)--;
|
||||
goto out_err;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,9 @@ extern int debug_type_profile;
|
|||
})
|
||||
#define pr_info(fmt, ...) \
|
||||
eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_debug(fmt, ...) \
|
||||
eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_debugN(n, fmt, ...) \
|
||||
eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
(unlikely(verbose >= (n)) ? eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__) : 0)
|
||||
#define pr_debug(fmt, ...) pr_debugN(1, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user