Skip to contentSkip to conversation

Miscellaneous fixes for BPF (perf tree)

PATCH Applied Mickaël Salaün 4 participants 8 messages Feb 8, 2017 – Feb 13, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover Miscellaneous fixes for BPF (perf tree)

This series brings some fixes and small improvements to the BPF samples.

This is intended for the perf tree and apply on 7a5980f9c006 ("tools lib bpf:
Add missing header to the library").

Changes since v3:
* remove applied patch 1/5
* remove patch 2/5 on bpf_load_program() as requested by Wang Nan

Changes since v2:
* add this cover letter

Changes since v1:
* exclude patches not intended for the perf tree

Regards,

Mickaël Salaün (3):
samples/bpf: Ignore already processed ELF sections samples/bpf: Reset global variables samples/bpf: Add missing header

 samples/bpf/bpf_load.c     | 7 +++++++
 samples/bpf/tracex5_kern.c | 1 +
 2 files changed, 8 insertions(+)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v4 1/3 samples/bpf: Ignore already processed ELF sections

Add a missing check for the map fixup loop.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
---
 samples/bpf/bpf_load.c | 2 ++
 1 file changed, 2 insertions(+)
samples/bpf/bpf_load.c +2 -0
index 396e204888b3..e04fe09d7c2e 100644
@@ -328,6 +328,8 @@ int load_bpf_file(char *path)
 
 	/* load programs that need map fixup (relocations) */
 	for (i = 1; i < ehdr.e_shnum; i++) {
+		if (processed_sec[i])
+			continue;
 
 		if (get_sec(elf, i, &ehdr, &shname, &shdr, &data))
 			continue;
Signature · 1 line
2.11.0
#2 lore raw

PATCH v4 2/3 samples/bpf: Reset global variables

In reply to Mickaël Salaün

Before loading a new ELF, clean previous kernel version, license and processed sections.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
---
 samples/bpf/bpf_load.c | 5 +++++
 1 file changed, 5 insertions(+)
samples/bpf/bpf_load.c +5 -0
index e04fe09d7c2e..b86ee54da2d1 100644
@@ -277,6 +277,11 @@ int load_bpf_file(char *path)
 	Elf_Data *data, *data_prog, *symbols = NULL;
 	char *shname, *shname_prog;
 
+	/* reset global variables */
+	kern_version = 0;
+	memset(license, 0, sizeof(license));
+	memset(processed_sec, 0, sizeof(processed_sec));
+
 	if (elf_version(EV_CURRENT) == EV_NONE)
 		return 1;
 
Signature · 1 line
2.11.0
#3 lore raw

PATCH v4 3/3 samples/bpf: Add missing header

In reply to Mickaël Salaün

Include unistd.h to define __NR_getuid and __NR_getsid.

Cc Alexei Starovoitov <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David S. Miller <[email protected]>
---
 samples/bpf/tracex5_kern.c | 1 +
 1 file changed, 1 insertion(+)
samples/bpf/tracex5_kern.c +1 -0
index fd12d7154d42..7e4cf74553ff 100644
@@ -8,6 +8,7 @@
 #include <linux/version.h>
 #include <uapi/linux/bpf.h>
 #include <uapi/linux/seccomp.h>
+#include <uapi/linux/unistd.h>
 #include "bpf_helpers.h"
 
 #define PROG(F) SEC("kprobe/"__stringify(F)) int bpf_func_##F
Signature · 1 line
2.11.0
#4 lore raw
In reply to Mickaël Salaün

Em Wed, Feb 08, 2017 at 09:27:41PM +0100, Mickaël Salaün escreveu:

Quoted 4 lines

This series brings some fixes and small improvements to the BPF samples.

This is intended for the perf tree and apply on 7a5980f9c006 ("tools lib bpf:
Add missing header to the library").

Wang, are you ok with this series? Joe?

- Arnaldo

Quoted 23 lines

Changes since v3:
* remove applied patch 1/5
* remove patch 2/5 on bpf_load_program() as requested by Wang Nan

Changes since v2:
* add this cover letter

Changes since v1:
* exclude patches not intended for the perf tree

Regards,

Mickaël Salaün (3):
samples/bpf: Ignore already processed ELF sections samples/bpf: Reset global variables samples/bpf: Add missing header

 samples/bpf/bpf_load.c     | 7 +++++++
 samples/bpf/tracex5_kern.c | 1 +
 2 files changed, 8 insertions(+)
Signature · 1 line
2.11.0
#5 lore raw
Quoted 7 lines · Arnaldo Carvalho de Melo

Em Wed, Feb 08, 2017 at 09:27:41PM +0100, Mickaël Salaün escreveu:

Quoted 4 lines

This series brings some fixes and small improvements to the BPF samples.

This is intended for the perf tree and apply on 7a5980f9c006 ("tools lib bpf:
Add missing header to the library").

Wang, are you ok with this series? Joe?

The changes look good to me. I also tried tracex5 and it seems to work fine.

#6 lore raw
In reply to Mickaël Salaün
Quoted 17 lines · Mickaël Salaün

This series brings some fixes and small improvements to the BPF samples.

This is intended for the perf tree and apply on 7a5980f9c006 ("tools lib bpf:
Add missing header to the library").

Changes since v3:
* remove applied patch 1/5
* remove patch 2/5 on bpf_load_program() as requested by Wang Nan

Changes since v2:
* add this cover letter

Changes since v1:
* exclude patches not intended for the perf tree

Regards,

Quoted 9 lines

Mickaël Salaün (3):
samples/bpf: Ignore already processed ELF sections samples/bpf: Reset global variables samples/bpf: Add missing header

  samples/bpf/bpf_load.c     | 7 +++++++
  samples/bpf/tracex5_kern.c | 1 +
  2 files changed, 8 insertions(+)

Looks good to me.

Thank you.

#7 lore raw

Em Mon, Feb 13, 2017 at 09:42:31AM +0800, Wangnan (F) escreveu:

Quoted 6 lines · Mickaël Salaün
Quoted 5 lines

Mickaël Salaün (3):
samples/bpf: Ignore already processed ELF sections samples/bpf: Reset global variables samples/bpf: Add missing header

Quoted 7 lines
Quoted 4 lines
 samples/bpf/bpf_load.c     | 7 +++++++
 samples/bpf/tracex5_kern.c | 1 +
 2 files changed, 8 insertions(+)

Looks good to me.

Thank you.

Thanks, applied, added Acked-by tags for you and Joe.

- Arnaldo