BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: handle prog/attach type comparison in veristat
@ 2025-01-06 14:43 Mykyta Yatsenko
  2025-01-06 20:57 ` Eduard Zingerman
  2025-01-08 15:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Mykyta Yatsenko @ 2025-01-06 14:43 UTC (permalink / raw)
  To: bpf, ast, andrii, daniel, kafai, kernel-team; +Cc: Mykyta Yatsenko

From: Mykyta Yatsenko <yatsenko@meta.com>

Implemented handling of prog type and attach type stats comparison in
veristat.
To test this change:
```
./veristat pyperf600.bpf.o -o csv > base1.csv
./veristat pyperf600.bpf.o -o csv > base2.csv
./veristat -C base2.csv base1.csv -o csv
...,raw_tracepoint,raw_tracepoint,MATCH,
...,cgroup_inet_ingress,cgroup_inet_ingress,MATCH
```
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
---
 tools/testing/selftests/bpf/veristat.c | 37 ++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c
index 476bf95cf684..974c808f9321 100644
--- a/tools/testing/selftests/bpf/veristat.c
+++ b/tools/testing/selftests/bpf/veristat.c
@@ -1688,9 +1688,42 @@ static int parse_stat_value(const char *str, enum stat_id id, struct verif_stats
 		st->stats[id] = val;
 		break;
 	}
-	case PROG_TYPE:
-	case ATTACH_TYPE:
+	case PROG_TYPE: {
+		enum bpf_prog_type prog_type = 0;
+		const char *type;
+
+		while ((type = libbpf_bpf_prog_type_str(prog_type)))  {
+			if (strcmp(type, str) == 0) {
+				st->stats[id] = prog_type;
+				break;
+			}
+			prog_type++;
+		}
+
+		if (!type) {
+			fprintf(stderr, "Unrecognized prog type %s\n", str);
+			return -EINVAL;
+		}
 		break;
+	}
+	case ATTACH_TYPE: {
+		enum bpf_attach_type attach_type = 0;
+		const char *type;
+
+		while ((type = libbpf_bpf_attach_type_str(attach_type)))  {
+			if (strcmp(type, str) == 0) {
+				st->stats[id] = attach_type;
+				break;
+			}
+			attach_type++;
+		}
+
+		if (!type) {
+			fprintf(stderr, "Unrecognized attach type %s\n", str);
+			return -EINVAL;
+		}
+		break;
+	}
 	default:
 		fprintf(stderr, "Unrecognized stat #%d\n", id);
 		return -EINVAL;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: handle prog/attach type comparison in veristat
  2025-01-06 14:43 [PATCH bpf-next] selftests/bpf: handle prog/attach type comparison in veristat Mykyta Yatsenko
@ 2025-01-06 20:57 ` Eduard Zingerman
  2025-01-08 15:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eduard Zingerman @ 2025-01-06 20:57 UTC (permalink / raw)
  To: Mykyta Yatsenko, bpf, ast, andrii, daniel, kafai, kernel-team
  Cc: Mykyta Yatsenko

On Mon, 2025-01-06 at 14:43 +0000, Mykyta Yatsenko wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
> 
> Implemented handling of prog type and attach type stats comparison in
> veristat.
> To test this change:
> ```
> ./veristat pyperf600.bpf.o -o csv > base1.csv
> ./veristat pyperf600.bpf.o -o csv > base2.csv
> ./veristat -C base2.csv base1.csv -o csv
> ...,raw_tracepoint,raw_tracepoint,MATCH,
> ...,cgroup_inet_ingress,cgroup_inet_ingress,MATCH
> ```
> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
> ---

Seem to work fine.

Tested-by: Eduard Zingerman <eddyz87@gmail.com>

[...]


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: handle prog/attach type comparison in veristat
  2025-01-06 14:43 [PATCH bpf-next] selftests/bpf: handle prog/attach type comparison in veristat Mykyta Yatsenko
  2025-01-06 20:57 ` Eduard Zingerman
@ 2025-01-08 15:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-08 15:10 UTC (permalink / raw)
  To: Mykyta Yatsenko; +Cc: bpf, ast, andrii, daniel, kafai, kernel-team, yatsenko

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Mon,  6 Jan 2025 14:43:21 +0000 you wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
> 
> Implemented handling of prog type and attach type stats comparison in
> veristat.
> To test this change:
> ```
> ./veristat pyperf600.bpf.o -o csv > base1.csv
> ./veristat pyperf600.bpf.o -o csv > base2.csv
> ./veristat -C base2.csv base1.csv -o csv
> ...,raw_tracepoint,raw_tracepoint,MATCH,
> ...,cgroup_inet_ingress,cgroup_inet_ingress,MATCH
> ```
> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: handle prog/attach type comparison in veristat
    https://git.kernel.org/bpf/bpf-next/c/46c61cbeb82f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-08 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 14:43 [PATCH bpf-next] selftests/bpf: handle prog/attach type comparison in veristat Mykyta Yatsenko
2025-01-06 20:57 ` Eduard Zingerman
2025-01-08 15:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox