* [PATCH bpf-next 0/2] deprecate bpf_object__open_buffer() API
@ 2022-01-25 0:59 Christy Lee
2022-01-25 0:59 ` [PATCH bpf-next 1/2] libbpf: mark bpf_object__open_buffer() API deprecated Christy Lee
2022-01-25 0:59 ` [PATCH bpf-next 2/2] perf: stop using bpf_object__open_buffer() API Christy Lee
0 siblings, 2 replies; 4+ messages in thread
From: Christy Lee @ 2022-01-25 0:59 UTC (permalink / raw)
To: andrii, arnaldo.melo, christyc.y.lee
Cc: bpf, linux-perf-users, kernel-team, Christy Lee
Deprecate bpf_object__open_buffer() API, replace all usage
with bpf_object__open_mem().
[0] closes: https://github.com/libbpf/libbpf/issues/287
Christy Lee (2):
libbpf: mark bpf_object__open_buffer() API deprecated
perf: stop using bpf_object__open_buffer() API
tools/lib/bpf/libbpf.h | 1 +
tools/perf/tests/llvm.c | 2 +-
tools/perf/util/bpf-event.c | 10 ++++++++++
tools/perf/util/bpf-loader.c | 10 ++++++++--
4 files changed, 20 insertions(+), 3 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH bpf-next 1/2] libbpf: mark bpf_object__open_buffer() API deprecated
2022-01-25 0:59 [PATCH bpf-next 0/2] deprecate bpf_object__open_buffer() API Christy Lee
@ 2022-01-25 0:59 ` Christy Lee
2022-01-25 0:59 ` [PATCH bpf-next 2/2] perf: stop using bpf_object__open_buffer() API Christy Lee
1 sibling, 0 replies; 4+ messages in thread
From: Christy Lee @ 2022-01-25 0:59 UTC (permalink / raw)
To: andrii, arnaldo.melo, christyc.y.lee
Cc: bpf, linux-perf-users, kernel-team, Christy Lee
Deprecate bpf_object__open_buffer() API in favor of the unified
opts bpf_object__open_mem() API.
Signed-off-by: Christy Lee <christylee@fb.com>
---
tools/lib/bpf/libbpf.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 94670066de62..281cb19591e5 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -180,6 +180,7 @@ bpf_object__open_mem(const void *obj_buf, size_t obj_buf_sz,
const struct bpf_object_open_opts *opts);
/* deprecated bpf_object__open variants */
+LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_object__open_mem() instead")
LIBBPF_API struct bpf_object *
bpf_object__open_buffer(const void *obj_buf, size_t obj_buf_sz,
const char *name);
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH bpf-next 2/2] perf: stop using bpf_object__open_buffer() API
2022-01-25 0:59 [PATCH bpf-next 0/2] deprecate bpf_object__open_buffer() API Christy Lee
2022-01-25 0:59 ` [PATCH bpf-next 1/2] libbpf: mark bpf_object__open_buffer() API deprecated Christy Lee
@ 2022-01-25 0:59 ` Christy Lee
2022-01-25 4:48 ` Andrii Nakryiko
1 sibling, 1 reply; 4+ messages in thread
From: Christy Lee @ 2022-01-25 0:59 UTC (permalink / raw)
To: andrii, arnaldo.melo, christyc.y.lee
Cc: bpf, linux-perf-users, kernel-team, Christy Lee
bpf_object__open_buffer() API is deprecated, use the unified opts
bpf_object__open_mem() API in perf instead. This requires at least
libbpf 6.0.
Signed-off-by: Christy Lee <christylee@fb.com>
---
tools/perf/tests/llvm.c | 2 +-
tools/perf/util/bpf-event.c | 10 ++++++++++
tools/perf/util/bpf-loader.c | 10 ++++++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 8ac0a3a457ef..0bc25a56cfef 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -13,7 +13,7 @@ static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
{
struct bpf_object *obj;
- obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, NULL);
+ obj = bpf_object__open_mem(obj_buf, obj_buf_sz, NULL);
if (libbpf_get_error(obj))
return TEST_FAIL;
bpf_object__close(obj);
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index a517eaa51eb3..fd5469bf4ac2 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -51,6 +51,16 @@ bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev)
#pragma GCC diagnostic pop
}
+struct bpf_object * __weak
+bpf_object__open_mem(const void *obj_buf, size_t obj_buf_sz,
+ const struct bpf_object_open_opts *opts)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ return bpf_object__open_buffer(obj_buf, obj_buf_sz, opts->object_name);
+#pragma GCC diagnostic pop
+}
+
const void * __weak
btf__raw_data(const struct btf *btf_ro, __u32 *size)
{
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 4631cac3957f..e92b17ad9d89 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -54,6 +54,9 @@ static bool libbpf_initialized;
struct bpf_object *
bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
{
+ DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts,
+ .object_name = name
+ );
struct bpf_object *obj;
if (!libbpf_initialized) {
@@ -61,7 +64,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
libbpf_initialized = true;
}
- obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, name);
+ obj = bpf_object__open_mem(obj_buf, obj_buf_sz, &opts);
if (IS_ERR_OR_NULL(obj)) {
pr_debug("bpf: failed to load buffer\n");
return ERR_PTR(-EINVAL);
@@ -72,6 +75,9 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
struct bpf_object *bpf__prepare_load(const char *filename, bool source)
{
+ DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts,
+ .object_name = filename
+ );
struct bpf_object *obj;
if (!libbpf_initialized) {
@@ -94,7 +100,7 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
return ERR_PTR(-BPF_LOADER_ERRNO__COMPILE);
} else
pr_debug("bpf: successful builtin compilation\n");
- obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, filename);
+ obj = bpf_object__open_mem(obj_buf, obj_buf_sz, &opts);
if (!IS_ERR_OR_NULL(obj) && llvm_param.dump_obj)
llvm__dump_obj(filename, obj_buf, obj_buf_sz);
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next 2/2] perf: stop using bpf_object__open_buffer() API
2022-01-25 0:59 ` [PATCH bpf-next 2/2] perf: stop using bpf_object__open_buffer() API Christy Lee
@ 2022-01-25 4:48 ` Andrii Nakryiko
0 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2022-01-25 4:48 UTC (permalink / raw)
To: Christy Lee
Cc: Andrii Nakryiko, Arnaldo Carvalho de Melo, Christy Lee, bpf,
linux-perf-use., Kernel Team
On Mon, Jan 24, 2022 at 4:59 PM Christy Lee <christylee@fb.com> wrote:
>
> bpf_object__open_buffer() API is deprecated, use the unified opts
> bpf_object__open_mem() API in perf instead. This requires at least
> libbpf 6.0.
Not 6.0, but 0.0.6 (not even v0.6). So it's a very old API. I removed
the __weak stub because it should be there anyways.
Fixed up commit message and applied the series to bpf-next, thanks.
>
> Signed-off-by: Christy Lee <christylee@fb.com>
> ---
> tools/perf/tests/llvm.c | 2 +-
> tools/perf/util/bpf-event.c | 10 ++++++++++
> tools/perf/util/bpf-loader.c | 10 ++++++++--
> 3 files changed, 19 insertions(+), 3 deletions(-)
>
[...]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-25 6:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-25 0:59 [PATCH bpf-next 0/2] deprecate bpf_object__open_buffer() API Christy Lee
2022-01-25 0:59 ` [PATCH bpf-next 1/2] libbpf: mark bpf_object__open_buffer() API deprecated Christy Lee
2022-01-25 0:59 ` [PATCH bpf-next 2/2] perf: stop using bpf_object__open_buffer() API Christy Lee
2022-01-25 4:48 ` Andrii Nakryiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).