perf: write bpf_prog (infos|btfs)_cnt to data file
PATCH 1/1 perf: write bpf_prog (infos|btfs)_cnt to data file
With commit f0d0f978f3f58 ("perf header: Don't write empty BPF/BTF info"), the write_bpf_( prog_info() | btf() ) functions exit without writing anything if env->bpf_prog.(infos| btfs)_cnt is zero.
process_bpf_( prog_info() | btf() ), however, still expect a "count" value to exist in the data file. If btf information is empty, for example, process_bpf_btf will read garbage or some other data as the number of btf nodes in the data file. As a result, the data file will not be processed correctly.
Instead, write the count to the data file and exit if it is zero.
--- tools/perf/util/header.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
tools/perf/util/header.c +2 -8
@@ -1022,12 +1022,9 @@ static int write_bpf_prog_info(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.infos_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.infos_cnt,sizeof (env->bpf_progs.infos_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.infos_cnt ==0 ) goto out; root = &env->bpf_progs.infos;
@@ -1067,13 +1064,10 @@ static int write_bpf_btf(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.btfs_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.btfs_cnt,sizeof (env->bpf_progs.btfs_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.btfs_cnt ==0 ) goto out; root = &env->bpf_progs.btfs;
Signature · 1 line
2.47.3
Quoted 11 lines · Thomas Falcon
With commit
f0d0f978f3f58("perf header: Don't write empty BPF/BTF info"), thewrite_bpf_( prog_info() | btf() )functions exit without writing anything if env->bpf_prog.(infos| btfs)_cnt is zero.
process_bpf_( prog_info() | btf() ), however, still expect a "count" value to exist in the data file. If btf information is empty, for example,process_bpf_btfwill read garbage or some other data as the number of btf nodes in the data file. As a result, the data file will not be processed correctly.
Quoted 4 lines
Instead, write the count to the data file and exit if it is zero.
Fixes f0d0f978f3f58 ("perf header: Don't write empty BPF/BTF info")Signed-off-by Thomas Falcon <[email protected]>
Thanks!
Ian
Quoted 40 lines
--- tools/perf/util/header.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)tools/perf/util/header.c +2
-9@@ -1022,12 +1022,9 @@ static int write_bpf_prog_info(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.infos_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.infos_cnt,sizeof (env->bpf_progs.infos_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.infos_cnt ==0 ) goto out; root = &env->bpf_progs.infos;@@ -1067,13 +1064,10 @@ static int write_bpf_btf(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.btfs_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.btfs_cnt,sizeof (env->bpf_progs.btfs_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.btfs_cnt ==0 ) goto out; root = &env->bpf_progs.btfs; --2.47.3
Namhyung Kim
maintainerQuoted 11 lines · Thomas Falcon
With commit
f0d0f978f3f58("perf header: Don't write empty BPF/BTF info"), thewrite_bpf_( prog_info() | btf() )functions exit without writing anything if env->bpf_prog.(infos| btfs)_cnt is zero.
process_bpf_( prog_info() | btf() ), however, still expect a "count" value to exist in the data file. If btf information is empty, for example,process_bpf_btfwill read garbage or some other data as the number of btf nodes in the data file. As a result, the data file will not be processed correctly.Instead, write the count to the data file and exit if it is zero.
Oh, I'm afraid it'd create a compatibility problem. But I think this is a right behavior and it's should be fine if it goes to the stable soon.
Arnaldo, can you please take this into perf-tools tree for v6.18?
Thanks,
Namhyung
Quoted 43 lines
Fixes f0d0f978f3f58 ("perf header: Don't write empty BPF/BTF info")Signed-off-by Thomas Falcon <[email protected]>--- tools/perf/util/header.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)tools/perf/util/header.c +2
-8@@ -1022,12 +1022,9 @@ static int write_bpf_prog_info(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.infos_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.infos_cnt,sizeof (env->bpf_progs.infos_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.infos_cnt ==0 ) goto out; root = &env->bpf_progs.infos;@@ -1067,13 +1064,10 @@ static int write_bpf_btf(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.btfs_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.btfs_cnt,sizeof (env->bpf_progs.btfs_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.btfs_cnt ==0 ) goto out; root = &env->bpf_progs.btfs;Signature · 1 line
2.47.3
Arnaldo Carvalho de Melo
maintainerQuoted 11 lines · Namhyung Kim
Quoted 10 lines · Thomas Falcon
With commit
f0d0f978f3f58("perf header: Don't write empty BPF/BTF info"), thewrite_bpf_( prog_info() | btf() )functions exit without writing anything if env->bpf_prog.(infos| btfs)_cnt is zero.
process_bpf_( prog_info() | btf() ), however, still expect a "count" value to exist in the data file. If btf information is empty, for example,process_bpf_btfwill read garbage or some other data as the number of btf nodes in the data file. As a result, the data file will not be processed correctly.
Quoted 6 lines
Quoted 1 line
Instead, write the count to the data file and exit if it is zero.
Oh, I'm afraid it'd create a compatibility problem. But I think this is a right behavior and it's should be fine if it goes to the stable soon.
Arnaldo, can you please take this into perf-tools tree for v6.18?
Ok, agreed, I'm taking your request as an Acked-by, ok?
- Arnaldo
Quoted 46 lines
Thanks,
NamhyungQuoted 43 lines
Fixes f0d0f978f3f58 ("perf header: Don't write empty BPF/BTF info")Signed-off-by Thomas Falcon <[email protected]>--- tools/perf/util/header.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)tools/perf/util/header.c +2
-8@@ -1022,12 +1022,9 @@ static int write_bpf_prog_info(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.infos_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.infos_cnt,sizeof (env->bpf_progs.infos_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.infos_cnt ==0 ) goto out; root = &env->bpf_progs.infos;@@ -1067,13 +1064,10 @@ static int write_bpf_btf(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.btfs_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.btfs_cnt,sizeof (env->bpf_progs.btfs_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.btfs_cnt ==0 ) goto out; root = &env->bpf_progs.btfs;Signature · 1 line
2.47.3
Namhyung Kim
maintainerQuoted 12 lines · Arnaldo Carvalho de Melo
Quoted 11 lines · Namhyung Kim
Quoted 10 lines · Thomas Falcon
With commit
f0d0f978f3f58("perf header: Don't write empty BPF/BTF info"), thewrite_bpf_( prog_info() | btf() )functions exit without writing anything if env->bpf_prog.(infos| btfs)_cnt is zero.
process_bpf_( prog_info() | btf() ), however, still expect a "count" value to exist in the data file. If btf information is empty, for example,process_bpf_btfwill read garbage or some other data as the number of btf nodes in the data file. As a result, the data file will not be processed correctly.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Instead, write the count to the data file and exit if it is zero.
Oh, I'm afraid it'd create a compatibility problem. But I think this is a right behavior and it's should be fine if it goes to the stable soon.
Arnaldo, can you please take this into perf-tools tree for v6.18?
Ok, agreed, I'm taking your request as an Acked-by, ok?
Sure, thanks!
Namhyung
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Fixes f0d0f978f3f58 ("perf header: Don't write empty BPF/BTF info")Signed-off-by Thomas Falcon <[email protected]>--- tools/perf/util/header.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)tools/perf/util/header.c +2
-8@@ -1022,12 +1022,9 @@ static int write_bpf_prog_info(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.infos_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.infos_cnt,sizeof (env->bpf_progs.infos_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.infos_cnt ==0 ) goto out; root = &env->bpf_progs.infos;@@ -1067,13 +1064,10 @@ static int write_bpf_btf(struct feat_fd *ff,down_read (&env->bpf_progs.lock); -if (env->bpf_progs.btfs_cnt ==0 ) - goto out; - ret =do_write (ff, &env->bpf_progs.btfs_cnt,sizeof (env->bpf_progs.btfs_cnt)); -if (ret <0 ) +if (ret <0 || env->bpf_progs.btfs_cnt ==0 ) goto out; root = &env->bpf_progs.btfs;Signature · 1 line
2.47.3