* [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning
@ 2023-08-29 13:21 Yanteng Si
2023-08-29 13:21 ` [PATCH v4 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Yanteng Si @ 2023-08-29 13:21 UTC (permalink / raw)
To: acme
Cc: Yanteng Si, mingo, peterz, mark.rutland, alexander.shishkin,
jolsa, namhyung, irogers, adrian.hunter, chenhuacai,
linux-perf-users, loongson-kernel, loongarch
v4:
* Modify commit message. [3/3]
v3:
* Using strcasest() correctly.
* Picking Huacai's Acked tag, I seem to have lost it in the last version.
v2:
* Switch to strcasestr().
* Use "test -f" instead of "[-f FILE]".
v1:
* LoongArch and riscv don't have tools/arch/xxxxx/include/uapi/asm/mman.h,
let's modify the detection rules.
* Allow to use cpuinfo on loongarch.
Yanteng Si (3):
perf/tools: Allow to use cpuinfo on LoongArch
perf/trace: Fix mmap_flags for archs use generic mman.h
perf/trace: Use "test -f" instead of "[-f FILE]"
tools/perf/trace/beauty/mmap_flags.sh | 7 +++++--
tools/perf/trace/beauty/mmap_prot.sh | 5 +++--
tools/perf/util/header.c | 2 ++
tools/perf/util/svghelper.c | 2 +-
4 files changed, 11 insertions(+), 5 deletions(-)
--
2.31.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/3] perf/tools: Allow to use cpuinfo on LoongArch
2023-08-29 13:21 [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
@ 2023-08-29 13:21 ` Yanteng Si
2023-08-29 13:21 ` [PATCH v4 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Yanteng Si @ 2023-08-29 13:21 UTC (permalink / raw)
To: acme
Cc: Yanteng Si, mingo, peterz, mark.rutland, alexander.shishkin,
jolsa, namhyung, irogers, adrian.hunter, chenhuacai,
linux-perf-users, loongson-kernel, loongarch, Huacai Chen
Define these macros so that the CPU name can be displayed
when running perf report and perf timechart.
Acked-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
| 2 ++
tools/perf/util/svghelper.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
--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..2e141126b0d6 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -331,7 +331,7 @@ static char *cpu_model(void)
file = fopen("/proc/cpuinfo", "r");
if (file) {
while (fgets(buf, 255, file)) {
- if (strstr(buf, "model name")) {
+ if (strcasestr(buf, "model Name")) {
strlcpy(cpu_m, &buf[13], 255);
break;
}
--
2.31.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h
2023-08-29 13:21 [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-29 13:21 ` [PATCH v4 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
@ 2023-08-29 13:21 ` Yanteng Si
2023-08-29 13:21 ` [PATCH v4 3/3] perf/trace: Use "test -f" instead of "[-f FILE]" Yanteng Si
2023-08-29 17:16 ` [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Arnaldo Carvalho de Melo
3 siblings, 0 replies; 5+ messages in thread
From: Yanteng Si @ 2023-08-29 13:21 UTC (permalink / raw)
To: acme
Cc: Yanteng Si, mingo, peterz, mark.rutland, alexander.shishkin,
jolsa, namhyung, irogers, adrian.hunter, chenhuacai,
linux-perf-users, loongson-kernel, loongarch, Huacai Chen
Silence this warning:
grep: /root/linux-next/tools/arch/xxxxx/include/uapi/asm//mman.h:
No such file or directory
Acked-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
tools/perf/trace/beauty/mmap_flags.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/trace/beauty/mmap_flags.sh b/tools/perf/trace/beauty/mmap_flags.sh
index 3022597c8c17..d035b29fc5ec 100755
--- a/tools/perf/trace/beauty/mmap_flags.sh
+++ b/tools/perf/trace/beauty/mmap_flags.sh
@@ -19,7 +19,7 @@ arch_mman=${arch_header_dir}/mman.h
printf "static const char *mmap_flags[] = {\n"
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
-grep -E -q $regex ${arch_mman} && \
+([ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman}) && \
(grep -E $regex ${arch_mman} | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
--
2.31.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 3/3] perf/trace: Use "test -f" instead of "[-f FILE]"
2023-08-29 13:21 [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-29 13:21 ` [PATCH v4 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
2023-08-29 13:21 ` [PATCH v4 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
@ 2023-08-29 13:21 ` Yanteng Si
2023-08-29 17:16 ` [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Arnaldo Carvalho de Melo
3 siblings, 0 replies; 5+ messages in thread
From: Yanteng Si @ 2023-08-29 13:21 UTC (permalink / raw)
To: acme
Cc: Yanteng Si, mingo, peterz, mark.rutland, alexander.shishkin,
jolsa, namhyung, irogers, adrian.hunter, chenhuacai,
linux-perf-users, loongson-kernel, loongarch
"[" is part of the shell builtin test (and a synonym for it),
not a link to the external command /usr/bin/test.
Using the "test" is simpler because it avoids a lot of "[]".
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
tools/perf/trace/beauty/mmap_flags.sh | 9 ++++++---
tools/perf/trace/beauty/mmap_prot.sh | 5 +++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/tools/perf/trace/beauty/mmap_flags.sh b/tools/perf/trace/beauty/mmap_flags.sh
index d035b29fc5ec..6ecdb3c5a99e 100755
--- a/tools/perf/trace/beauty/mmap_flags.sh
+++ b/tools/perf/trace/beauty/mmap_flags.sh
@@ -19,7 +19,8 @@ arch_mman=${arch_header_dir}/mman.h
printf "static const char *mmap_flags[] = {\n"
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
-([ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman}) && \
+test -f ${arch_mman} && \
+grep -E -q $regex ${arch_mman} && \
(grep -E $regex ${arch_mman} | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
@@ -28,12 +29,14 @@ grep -E -q $regex ${linux_mman} && \
grep -E -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
-([ ! -f ${arch_mman} ] || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
+( ! test -f ${arch_mman} || \
+grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
(grep -E $regex ${header_dir}/mman-common.h | \
grep -E -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
-([ ! -f ${arch_mman} ] || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
+( ! test -f ${arch_mman} || \
+grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
(grep -E $regex ${header_dir}/mman.h | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
diff --git a/tools/perf/trace/beauty/mmap_prot.sh b/tools/perf/trace/beauty/mmap_prot.sh
index 49e8c865214b..4436fcd6e861 100755
--- a/tools/perf/trace/beauty/mmap_prot.sh
+++ b/tools/perf/trace/beauty/mmap_prot.sh
@@ -17,12 +17,13 @@ prefix="PROT"
printf "static const char *mmap_prot[] = {\n"
regex=`printf '^[[:space:]]*#[[:space:]]*define[[:space:]]+%s_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' ${prefix}`
-([ ! -f ${arch_mman} ] || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
+( ! test -f ${arch_mman} \
+|| grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
(grep -E $regex ${common_mman} | \
grep -E -vw PROT_NONE | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n")
-[ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman} &&
+test -f ${arch_mman} && grep -E -q $regex ${arch_mman} &&
(grep -E $regex ${arch_mman} | \
grep -E -vw PROT_NONE | \
sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
--
2.31.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning
2023-08-29 13:21 [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
` (2 preceding siblings ...)
2023-08-29 13:21 ` [PATCH v4 3/3] perf/trace: Use "test -f" instead of "[-f FILE]" Yanteng Si
@ 2023-08-29 17:16 ` Arnaldo Carvalho de Melo
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-08-29 17:16 UTC (permalink / raw)
To: Yanteng Si
Cc: mingo, peterz, mark.rutland, alexander.shishkin, jolsa, namhyung,
irogers, adrian.hunter, chenhuacai, linux-perf-users,
loongson-kernel, loongarch
Em Tue, Aug 29, 2023 at 09:21:10PM +0800, Yanteng Si escreveu:
> v4:
> * Modify commit message. [3/3]
Thanks, I updated the commit log messages adding the Acked-by and the
new description for 3/3 since I hadn't published this in perf-tools-next
yet.
- Arnaldo
> v3:
> * Using strcasest() correctly.
> * Picking Huacai's Acked tag, I seem to have lost it in the last version.
>
> v2:
> * Switch to strcasestr().
> * Use "test -f" instead of "[-f FILE]".
>
> v1:
> * LoongArch and riscv don't have tools/arch/xxxxx/include/uapi/asm/mman.h,
> let's modify the detection rules.
> * Allow to use cpuinfo on loongarch.
>
> Yanteng Si (3):
> perf/tools: Allow to use cpuinfo on LoongArch
> perf/trace: Fix mmap_flags for archs use generic mman.h
> perf/trace: Use "test -f" instead of "[-f FILE]"
>
> tools/perf/trace/beauty/mmap_flags.sh | 7 +++++--
> tools/perf/trace/beauty/mmap_prot.sh | 5 +++--
> tools/perf/util/header.c | 2 ++
> tools/perf/util/svghelper.c | 2 +-
> 4 files changed, 11 insertions(+), 5 deletions(-)
>
> --
> 2.31.4
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-29 17:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-29 13:21 [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-29 13:21 ` [PATCH v4 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
2023-08-29 13:21 ` [PATCH v4 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
2023-08-29 13:21 ` [PATCH v4 3/3] perf/trace: Use "test -f" instead of "[-f FILE]" Yanteng Si
2023-08-29 17:16 ` [PATCH v4 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Arnaldo Carvalho de Melo
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).