Skip to contentSkip to conversation

perf skel: Remove some unused variables.

PATCH In review Ian Rogers 3 participants 7 messages Mar 6, 2021 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/3 perf skel: Remove some unused variables.

Fixes -Wall warnings.

---
 tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c +1 -2
index c7cec92d0236..ab12b4c4ece2 100644
@@ -52,7 +52,7 @@ int BPF_PROG(fentry_XXX)
 static inline void
 fexit_update_maps(struct bpf_perf_event_value *after)
 {
-	struct bpf_perf_event_value *before, diff, *accum;
+	struct bpf_perf_event_value *before, diff;
 	__u32 zero = 0;
 
 	before = bpf_map_lookup_elem(&fentry_readings, &zero);
@@ -78,7 +78,6 @@ int BPF_PROG(fexit_XXX)
 {
 	struct bpf_perf_event_value reading;
 	__u32 cpu = bpf_get_smp_processor_id();
-	__u32 one = 1, zero = 0;
 	int err;
 
 	/* read all events before updating the maps, to reduce error */
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
author reviewer
#1 lore raw

PATCH 2/3 perf tool: Enable warnings when compiling BPF programs

Add -Wall -Werror when compiling BPF skeletons.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index 5345ac70cd83..f43d2551f3de 100644
@@ -1029,7 +1029,7 @@ $(BPFTOOL): | $(SKEL_TMP_OUT)
 		OUTPUT=$(SKEL_TMP_OUT)/ bootstrap
 
 $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) | $(SKEL_TMP_OUT)
-	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf $(BPF_INCLUDE) \
+	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -Wall -Werror $(BPF_INCLUDE) \
 	  -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ && $(LLVM_STRIP) -g $@
 
 $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
Acked-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] perf tool: Enable warnings when compiling BPF programs

Quoted 7 lines · Ian Rogers

Add -Wall -Werror when compiling BPF skeletons.

Quoted 20 lines

---
tools/perf/Makefile.perf | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index 5345ac70cd83..f43d2551f3de 100644
@@ -1029,7 +1029,7 @@ $(BPFTOOL): | $(SKEL_TMP_OUT)
 		OUTPUT=$(SKEL_TMP_OUT)/ bootstrap
 
 $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) | $(SKEL_TMP_OUT)
-	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf $(BPF_INCLUDE) \
+	$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -Wall -Werror $(BPF_INCLUDE) \
 	  -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ && $(LLVM_STRIP) -g $@
 
 $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
author reviewer
#3 lore raw

PATCH 3/3 perf bpf: Minor whitespace cleanup.

In reply to Ian Rogers

Missed space after #include.

---
 tools/perf/util/bpf_counter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/bpf_counter.h +1 -1
index 2eca210e5dc1..cb9c532e0a07 100644
@@ -38,7 +38,7 @@ int bpf_counter__install_pe(struct evsel *evsel, int cpu, int fd);
 
 #else /* HAVE_BPF_SKEL */
 
-#include<linux/err.h>
+#include <linux/err.h>
 
 static inline int bpf_counter__load(struct evsel *evsel __maybe_unused,
 				    struct target *target __maybe_unused)
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
Acked-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] perf bpf: Minor whitespace cleanup.

Quoted 7 lines · Ian Rogers

Missed space after #include.

Quoted 20 lines

---
tools/perf/util/bpf_counter.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/bpf_counter.h +1 -1
index 2eca210e5dc1..cb9c532e0a07 100644
@@ -38,7 +38,7 @@ int bpf_counter__install_pe(struct evsel *evsel, int cpu, int fd);
 
 #else /* HAVE_BPF_SKEL */
 
-#include<linux/err.h>
+#include <linux/err.h>
 
 static inline int bpf_counter__load(struct evsel *evsel __maybe_unused,
 				    struct target *target __maybe_unused)
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
#5 lore raw
In reply to Ian Rogers

Em Sat, Mar 06, 2021 at 12:08:38AM -0800, Ian Rogers escreveu:

Quoted 1 line

Fixes -Wall warnings.

Thanks, tested all with:

  $ make BUILD_BPF_SKEL=1 PYTHON=python3 O=/tmp/build/perf -C tools/perf install-bin

Which makes me realize we need to turn both python3 and building the bpf skel to be the default...

- Arnaldo

Quoted 29 lines
---
 tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c +1 -2
index c7cec92d0236..ab12b4c4ece2 100644
@@ -52,7 +52,7 @@ int BPF_PROG(fentry_XXX)
 static inline void
 fexit_update_maps(struct bpf_perf_event_value *after)
 {
-	struct bpf_perf_event_value *before, diff, *accum;
+	struct bpf_perf_event_value *before, diff;
 	__u32 zero = 0;
 
 	before = bpf_map_lookup_elem(&fentry_readings, &zero);
@@ -78,7 +78,6 @@ int BPF_PROG(fexit_XXX)
 {
 	struct bpf_perf_event_value reading;
 	__u32 cpu = bpf_get_smp_processor_id();
-	__u32 one = 1, zero = 0;
 	int err;
 
 	/* read all events before updating the maps, to reduce error */
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog
Signature · 1 line
- Arnaldo
Acked-by on v1 1/3
#6 lore raw
In reply to Ian Rogers
Quoted 7 lines · Ian Rogers

Fixes -Wall warnings.

Thanks for the clean up!

Quoted 28 lines

---
tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c +0 -0
index c7cec92d0236..ab12b4c4ece2 100644
@@ -52,7 +52,7 @@ int BPF_PROG(fentry_XXX)

static inline void
fexit_update_maps(struct bpf_perf_event_value *after) {

tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c +1 -1
-	struct bpf_perf_event_value *before, diff, *accum;
+	struct bpf_perf_event_value *before, diff;
	__u32 zero = 0;

	before = bpf_map_lookup_elem(&fentry_readings, &zero);
tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c +0 -1
@@ -78,7 +78,6 @@ int BPF_PROG(fexit_XXX)
 {
 	struct bpf_perf_event_value reading;
 	__u32 cpu = bpf_get_smp_processor_id();
-	__u32 one = 1, zero = 0;
 	int err;
 
 	/* read all events before updating the maps, to reduce error */
Signature · 1 line
2.30.1.766.gb4fecdf3b7-goog