Skip to contentSkip to conversation

perf: stop using deprecated bpf APIs

PATCH Superseded Andrii Nakryiko 3 participants 8 messages Feb 12, 2022

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

v5 cover perf: stop using deprecated bpf APIs

libbpf's bpf_prog_load() and bpf__object_next() APIs are deprecated. remove perf's usage of these deprecated functions. After this patch set, the only remaining libbpf deprecated APIs in perf would be bpf_program__set_prep() and bpf_program__nth_fd().

v4 -> v5:
- add bpf_perf_object__add() and use it where appropriate (Jiri);
- use __maybe_unused in first patch;
v3 -> v4:
- Fixed commit title
- Added weak definition for deprecated function
v2 -> v3:
- Fixed commit message to use upstream perf
v1 -> v2:
- Added missing commit message
- Added more details to commit message and added steps to reproduce original test case.

Christy Lee (2):
perf: Stop using deprecated bpf_load_program() API
perf: Stop using deprecated bpf_object__next() API

 tools/perf/tests/bpf.c       | 14 ++----
 tools/perf/util/bpf-event.c  | 13 +++++
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 3 files changed, 96 insertions(+), 29 deletions(-)
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH v5 1/2 perf: Stop using deprecated bpf_load_program() API

From: Christy Lee <[email protected]>

bpf_load_program() API is deprecated, remove perf's usage of the deprecated function. Add a __weak function declaration for libbpf version compatibility.

---
 tools/perf/tests/bpf.c      | 14 ++++----------
 tools/perf/util/bpf-event.c | 13 +++++++++++++
 2 files changed, 17 insertions(+), 10 deletions(-)
tools/perf/tests/bpf.c +4 -10
index 573490530194..57b9591f7cbb 100644
@@ -281,8 +281,8 @@ static int __test__bpf(int idx)
 
 static int check_env(void)
 {
+	LIBBPF_OPTS(bpf_prog_load_opts, opts);
 	int err;
-	unsigned int kver_int;
 	char license[] = "GPL";
 
 	struct bpf_insn insns[] = {
@@ -290,19 +290,13 @@ static int check_env(void)
 		BPF_EXIT_INSN(),
 	};
 
-	err = fetch_kernel_version(&kver_int, NULL, 0);
+	err = fetch_kernel_version(&opts.kern_version, NULL, 0);
 	if (err) {
 		pr_debug("Unable to get kernel version\n");
 		return err;
 	}
-
-/* temporarily disable libbpf deprecation warnings */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-	err = bpf_load_program(BPF_PROG_TYPE_KPROBE, insns,
-			       ARRAY_SIZE(insns),
-			       license, kver_int, NULL, 0);
-#pragma GCC diagnostic pop
+	err = bpf_prog_load(BPF_PROG_TYPE_KPROBE, NULL, license, insns,
+			    ARRAY_SIZE(insns), &opts);
 	if (err < 0) {
 		pr_err("Missing basic BPF support, skip this test: %s\n",
 		       strerror(errno));
tools/perf/util/bpf-event.c +13 -0
index a517eaa51eb3..bd1bc3c86cac 100644
@@ -33,6 +33,19 @@ struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
        return err ? ERR_PTR(err) : btf;
 }
 
+int __weak bpf_prog_load(enum bpf_prog_type prog_type,
+			 const char *prog_name __maybe_unused,
+			 const char *license,
+			 const struct bpf_insn *insns, size_t insn_cnt,
+			 const struct bpf_prog_load_opts *opts)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+	return bpf_load_program(prog_type, insns, insn_cnt, license,
+				opts->kern_version, opts->log_buf, opts->log_size);
+#pragma GCC diagnostic pop
+}
+
 struct bpf_program * __weak
 bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
 {
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH v5 2/2 perf: Stop using deprecated bpf_object__next() API

In reply to Andrii Nakryiko

From: Christy Lee <[email protected]>

Libbpf has deprecated the ability to keep track of object list inside libbpf, it now requires applications to track usage multiple bpf objects directly. Remove usage of bpf_object__next() API and hoist the tracking logic to perf.

---
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 1 file changed, 79 insertions(+), 19 deletions(-)
tools/perf/util/bpf-loader.c +79 -19
index 3cd5ae200f2c..7ff556ef1137 100644
@@ -49,8 +49,52 @@ struct bpf_prog_priv {
 	int *type_mapping;
 };
 
+struct bpf_perf_object {
+	struct list_head list;
+	struct bpf_object *obj;
+};
+
+static LIST_HEAD(bpf_objects_list);
+
+static struct bpf_perf_object *
+bpf_perf_object__next(struct bpf_perf_object *prev)
+{
+	struct bpf_perf_object *next;
+
+	if (!prev)
+		next = list_first_entry(&bpf_objects_list,
+					struct bpf_perf_object,
+					list);
+	else
+		next = list_next_entry(prev, list);
+
+	/* Empty list is noticed here so don't need checking on entry. */
+	if (&next->list == &bpf_objects_list)
+		return NULL;
+
+	return next;
+}
+
+#define bpf_perf_object__for_each(perf_obj, tmp)	\
+	for ((perf_obj) = bpf_perf_object__next(NULL),	\
+	     (tmp) = bpf_perf_object__next(perf_obj);	\
+	     (perf_obj) != NULL;			\
+	     (perf_obj) = (tmp), (tmp) = bpf_perf_object__next(tmp))
+
 static bool libbpf_initialized;
 
+static int bpf_perf_object__add(struct bpf_object *obj)
+{
+	struct bpf_perf_object *perf_obj = zalloc(sizeof(*perf_obj));
+
+	if (perf_obj) {
+		INIT_LIST_HEAD(&perf_obj->list);
+		perf_obj->obj = obj;
+		list_add_tail(&perf_obj->list, &bpf_objects_list);
+	}
+	return perf_obj ? 0 : -ENOMEM;
+}
+
 struct bpf_object *
 bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
 {
@@ -68,9 +112,21 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
 		return ERR_PTR(-EINVAL);
 	}
 
+	if (bpf_perf_object__add(obj)) {
+		bpf_object__close(obj);
+		return ERR_PTR(-ENOMEM);
+	}
+
 	return obj;
 }
 
