Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf header: Pass "cpu" pmu name while printing caps

Avoid unnecessary conditional code to check if pmu name is NULL
or not by passing "cpu" pmu name to the printing function.

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <rrichter@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: like.xu.linux@gmail.com
Cc: x86@kernel.org
Link: https://lore.kernel.org/r/20220604044519.594-4-ravi.bangoria@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ravi Bangoria and committed by
Arnaldo Carvalho de Melo
2a12bef4 3339ec44

+3 -9
+3 -9
tools/perf/util/header.c
··· 2058 2058 char *str, buf[128]; 2059 2059 2060 2060 if (!nr_caps) { 2061 - if (!pmu_name) 2062 - fprintf(fp, "# cpu pmu capabilities: not available\n"); 2063 - else 2064 - fprintf(fp, "# %s pmu capabilities: not available\n", pmu_name); 2061 + fprintf(fp, "# %s pmu capabilities: not available\n", pmu_name); 2065 2062 return; 2066 2063 } 2067 2064 2068 - if (!pmu_name) 2069 - scnprintf(buf, sizeof(buf), "# cpu pmu capabilities: "); 2070 - else 2071 - scnprintf(buf, sizeof(buf), "# %s pmu capabilities: ", pmu_name); 2065 + scnprintf(buf, sizeof(buf), "# %s pmu capabilities: ", pmu_name); 2072 2066 2073 2067 delimiter = buf; 2074 2068 ··· 2079 2085 static void print_cpu_pmu_caps(struct feat_fd *ff, FILE *fp) 2080 2086 { 2081 2087 print_per_cpu_pmu_caps(fp, ff->ph->env.nr_cpu_pmu_caps, 2082 - ff->ph->env.cpu_pmu_caps, NULL); 2088 + ff->ph->env.cpu_pmu_caps, (char *)"cpu"); 2083 2089 } 2084 2090 2085 2091 static void print_hybrid_cpu_pmu_caps(struct feat_fd *ff, FILE *fp)