Commit 22dd7a58 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

libbpf: clean up perfbuf APIs

Remove deprecated perfbuf APIs and clean up opts structs.
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20220627211527.2245459-7-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent aaf6886d
...@@ -11975,6 +11975,9 @@ struct bpf_link *bpf_map__attach_struct_ops(const struct bpf_map *map) ...@@ -11975,6 +11975,9 @@ struct bpf_link *bpf_map__attach_struct_ops(const struct bpf_map *map)
return link; return link;
} }
typedef enum bpf_perf_event_ret (*bpf_perf_event_print_t)(struct perf_event_header *hdr,
void *private_data);
static enum bpf_perf_event_ret static enum bpf_perf_event_ret
perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size, perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size,
void **copy_mem, size_t *copy_size, void **copy_mem, size_t *copy_size,
...@@ -12023,12 +12026,6 @@ perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size, ...@@ -12023,12 +12026,6 @@ perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size,
return libbpf_err(ret); return libbpf_err(ret);
} }
__attribute__((alias("perf_event_read_simple")))
enum bpf_perf_event_ret
bpf_perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size,
void **copy_mem, size_t *copy_size,
bpf_perf_event_print_t fn, void *private_data);
struct perf_buffer; struct perf_buffer;
struct perf_buffer_params { struct perf_buffer_params {
...@@ -12162,12 +12159,11 @@ perf_buffer__open_cpu_buf(struct perf_buffer *pb, struct perf_event_attr *attr, ...@@ -12162,12 +12159,11 @@ perf_buffer__open_cpu_buf(struct perf_buffer *pb, struct perf_event_attr *attr,
static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt, static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt,
struct perf_buffer_params *p); struct perf_buffer_params *p);
DEFAULT_VERSION(perf_buffer__new_v0_6_0, perf_buffer__new, LIBBPF_0.6.0) struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
struct perf_buffer *perf_buffer__new_v0_6_0(int map_fd, size_t page_cnt, perf_buffer_sample_fn sample_cb,
perf_buffer_sample_fn sample_cb, perf_buffer_lost_fn lost_cb,
perf_buffer_lost_fn lost_cb, void *ctx,
void *ctx, const struct perf_buffer_opts *opts)
const struct perf_buffer_opts *opts)
{ {
struct perf_buffer_params p = {}; struct perf_buffer_params p = {};
struct perf_event_attr attr = {}; struct perf_event_attr attr = {};
...@@ -12189,22 +12185,10 @@ struct perf_buffer *perf_buffer__new_v0_6_0(int map_fd, size_t page_cnt, ...@@ -12189,22 +12185,10 @@ struct perf_buffer *perf_buffer__new_v0_6_0(int map_fd, size_t page_cnt,
return libbpf_ptr(__perf_buffer__new(map_fd, page_cnt, &p)); return libbpf_ptr(__perf_buffer__new(map_fd, page_cnt, &p));
} }
COMPAT_VERSION(perf_buffer__new_deprecated, perf_buffer__new, LIBBPF_0.0.4) struct perf_buffer *perf_buffer__new_raw(int map_fd, size_t page_cnt,
struct perf_buffer *perf_buffer__new_deprecated(int map_fd, size_t page_cnt, struct perf_event_attr *attr,
const struct perf_buffer_opts *opts) perf_buffer_event_fn event_cb, void *ctx,
{ const struct perf_buffer_raw_opts *opts)
return perf_buffer__new_v0_6_0(map_fd, page_cnt,
opts ? opts->sample_cb : NULL,
opts ? opts->lost_cb : NULL,
opts ? opts->ctx : NULL,
NULL);
}
DEFAULT_VERSION(perf_buffer__new_raw_v0_6_0, perf_buffer__new_raw, LIBBPF_0.6.0)
struct perf_buffer *perf_buffer__new_raw_v0_6_0(int map_fd, size_t page_cnt,
struct perf_event_attr *attr,
perf_buffer_event_fn event_cb, void *ctx,
const struct perf_buffer_raw_opts *opts)
{ {
struct perf_buffer_params p = {}; struct perf_buffer_params p = {};
...@@ -12224,20 +12208,6 @@ struct perf_buffer *perf_buffer__new_raw_v0_6_0(int map_fd, size_t page_cnt, ...@@ -12224,20 +12208,6 @@ struct perf_buffer *perf_buffer__new_raw_v0_6_0(int map_fd, size_t page_cnt,
return libbpf_ptr(__perf_buffer__new(map_fd, page_cnt, &p)); return libbpf_ptr(__perf_buffer__new(map_fd, page_cnt, &p));
} }
COMPAT_VERSION(perf_buffer__new_raw_deprecated, perf_buffer__new_raw, LIBBPF_0.0.4)
struct perf_buffer *perf_buffer__new_raw_deprecated(int map_fd, size_t page_cnt,
const struct perf_buffer_raw_opts *opts)
{
LIBBPF_OPTS(perf_buffer_raw_opts, inner_opts,
.cpu_cnt = opts->cpu_cnt,
.cpus = opts->cpus,
.map_keys = opts->map_keys,
);
return perf_buffer__new_raw_v0_6_0(map_fd, page_cnt, opts->attr,
opts->event_cb, opts->ctx, &inner_opts);
}
static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt, static struct perf_buffer *__perf_buffer__new(int map_fd, size_t page_cnt,
struct perf_buffer_params *p) struct perf_buffer_params *p)
{ {
......
...@@ -1269,17 +1269,7 @@ typedef void (*perf_buffer_lost_fn)(void *ctx, int cpu, __u64 cnt); ...@@ -1269,17 +1269,7 @@ typedef void (*perf_buffer_lost_fn)(void *ctx, int cpu, __u64 cnt);
/* common use perf buffer options */ /* common use perf buffer options */
struct perf_buffer_opts { struct perf_buffer_opts {
union { size_t sz;
size_t sz;
struct { /* DEPRECATED: will be removed in v1.0 */
/* if specified, sample_cb is called for each sample */
perf_buffer_sample_fn sample_cb;
/* if specified, lost_cb is called for each batch of lost samples */
perf_buffer_lost_fn lost_cb;
/* ctx is provided to sample_cb and lost_cb */
void *ctx;
};
};
}; };
#define perf_buffer_opts__last_field sz #define perf_buffer_opts__last_field sz
...@@ -1300,21 +1290,6 @@ perf_buffer__new(int map_fd, size_t page_cnt, ...@@ -1300,21 +1290,6 @@ perf_buffer__new(int map_fd, size_t page_cnt,
perf_buffer_sample_fn sample_cb, perf_buffer_lost_fn lost_cb, void *ctx, perf_buffer_sample_fn sample_cb, perf_buffer_lost_fn lost_cb, void *ctx,
const struct perf_buffer_opts *opts); const struct perf_buffer_opts *opts);
LIBBPF_API struct perf_buffer *
perf_buffer__new_v0_6_0(int map_fd, size_t page_cnt,
perf_buffer_sample_fn sample_cb, perf_buffer_lost_fn lost_cb, void *ctx,
const struct perf_buffer_opts *opts);
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "use new variant of perf_buffer__new() instead")
struct perf_buffer *perf_buffer__new_deprecated(int map_fd, size_t page_cnt,
const struct perf_buffer_opts *opts);
#define perf_buffer__new(...) ___libbpf_overload(___perf_buffer_new, __VA_ARGS__)
#define ___perf_buffer_new6(map_fd, page_cnt, sample_cb, lost_cb, ctx, opts) \
perf_buffer__new(map_fd, page_cnt, sample_cb, lost_cb, ctx, opts)
#define ___perf_buffer_new3(map_fd, page_cnt, opts) \
perf_buffer__new_deprecated(map_fd, page_cnt, opts)
enum bpf_perf_event_ret { enum bpf_perf_event_ret {
LIBBPF_PERF_EVENT_DONE = 0, LIBBPF_PERF_EVENT_DONE = 0,
LIBBPF_PERF_EVENT_ERROR = -1, LIBBPF_PERF_EVENT_ERROR = -1,
...@@ -1328,21 +1303,9 @@ typedef enum bpf_perf_event_ret ...@@ -1328,21 +1303,9 @@ typedef enum bpf_perf_event_ret
/* raw perf buffer options, giving most power and control */ /* raw perf buffer options, giving most power and control */
struct perf_buffer_raw_opts { struct perf_buffer_raw_opts {
union { size_t sz;
struct { long :0;
size_t sz; long :0;
long :0;
long :0;
};
struct { /* DEPRECATED: will be removed in v1.0 */
/* perf event attrs passed directly into perf_event_open() */
struct perf_event_attr *attr;
/* raw event callback */
perf_buffer_event_fn event_cb;
/* ctx is provided to event_cb */
void *ctx;
};
};
/* if cpu_cnt == 0, open all on all possible CPUs (up to the number of /* if cpu_cnt == 0, open all on all possible CPUs (up to the number of
* max_entries of given PERF_EVENT_ARRAY map) * max_entries of given PERF_EVENT_ARRAY map)
*/ */
...@@ -1354,26 +1317,13 @@ struct perf_buffer_raw_opts { ...@@ -1354,26 +1317,13 @@ struct perf_buffer_raw_opts {
}; };
#define perf_buffer_raw_opts__last_field map_keys #define perf_buffer_raw_opts__last_field map_keys
struct perf_event_attr;
LIBBPF_API struct perf_buffer * LIBBPF_API struct perf_buffer *
perf_buffer__new_raw(int map_fd, size_t page_cnt, struct perf_event_attr *attr, perf_buffer__new_raw(int map_fd, size_t page_cnt, struct perf_event_attr *attr,
perf_buffer_event_fn event_cb, void *ctx, perf_buffer_event_fn event_cb, void *ctx,
const struct perf_buffer_raw_opts *opts); const struct perf_buffer_raw_opts *opts);
LIBBPF_API struct perf_buffer *
perf_buffer__new_raw_v0_6_0(int map_fd, size_t page_cnt, struct perf_event_attr *attr,
perf_buffer_event_fn event_cb, void *ctx,
const struct perf_buffer_raw_opts *opts);
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "use new variant of perf_buffer__new_raw() instead")
struct perf_buffer *perf_buffer__new_raw_deprecated(int map_fd, size_t page_cnt,
const struct perf_buffer_raw_opts *opts);
#define perf_buffer__new_raw(...) ___libbpf_overload(___perf_buffer_new_raw, __VA_ARGS__)
#define ___perf_buffer_new_raw6(map_fd, page_cnt, attr, event_cb, ctx, opts) \
perf_buffer__new_raw(map_fd, page_cnt, attr, event_cb, ctx, opts)
#define ___perf_buffer_new_raw3(map_fd, page_cnt, opts) \
perf_buffer__new_raw_deprecated(map_fd, page_cnt, opts)
LIBBPF_API void perf_buffer__free(struct perf_buffer *pb); LIBBPF_API void perf_buffer__free(struct perf_buffer *pb);
LIBBPF_API int perf_buffer__epoll_fd(const struct perf_buffer *pb); LIBBPF_API int perf_buffer__epoll_fd(const struct perf_buffer *pb);
LIBBPF_API int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms); LIBBPF_API int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms);
...@@ -1382,15 +1332,6 @@ LIBBPF_API int perf_buffer__consume_buffer(struct perf_buffer *pb, size_t buf_id ...@@ -1382,15 +1332,6 @@ LIBBPF_API int perf_buffer__consume_buffer(struct perf_buffer *pb, size_t buf_id
LIBBPF_API size_t perf_buffer__buffer_cnt(const struct perf_buffer *pb); LIBBPF_API size_t perf_buffer__buffer_cnt(const struct perf_buffer *pb);
LIBBPF_API int perf_buffer__buffer_fd(const struct perf_buffer *pb, size_t buf_idx); LIBBPF_API int perf_buffer__buffer_fd(const struct perf_buffer *pb, size_t buf_idx);
typedef enum bpf_perf_event_ret
(*bpf_perf_event_print_t)(struct perf_event_header *hdr,
void *private_data);
LIBBPF_DEPRECATED_SINCE(0, 8, "use perf_buffer__poll() or perf_buffer__consume() instead")
LIBBPF_API enum bpf_perf_event_ret
bpf_perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size,
void **copy_mem, size_t *copy_size,
bpf_perf_event_print_t fn, void *private_data);
struct bpf_prog_linfo; struct bpf_prog_linfo;
struct bpf_prog_info; struct bpf_prog_info;
......
...@@ -46,7 +46,6 @@ LIBBPF_0.0.1 { ...@@ -46,7 +46,6 @@ LIBBPF_0.0.1 {
bpf_object__unload; bpf_object__unload;
bpf_object__unpin_maps; bpf_object__unpin_maps;
bpf_object__unpin_programs; bpf_object__unpin_programs;
bpf_perf_event_read_simple;
bpf_prog_attach; bpf_prog_attach;
bpf_prog_detach; bpf_prog_detach;
bpf_prog_detach2; bpf_prog_detach2;
...@@ -144,8 +143,6 @@ LIBBPF_0.0.4 { ...@@ -144,8 +143,6 @@ LIBBPF_0.0.4 {
btf__parse_elf; btf__parse_elf;
libbpf_num_possible_cpus; libbpf_num_possible_cpus;
perf_buffer__free; perf_buffer__free;
perf_buffer__new;
perf_buffer__new_raw;
perf_buffer__poll; perf_buffer__poll;
} LIBBPF_0.0.3; } LIBBPF_0.0.3;
...@@ -369,9 +366,7 @@ LIBBPF_0.6.0 { ...@@ -369,9 +366,7 @@ LIBBPF_0.6.0 {
libbpf_minor_version; libbpf_minor_version;
libbpf_version_string; libbpf_version_string;
perf_buffer__new; perf_buffer__new;
perf_buffer__new_deprecated;
perf_buffer__new_raw; perf_buffer__new_raw;
perf_buffer__new_raw_deprecated;
} LIBBPF_0.5.0; } LIBBPF_0.5.0;
LIBBPF_0.7.0 { LIBBPF_0.7.0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment