From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Yanteng Si <siyanteng@loongson.cn>
Cc: mingo@redhat.com, peterz@infradead.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
chenhuacai@kernel.org, linux-perf-users@vger.kernel.org,
loongson-kernel@lists.loongnix.cn, loongarch@lists.linux.dev
Subject: Re: [PATCH v1 2/2] perf/tools: Allow to use cpuinfo on loongarch
Date: Tue, 22 Aug 2023 14:50:43 -0300 [thread overview]
Message-ID: <ZOT1c/MRwkaPaqf1@kernel.org> (raw)
In-Reply-To: <fbb71a04bf3b19b1d1b239e464c1acbcc572e9a8.1692694595.git.siyanteng@loongson.cn>
Em Tue, Aug 22, 2023 at 05:32:07PM +0800, Yanteng Si escreveu:
> Define these macros so that the CPU name can be displayed
> when running perf report and perf timechart.
>
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
> tools/perf/util/header.c | 2 ++
> tools/perf/util/svghelper.c | 7 ++++++-
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 52fbf526fe74..c6e19192bd28 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -456,6 +456,8 @@ static int write_cpudesc(struct feat_fd *ff,
> #define CPUINFO_PROC { "Processor", }
> #elif defined(__xtensa__)
> #define CPUINFO_PROC { "core ID", }
> +#elif defined(__loongarch__)
> +#define CPUINFO_PROC { "Model Name", }
> #else
> #define CPUINFO_PROC { "model name", }
> #endif
> diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
> index 5c62d3118c41..0259715ad6a6 100644
> --- a/tools/perf/util/svghelper.c
> +++ b/tools/perf/util/svghelper.c
> @@ -322,6 +322,11 @@ void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
>
> static char *cpu_model(void)
> {
> +#if defined(__loongarch__)
> +#define CPU_TYPE "Model Name"
> +#else
> +#define CPU_TYPE "model name"
> +#endif
> static char cpu_m[255];
> char buf[256];
> FILE *file;
> @@ -331,7 +336,7 @@ static char *cpu_model(void)
> file = fopen("/proc/cpuinfo", "r");
> if (file) {
> while (fgets(buf, 255, file)) {
> - if (strstr(buf, "model name")) {
> + if (strstr(buf, CPU_TYPE)) {
Isn't it better to just switch to strcasestr()?
- Arnaldo
> strlcpy(cpu_m, &buf[13], 255);
> break;
> }
> --
> 2.31.4
>
--
- Arnaldo
next prev parent reply other threads:[~2023-08-22 17:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 9:32 [PATCH v1 0/2] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-22 9:32 ` [PATCH v1 1/2] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
2023-08-22 18:02 ` Arnaldo Carvalho de Melo
2023-08-23 7:11 ` Yanteng Si
2023-08-23 11:36 ` Arnaldo Carvalho de Melo
2023-08-24 2:22 ` Yanteng Si
2023-08-24 13:33 ` Arnaldo Carvalho de Melo
2023-08-22 9:32 ` [PATCH v1 2/2] perf/tools: Allow to use cpuinfo on loongarch Yanteng Si
2023-08-22 17:50 ` Arnaldo Carvalho de Melo [this message]
2023-08-23 7:11 ` Yanteng Si
2023-08-22 15:10 ` [PATCH v1 0/2] tools/perf: Add loongarch cpuinfo and fix build warning Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZOT1c/MRwkaPaqf1@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=chenhuacai@kernel.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=loongson-kernel@lists.loongnix.cn \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=siyanteng@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).