* [PATCH v2 0/3] tools/perf: Add loongarch cpuinfo and fix build warning
@ 2023-08-25 11:28 Yanteng Si
2023-08-25 11:28 ` [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Yanteng Si @ 2023-08-25 11:28 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
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/tools: 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 | 5 ++++-
4 files changed, 14 insertions(+), 5 deletions(-)
--
2.31.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch
2023-08-25 11:28 [PATCH v2 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
@ 2023-08-25 11:28 ` Yanteng Si
2023-08-25 13:45 ` Arnaldo Carvalho de Melo
2023-08-25 11:28 ` [PATCH v2 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
2023-08-25 11:28 ` [PATCH v2 3/3] perf/tools: Use "test -f" instead of "[-f FILE]" Yanteng Si
2 siblings, 1 reply; 7+ messages in thread
From: Yanteng Si @ 2023-08-25 11:28 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
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>
---
| 2 ++
tools/perf/util/svghelper.c | 5 ++++-
2 files changed, 6 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..5744a3036b01 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -331,7 +331,10 @@ 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;
+ } else if (strcasestr(buf, "model name")) {
strlcpy(cpu_m, &buf[13], 255);
break;
}
--
2.31.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h
2023-08-25 11:28 [PATCH v2 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-25 11:28 ` [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
@ 2023-08-25 11:28 ` Yanteng Si
2023-08-25 11:28 ` [PATCH v2 3/3] perf/tools: Use "test -f" instead of "[-f FILE]" Yanteng Si
2 siblings, 0 replies; 7+ messages in thread
From: Yanteng Si @ 2023-08-25 11:28 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
Silence this warning:
grep: /root/linux-next/tools/arch/xxxxx/include/uapi/asm//mman.h:
No such file or directory
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] 7+ messages in thread
* [PATCH v2 3/3] perf/tools: Use "test -f" instead of "[-f FILE]"
2023-08-25 11:28 [PATCH v2 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-25 11:28 ` [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
2023-08-25 11:28 ` [PATCH v2 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
@ 2023-08-25 11:28 ` Yanteng Si
2023-08-26 9:42 ` Xi Ruoyao
2 siblings, 1 reply; 7+ messages in thread
From: Yanteng Si @ 2023-08-25 11:28 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
It will be simpler without that extra subshell, so
let's use "test -f".
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] 7+ messages in thread
* Re: [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch
2023-08-25 11:28 ` [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
@ 2023-08-25 13:45 ` Arnaldo Carvalho de Melo
2023-08-26 9:19 ` Yanteng Si
0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-08-25 13:45 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 Fri, Aug 25, 2023 at 07:28:02PM +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 | 5 ++++-
> 2 files changed, 6 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..5744a3036b01 100644
> --- a/tools/perf/util/svghelper.c
> +++ b/tools/perf/util/svghelper.c
> @@ -331,7 +331,10 @@ 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;
> + } else if (strcasestr(buf, "model name")) {
> strlcpy(cpu_m, &buf[13], 255);
Hey, the point of strcasestr() is to do a case _insensitive_ substring
search, so all we need is:
> --- a/tools/perf/util/svghelper.c
> +++ b/tools/perf/util/svghelper.c
> @@ -331,7 +331,10 @@ 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;
Right? I'm doing this change while applying your patches.
See:
[acme@five c]$ grep -m1 "model name" /proc/cpuinfo | ./strcasestr "Model NAME"
needle=Model NAME
haystack=model name : AMD Ryzen 9 5950X 16-Core Processor
found: model name : AMD Ryzen 9 5950X 16-Core Processor
found[13..]: AMD Ryzen 9 5950X 16-Core Processor
[acme@five c]$ grep -m1 "model name" /proc/cpuinfo | ./strcasestr "model name"
needle=model name
haystack=model name : AMD Ryzen 9 5950X 16-Core Processor
found: model name : AMD Ryzen 9 5950X 16-Core Processor
found[13..]: AMD Ryzen 9 5950X 16-Core Processor
[acme@five c]$ grep -m1 "model name" /proc/cpuinfo | ./strcasestr "Model Name"
needle=Model Name
haystack=model name : AMD Ryzen 9 5950X 16-Core Processor
found: model name : AMD Ryzen 9 5950X 16-Core Processor
found[13..]: AMD Ryzen 9 5950X 16-Core Processor
acme@five c]$ echo "Model Name : AMD Ryzen 9 5950X 16-Core Processor" | ./strcasestr "model name"
needle=model name
haystack=Model Name : AMD Ryzen 9 5950X 16-Core Processor
found: Model Name : AMD Ryzen 9 5950X 16-Core Processor
found[13..]: AMD Ryzen 9 5950X 16-Core Processor
[acme@five c]$ echo "MODEL NAME : AMD Ryzen 9 5950X 16-Core Processor" | ./strcasestr "model name"
needle=model name
haystack=MODEL NAME : AMD Ryzen 9 5950X 16-Core Processor
found: MODEL NAME : AMD Ryzen 9 5950X 16-Core Processor
found[13..]: AMD Ryzen 9 5950X 16-Core Processor
[acme@five c]$
[acme@five c]$ cat strcasestr.c
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
char *needle = argv[1], haystack[128], *found;
printf("needle=%s\n", needle);
fgets(haystack, sizeof(haystack), stdin);
printf("haystack=%s\n", haystack);
found = strcasestr(haystack, needle);
printf("found: %s", found);
printf("found[13..]: %s", found + 13);
return 0;
}
[acme@five c]$
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch
2023-08-25 13:45 ` Arnaldo Carvalho de Melo
@ 2023-08-26 9:19 ` Yanteng Si
0 siblings, 0 replies; 7+ messages in thread
From: Yanteng Si @ 2023-08-26 9:19 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: mingo, peterz, mark.rutland, alexander.shishkin, jolsa, namhyung,
irogers, adrian.hunter, chenhuacai, linux-perf-users,
loongson-kernel, loongarch
在 2023/8/25 21:45, Arnaldo Carvalho de Melo 写道:
> Em Fri, Aug 25, 2023 at 07:28:02PM +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 | 5 ++++-
>> 2 files changed, 6 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..5744a3036b01 100644
>> --- a/tools/perf/util/svghelper.c
>> +++ b/tools/perf/util/svghelper.c
>> @@ -331,7 +331,10 @@ 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;
>> + } else if (strcasestr(buf, "model name")) {
>> strlcpy(cpu_m, &buf[13], 255);
> Hey, the point of strcasestr() is to do a case _insensitive_ substring
> search, so all we need is:
>
>> --- a/tools/perf/util/svghelper.c
>> +++ b/tools/perf/util/svghelper.c
>> @@ -331,7 +331,10 @@ 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;
Thanks a million!
> Right? I'm doing this change while applying your patches.
>
> See:
>
> [acme@five c]$ grep -m1 "model name" /proc/cpuinfo | ./strcasestr "Model NAME"
> needle=Model NAME
> haystack=model name : AMD Ryzen 9 5950X 16-Core Processor
>
> found: model name : AMD Ryzen 9 5950X 16-Core Processor
> found[13..]: AMD Ryzen 9 5950X 16-Core Processor
> [acme@five c]$ grep -m1 "model name" /proc/cpuinfo | ./strcasestr "model name"
> needle=model name
> haystack=model name : AMD Ryzen 9 5950X 16-Core Processor
>
> found: model name : AMD Ryzen 9 5950X 16-Core Processor
> found[13..]: AMD Ryzen 9 5950X 16-Core Processor
> [acme@five c]$ grep -m1 "model name" /proc/cpuinfo | ./strcasestr "Model Name"
> needle=Model Name
> haystack=model name : AMD Ryzen 9 5950X 16-Core Processor
>
> found: model name : AMD Ryzen 9 5950X 16-Core Processor
> found[13..]: AMD Ryzen 9 5950X 16-Core Processor
> acme@five c]$ echo "Model Name : AMD Ryzen 9 5950X 16-Core Processor" | ./strcasestr "model name"
> needle=model name
> haystack=Model Name : AMD Ryzen 9 5950X 16-Core Processor
>
> found: Model Name : AMD Ryzen 9 5950X 16-Core Processor
> found[13..]: AMD Ryzen 9 5950X 16-Core Processor
> [acme@five c]$ echo "MODEL NAME : AMD Ryzen 9 5950X 16-Core Processor" | ./strcasestr "model name"
> needle=model name
> haystack=MODEL NAME : AMD Ryzen 9 5950X 16-Core Processor
>
> found: MODEL NAME : AMD Ryzen 9 5950X 16-Core Processor
> found[13..]: AMD Ryzen 9 5950X 16-Core Processor
> [acme@five c]$
> [acme@five c]$ cat strcasestr.c
> #define _GNU_SOURCE
> #include <stdio.h>
> #include <string.h>
>
> int main(int argc, char *argv[])I will send v3
> {
> char *needle = argv[1], haystack[128], *found;
> printf("needle=%s\n", needle);
> fgets(haystack, sizeof(haystack), stdin);
> printf("haystack=%s\n", haystack);
> found = strcasestr(haystack, needle);
> printf("found: %s", found);
> printf("found[13..]: %s", found + 13);
> return 0;
> }
> [acme@five c]$
I see. I will send v3.
Thanks,
Yanteng
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] perf/tools: Use "test -f" instead of "[-f FILE]"
2023-08-25 11:28 ` [PATCH v2 3/3] perf/tools: Use "test -f" instead of "[-f FILE]" Yanteng Si
@ 2023-08-26 9:42 ` Xi Ruoyao
0 siblings, 0 replies; 7+ messages in thread
From: Xi Ruoyao @ 2023-08-26 9:42 UTC (permalink / raw)
To: Yanteng Si, acme
Cc: mingo, peterz, mark.rutland, alexander.shishkin, jolsa, namhyung,
irogers, adrian.hunter, chenhuacai, linux-perf-users,
loongson-kernel, loongarch
On Fri, 2023-08-25 at 19:28 +0800, Yanteng Si wrote:
> It will be simpler without that extra subshell, so
> let's use "test -f".
I don't understand this sentence. I'm pretty sure [ ... ] does not
start any subshell.
> 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:]_]+)[[:spac
> e:]]+(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" | \
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-08-26 9:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-25 11:28 [PATCH v2 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-25 11:28 ` [PATCH v2 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
2023-08-25 13:45 ` Arnaldo Carvalho de Melo
2023-08-26 9:19 ` Yanteng Si
2023-08-25 11:28 ` [PATCH v2 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
2023-08-25 11:28 ` [PATCH v2 3/3] perf/tools: Use "test -f" instead of "[-f FILE]" Yanteng Si
2023-08-26 9:42 ` Xi Ruoyao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.