+static void bpf_perf_object__close(struct bpf_perf_object *perf_obj)
+{
+	list_del(&perf_obj->list);
+	bpf_object__close(perf_obj->obj);
+	free(perf_obj);
+}
+
 struct bpf_object *bpf__prepare_load(const char *filename, bool source)
 {
 	LIBBPF_OPTS(bpf_object_open_opts, opts, .object_name = filename);
@@ -102,24 +158,30 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
 			llvm__dump_obj(filename, obj_buf, obj_buf_sz);
 
 		free(obj_buf);
-	} else
+	} else {
 		obj = bpf_object__open(filename);
+	}
 
 	if (IS_ERR_OR_NULL(obj)) {
 		pr_debug("bpf: failed to load %s\n", filename);
 		return obj;
 	}
 
+	if (bpf_perf_object__add(obj)) {
+		bpf_object__close(obj);
+		return ERR_PTR(-BPF_LOADER_ERRNO__COMPILE);
+	}
+
 	return obj;
 }
 
 void bpf__clear(void)
 {
-	struct bpf_object *obj, *tmp;
+	struct bpf_perf_object *perf_obj, *tmp;
 
-	bpf_object__for_each_safe(obj, tmp) {
-		bpf__unprobe(obj);
-		bpf_object__close(obj);
+	bpf_perf_object__for_each(perf_obj, tmp) {
+		bpf__unprobe(perf_obj->obj);
+		bpf_perf_object__close(perf_obj);
 	}
 }
 
@@ -1493,11 +1555,11 @@ apply_obj_config_object(struct bpf_object *obj)
 
 int bpf__apply_obj_config(void)
 {
-	struct bpf_object *obj, *tmp;
+	struct bpf_perf_object *perf_obj, *tmp;
 	int err;
 
-	bpf_object__for_each_safe(obj, tmp) {
-		err = apply_obj_config_object(obj);
+	bpf_perf_object__for_each(perf_obj, tmp) {
+		err = apply_obj_config_object(perf_obj->obj);
 		if (err)
 			return err;
 	}
@@ -1505,26 +1567,24 @@ int bpf__apply_obj_config(void)
 	return 0;
 }
 
-#define bpf__for_each_map(pos, obj, objtmp)	\
-	bpf_object__for_each_safe(obj, objtmp)	\
-		bpf_object__for_each_map(pos, obj)
+#define bpf__perf_for_each_map(map, pobj, tmp)			\
+	bpf_perf_object__for_each(pobj, tmp)			\
+		bpf_object__for_each_map(map, pobj->obj)
 
-#define bpf__for_each_map_named(pos, obj, objtmp, name)	\
-	bpf__for_each_map(pos, obj, objtmp) 		\
-		if (bpf_map__name(pos) && 		\
-			(strcmp(name, 			\
-				bpf_map__name(pos)) == 0))
+#define bpf__perf_for_each_map_named(map, pobj, pobjtmp, name)	\
+	bpf__perf_for_each_map(map, pobj, pobjtmp)		\
+		if (bpf_map__name(map) && (strcmp(name, bpf_map__name(map)) == 0))
 
 struct evsel *bpf__setup_output_event(struct evlist *evlist, const char *name)
 {
 	struct bpf_map_priv *tmpl_priv = NULL;
-	struct bpf_object *obj, *tmp;
+	struct bpf_perf_object *perf_obj, *tmp;
 	struct evsel *evsel = NULL;
 	struct bpf_map *map;
 	int err;
 	bool need_init = false;
 
-	bpf__for_each_map_named(map, obj, tmp, name) {
+	bpf__perf_for_each_map_named(map, perf_obj, tmp, name) {
 		struct bpf_map_priv *priv = bpf_map__priv(map);
 
 		if (IS_ERR(priv))
@@ -1560,7 +1620,7 @@ struct evsel *bpf__setup_output_event(struct evlist *evlist, const char *name)
 		evsel = evlist__last(evlist);
 	}
 
-	bpf__for_each_map_named(map, obj, tmp, name) {
+	bpf__perf_for_each_map_named(map, perf_obj, tmp, name) {
 		struct bpf_map_priv *priv = bpf_map__priv(map);
 
 		if (IS_ERR(priv))
Signature · 1 line
2.30.2
#3 lore raw
In reply to Andrii Nakryiko

Em Fri, Feb 11, 2022 at 11:30:52PM -0800, Andrii Nakryiko escreveu:

Quoted 4 lines

libbpf's bpf_prog_load() and bpf__object_next() APIs are deprecated. remove perf's usage of these deprecated functions. After this patch set, the only remaining libbpf deprecated APIs in perf would be bpf_program__set_prep() and bpf_program__nth_fd().

Not applying to perf/core, I'm checking...

⬢[acme@toolbox perf]$ b4 am -ctsl --cc-trailers [email protected] Looking up https://lore.kernel.org/r/20220212073054.1052880-1-andrii%40kernel.org
Grabbing thread from lore.kernel.org/all/20220212073054.1052880-1-andrii%40kernel.org/t.mbox.gz Checking for newer revisions on https://lore.kernel.org/all/
Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/2] perf: Stop using deprecated bpf_load_program() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
[PATCH v5 2/2] perf: Stop using deprecated bpf_object__next() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
---
Total patches: 2
---
Cover: ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.cover

Base: not specified

       git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx

⬢[acme@toolbox perf]$ git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx
Applying: perf: Stop using deprecated bpf_load_program() API
Applying: perf: Stop using deprecated bpf_object__next() API
error: patch failed: tools/perf/util/bpf-loader.c:68
error: tools/perf/util/bpf-loader.c: patch does not apply Patch failed at 0002 perf: Stop using deprecated bpf_object__next() API
hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

- Arnaldo

Quoted 24 lines

v4 -> v5:
- add bpf_perf_object__add() and use it where appropriate (Jiri);
- use __maybe_unused in first patch;
v3 -> v4:
- Fixed commit title
- Added weak definition for deprecated function
v2 -> v3:
- Fixed commit message to use upstream perf
v1 -> v2:
- Added missing commit message
- Added more details to commit message and added steps to reproduce original test case.

Christy Lee (2):
perf: Stop using deprecated bpf_load_program() API
perf: Stop using deprecated bpf_object__next() API

 tools/perf/tests/bpf.c       | 14 ++----
 tools/perf/util/bpf-event.c  | 13 +++++
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 3 files changed, 96 insertions(+), 29 deletions(-)
Signature · 1 line
2.30.2
Signature · 1 line
- Arnaldo
#4 lore raw

Em Sat, Feb 12, 2022 at 12:34:58PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Feb 11, 2022 at 11:30:52PM -0800, Andrii Nakryiko escreveu:

Quoted 4 lines

libbpf's bpf_prog_load() and bpf__object_next() APIs are deprecated. remove perf's usage of these deprecated functions. After this patch set, the only remaining libbpf deprecated APIs in perf would be bpf_program__set_prep() and bpf_program__nth_fd().

Not applying to perf/core, I'm checking...

Just some fuzz on the second patch:

⬢[acme@toolbox perf]$ patch -p1 < ~/wb/1.patch patching file tools/perf/util/bpf-loader.c Hunk #2 succeeded at 111 with fuzz 1 (offset -1 lines). Hunk #3 succeeded at 156 (offset -2 lines). Hunk #4 succeeded at 1563 (offset 8 lines). Hunk #5 succeeded at 1575 (offset 8 lines). Hunk #6 succeeded at 1628 (offset 8 lines). ⬢[acme@toolbox perf]$

Applying manually to test on the set of test build containers.

- Arnaldo

Quoted 70 lines

⬢[acme@toolbox perf]$ b4 am -ctsl --cc-trailers [email protected] Looking up https://lore.kernel.org/r/20220212073054.1052880-1-andrii%40kernel.org
Grabbing thread from lore.kernel.org/all/20220212073054.1052880-1-andrii%40kernel.org/t.mbox.gz Checking for newer revisions on https://lore.kernel.org/all/
Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/2] perf: Stop using deprecated bpf_load_program() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
[PATCH v5 2/2] perf: Stop using deprecated bpf_object__next() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
---
Total patches: 2
---
Cover: ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.cover

Base: not specified

       git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx

⬢[acme@toolbox perf]$ git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx
Applying: perf: Stop using deprecated bpf_load_program() API
Applying: perf: Stop using deprecated bpf_object__next() API
error: patch failed: tools/perf/util/bpf-loader.c:68
error: tools/perf/util/bpf-loader.c: patch does not apply Patch failed at 0002 perf: Stop using deprecated bpf_object__next() API
hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

- Arnaldo

Quoted 24 lines

v4 -> v5:
- add bpf_perf_object__add() and use it where appropriate (Jiri);
- use __maybe_unused in first patch;
v3 -> v4:
- Fixed commit title
- Added weak definition for deprecated function
v2 -> v3:
- Fixed commit message to use upstream perf
v1 -> v2:
- Added missing commit message
- Added more details to commit message and added steps to reproduce original test case.

Christy Lee (2):
perf: Stop using deprecated bpf_load_program() API
perf: Stop using deprecated bpf_object__next() API

 tools/perf/tests/bpf.c       | 14 ++----
 tools/perf/util/bpf-event.c  | 13 +++++
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 3 files changed, 96 insertions(+), 29 deletions(-)
Signature · 1 line
2.30.2
Signature · 1 line
- Arnaldo
Signature · 1 line
- Arnaldo
#5 lore raw
Quoted 21 lines · Arnaldo Carvalho de Melo

Em Sat, Feb 12, 2022 at 12:34:58PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Feb 11, 2022 at 11:30:52PM -0800, Andrii Nakryiko escreveu:

Quoted 4 lines

libbpf's bpf_prog_load() and bpf__object_next() APIs are deprecated. remove perf's usage of these deprecated functions. After this patch set, the only remaining libbpf deprecated APIs in perf would be bpf_program__set_prep() and bpf_program__nth_fd().

Not applying to perf/core, I'm checking...

Just some fuzz on the second patch:

⬢[acme@toolbox perf]$ patch -p1 < ~/wb/1.patch patching file tools/perf/util/bpf-loader.c Hunk #2 succeeded at 111 with fuzz 1 (offset -1 lines). Hunk #3 succeeded at 156 (offset -2 lines). Hunk #4 succeeded at 1563 (offset 8 lines). Hunk #5 succeeded at 1575 (offset 8 lines). Hunk #6 succeeded at 1628 (offset 8 lines). ⬢[acme@toolbox perf]$

Quoted 1 line

Applying manually to test on the set of test build containers.

Sorry, my bad. I just followed my typical bpf-next routine and didn't even think twice before basing everything off bpf-next. You can see I didn't even CC you or [email protected]. :(

I'll resend v6 against perf/core.

Quoted 77 lines

- Arnaldo

Quoted 64 lines

⬢[acme@toolbox perf]$ b4 am -ctsl --cc-trailers [email protected] Looking up https://lore.kernel.org/r/20220212073054.1052880-1-andrii%40kernel.org
Grabbing thread from lore.kernel.org/all/20220212073054.1052880-1-andrii%40kernel.org/t.mbox.gz Checking for newer revisions on https://lore.kernel.org/all/
Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/2] perf: Stop using deprecated bpf_load_program() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
[PATCH v5 2/2] perf: Stop using deprecated bpf_object__next() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
---
Total patches: 2
---
Cover: ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.cover

Base: not specified

       git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx

⬢[acme@toolbox perf]$ git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx
Applying: perf: Stop using deprecated bpf_load_program() API
Applying: perf: Stop using deprecated bpf_object__next() API
error: patch failed: tools/perf/util/bpf-loader.c:68
error: tools/perf/util/bpf-loader.c: patch does not apply Patch failed at 0002 perf: Stop using deprecated bpf_object__next() API
hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

- Arnaldo

Quoted 22 lines

v4 -> v5:
- add bpf_perf_object__add() and use it where appropriate (Jiri);
- use __maybe_unused in first patch;
v3 -> v4:
- Fixed commit title
- Added weak definition for deprecated function
v2 -> v3:
- Fixed commit message to use upstream perf
v1 -> v2:
- Added missing commit message
- Added more details to commit message and added steps to reproduce original test case.

Christy Lee (2):
perf: Stop using deprecated bpf_load_program() API
perf: Stop using deprecated bpf_object__next() API

 tools/perf/tests/bpf.c       | 14 ++----
 tools/perf/util/bpf-event.c  | 13 +++++
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 3 files changed, 96 insertions(+), 29 deletions(-)
Quoted 6 lines
Quoted 2 lines

--
2.30.2

--

- Arnaldo

--

- Arnaldo

#6 lore raw
In reply to Arnaldo Carvalho de Melo

Em Sat, Feb 12, 2022 at 12:36:49PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 20 lines

Em Sat, Feb 12, 2022 at 12:34:58PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Feb 11, 2022 at 11:30:52PM -0800, Andrii Nakryiko escreveu:

Quoted 4 lines

libbpf's bpf_prog_load() and bpf__object_next() APIs are deprecated. remove perf's usage of these deprecated functions. After this patch set, the only remaining libbpf deprecated APIs in perf would be bpf_program__set_prep() and bpf_program__nth_fd().

Not applying to perf/core, I'm checking...

Just some fuzz on the second patch:

⬢[acme@toolbox perf]$ patch -p1 < ~/wb/1.patch patching file tools/perf/util/bpf-loader.c Hunk #2 succeeded at 111 with fuzz 1 (offset -1 lines). Hunk #3 succeeded at 156 (offset -2 lines). Hunk #4 succeeded at 1563 (offset 8 lines). Hunk #5 succeeded at 1575 (offset 8 lines). Hunk #6 succeeded at 1628 (offset 8 lines). ⬢[acme@toolbox perf]$

Quoted 1 line

Applying manually to test on the set of test build containers.

perf test clean, these also work:

# perf trace -e tools/perf/examples/bpf/augmented_raw_syscalls.c  sleep 1
[root@quaco perf]# perf trace -e tools/perf/examples/bpf/5sec.c  sleep 5s
     0.000 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1994947936, rqtp: 5000000000)
[root@quaco perf]#

containers building:

[perfbuilder@five ~]$ export BUILD_TARBALL=http://192.168.100.2/perf/perf-5.17.0-rc3.tar.xz [perfbuilder@five ~]$ time dm

   1   164.81 almalinux:8                   : Ok   gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4) , clang version 12.0.1 (Red Hat 12.0.1-4.module_el8.5.0+1025+93159d6c)
   2    90.60 alpine:3.4                    : Ok   gcc (Alpine 5.3.0) 5.3.0 , clang version 3.8.0 (tags/RELEASE_380/final)
   3    55.88 alpine:3.5                    : Ok   gcc (Alpine 6.2.1) 6.2.1 20160822 , clang version 3.8.1 (tags/RELEASE_381/final)
   4    58.69 alpine:3.6                    : Ok   gcc (Alpine 6.3.0) 6.3.0 , clang version 4.0.0 (tags/RELEASE_400/final)
   5    65.65 alpine:3.7                    : Ok   gcc (Alpine 6.4.0) 6.4.0 , Alpine clang version 5.0.0 (tags/RELEASE_500/final) (based on LLVM 5.0.0)
   6    69.85 alpine:3.8                    : Ok   gcc (Alpine 6.4.0) 6.4.0 , Alpine clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
   7    66.83 alpine:3.9                    : Ok   gcc (Alpine 8.3.0) 8.3.0 , Alpine clang version 5.0.1 (tags/RELEASE_502/final) (based on LLVM 5.0.1)

8: alpine:3.10

I don't expect problems with those, so probably later today I'll push it to perf/core so that it will be on its way t 5.18.

- Arnaldo

Quoted 75 lines
Quoted 71 lines

⬢[acme@toolbox perf]$ b4 am -ctsl --cc-trailers [email protected] Looking up https://lore.kernel.org/r/20220212073054.1052880-1-andrii%40kernel.org
Grabbing thread from lore.kernel.org/all/20220212073054.1052880-1-andrii%40kernel.org/t.mbox.gz Checking for newer revisions on https://lore.kernel.org/all/
Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/2] perf: Stop using deprecated bpf_load_program() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
[PATCH v5 2/2] perf: Stop using deprecated bpf_object__next() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
---
Total patches: 2
---
Cover: ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.cover

Base: not specified

       git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx

⬢[acme@toolbox perf]$ git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx
Applying: perf: Stop using deprecated bpf_load_program() API
Applying: perf: Stop using deprecated bpf_object__next() API
error: patch failed: tools/perf/util/bpf-loader.c:68
error: tools/perf/util/bpf-loader.c: patch does not apply Patch failed at 0002 perf: Stop using deprecated bpf_object__next() API
hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

- Arnaldo

Quoted 24 lines

v4 -> v5:
- add bpf_perf_object__add() and use it where appropriate (Jiri);
- use __maybe_unused in first patch;
v3 -> v4:
- Fixed commit title
- Added weak definition for deprecated function
v2 -> v3:
- Fixed commit message to use upstream perf
v1 -> v2:
- Added missing commit message
- Added more details to commit message and added steps to reproduce original test case.

Christy Lee (2):
perf: Stop using deprecated bpf_load_program() API
perf: Stop using deprecated bpf_object__next() API

 tools/perf/tests/bpf.c       | 14 ++----
 tools/perf/util/bpf-event.c  | 13 +++++
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 3 files changed, 96 insertions(+), 29 deletions(-)
Signature · 1 line
2.30.2
Signature · 1 line
- Arnaldo
Signature · 1 line
- Arnaldo
Signature · 1 line
- Arnaldo
#7 lore raw
Quoted 42 lines · Arnaldo Carvalho de Melo

Em Sat, Feb 12, 2022 at 12:36:49PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 20 lines

Em Sat, Feb 12, 2022 at 12:34:58PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 7 lines

Em Fri, Feb 11, 2022 at 11:30:52PM -0800, Andrii Nakryiko escreveu:

Quoted 4 lines

libbpf's bpf_prog_load() and bpf__object_next() APIs are deprecated. remove perf's usage of these deprecated functions. After this patch set, the only remaining libbpf deprecated APIs in perf would be bpf_program__set_prep() and bpf_program__nth_fd().

Not applying to perf/core, I'm checking...

Just some fuzz on the second patch:

⬢[acme@toolbox perf]$ patch -p1 < ~/wb/1.patch patching file tools/perf/util/bpf-loader.c Hunk #2 succeeded at 111 with fuzz 1 (offset -1 lines). Hunk #3 succeeded at 156 (offset -2 lines). Hunk #4 succeeded at 1563 (offset 8 lines). Hunk #5 succeeded at 1575 (offset 8 lines). Hunk #6 succeeded at 1628 (offset 8 lines). ⬢[acme@toolbox perf]$

Quoted 1 line

Applying manually to test on the set of test build containers.

perf test clean, these also work:

# perf trace -e tools/perf/examples/bpf/augmented_raw_syscalls.c  sleep 1
[root@quaco perf]# perf trace -e tools/perf/examples/bpf/5sec.c  sleep 5s
     0.000 perf_bpf_probe:hrtimer_nanosleep(__probe_ip: -1994947936, rqtp: 5000000000)
[root@quaco perf]#

containers building:

[perfbuilder@five ~]$ export BUILD_TARBALL=http://192.168.100.2/perf/perf-5.17.0-rc3.tar.xz [perfbuilder@five ~]$ time dm

   1   164.81 almalinux:8                   : Ok   gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4) , clang version 12.0.1 (Red Hat 12.0.1-4.module_el8.5.0+1025+93159d6c)
   2    90.60 alpine:3.4                    : Ok   gcc (Alpine 5.3.0) 5.3.0 , clang version 3.8.0 (tags/RELEASE_380/final)
   3    55.88 alpine:3.5                    : Ok   gcc (Alpine 6.2.1) 6.2.1 20160822 , clang version 3.8.1 (tags/RELEASE_381/final)
   4    58.69 alpine:3.6                    : Ok   gcc (Alpine 6.3.0) 6.3.0 , clang version 4.0.0 (tags/RELEASE_400/final)
   5    65.65 alpine:3.7                    : Ok   gcc (Alpine 6.4.0) 6.4.0 , Alpine clang version 5.0.0 (tags/RELEASE_500/final) (based on LLVM 5.0.0)
   6    69.85 alpine:3.8                    : Ok   gcc (Alpine 6.4.0) 6.4.0 , Alpine clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
   7    66.83 alpine:3.9                    : Ok   gcc (Alpine 8.3.0) 8.3.0 , Alpine clang version 5.0.1 (tags/RELEASE_502/final) (based on LLVM 5.0.1)
