Skip to content

Commit c56f286

Browse files
Yanteng Siacmel
authored andcommitted
perf tools: Allow to use cpuinfo on LoongArch
Define these macros so that the CPU name can be displayed when running 'perf report' and 'perf timechart'. Committer notes: No need to have: if (strcasestr(buf, "Model Name")) { strlcpy(cpu_m, &buf[13], 255); break; } else if (strcasestr(buf, "model name")) { strlcpy(cpu_m, &buf[13], 255); break; } As the point of strcasestr() is to be case insensitive to both the haystack and the needle, so simplify the above to just: if (strcasestr(buf, "model name")) { strlcpy(cpu_m, &buf[13], 255); break; } Signed-off-by: Yanteng Si <siyanteng@loongson.cn> Acked-by: Huacai Chen <chenhuacai@loongson.cn> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: loongarch@lists.linux.dev Cc: loongson-kernel@lists.loongnix.cn Link: https://lore.kernel.org/r/db968a186a10e4629fe10c26a1210f7126ad41ec.1692962043.git.siyanteng@loongson.cn Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0f2418f commit c56f286

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tools/perf/util/header.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ static int write_cpudesc(struct feat_fd *ff,
456456
#define CPUINFO_PROC { "Processor", }
457457
#elif defined(__xtensa__)
458458
#define CPUINFO_PROC { "core ID", }
459+
#elif defined(__loongarch__)
460+
#define CPUINFO_PROC { "Model Name", }
459461
#else
460462
#define CPUINFO_PROC { "model name", }
461463
#endif

tools/perf/util/svghelper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static char *cpu_model(void)
331331
file = fopen("/proc/cpuinfo", "r");
332332
if (file) {
333333
while (fgets(buf, 255, file)) {
334-
if (strstr(buf, "model name")) {
334+
if (strcasestr(buf, "model name")) {
335335
strlcpy(cpu_m, &buf[13], 255);
336336
break;
337337
}

0 commit comments

Comments
 (0)