Quoted 4 lines

8: alpine:3.10

I don't expect problems with those, so probably later today I'll push it to perf/core so that it will be on its way t 5.18.

Great, thank you!

Quoted 81 lines

- Arnaldo

Quoted 68 lines
Quoted 68 lines

⬢[acme@toolbox perf]$ b4 am -ctsl --cc-trailers [email protected] Looking up https://lore.kernel.org/r/20220212073054.1052880-1-andrii%40kernel.org
Grabbing thread from lore.kernel.org/all/20220212073054.1052880-1-andrii%40kernel.org/t.mbox.gz Checking for newer revisions on https://lore.kernel.org/all/
Analyzing 3 messages in the thread
Checking attestation on all messages, may take a moment...
---
[PATCH v5 1/2] perf: Stop using deprecated bpf_load_program() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
[PATCH v5 2/2] perf: Stop using deprecated bpf_object__next() API
+ Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
+ Cc: [email protected]
---
Total patches: 2
---
Cover: ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.cover

Base: not specified

       git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx

⬢[acme@toolbox perf]$ git am ./v5_20220211_andrii_perf_stop_using_deprecated_bpf_apis.mbx
Applying: perf: Stop using deprecated bpf_load_program() API
Applying: perf: Stop using deprecated bpf_object__next() API
error: patch failed: tools/perf/util/bpf-loader.c:68
error: tools/perf/util/bpf-loader.c: patch does not apply Patch failed at 0002 perf: Stop using deprecated bpf_object__next() API
hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

- Arnaldo

Quoted 24 lines

v4 -> v5:
- add bpf_perf_object__add() and use it where appropriate (Jiri);
- use __maybe_unused in first patch;
v3 -> v4:
- Fixed commit title
- Added weak definition for deprecated function
v2 -> v3:
- Fixed commit message to use upstream perf
v1 -> v2:
- Added missing commit message
- Added more details to commit message and added steps to reproduce original test case.

Christy Lee (2):
perf: Stop using deprecated bpf_load_program() API
perf: Stop using deprecated bpf_object__next() API

 tools/perf/tests/bpf.c       | 14 ++----
 tools/perf/util/bpf-event.c  | 13 +++++
 tools/perf/util/bpf-loader.c | 98 +++++++++++++++++++++++++++++-------
 3 files changed, 96 insertions(+), 29 deletions(-)

--
2.30.2

Quoted 7 lines
Quoted 3 lines

--

- Arnaldo

--

- Arnaldo

--

- Arnaldo