David Vernet
2057156738
bpf: Add bpf_user_ringbuf_drain() helper
...
In a prior change, we added a new BPF_MAP_TYPE_USER_RINGBUF map type which
will allow user-space applications to publish messages to a ring buffer
that is consumed by a BPF program in kernel-space. In order for this
map-type to be useful, it will require a BPF helper function that BPF
programs can invoke to drain samples from the ring buffer, and invoke
callbacks on those samples. This change adds that capability via a new BPF
helper function:
bpf_user_ringbuf_drain(struct bpf_map *map, void *callback_fn, void *ctx,
u64 flags)
BPF programs may invoke this function to run callback_fn() on a series of
samples in the ring buffer. callback_fn() has the following signature:
long callback_fn(struct bpf_dynptr *dynptr, void *context);
Samples are provided to the callback in the form of struct bpf_dynptr *'s,
which the program can read using BPF helper functions for querying
struct bpf_dynptr's.
In order to support bpf_ringbuf_drain(), a new PTR_TO_DYNPTR register
type is added to the verifier to reflect a dynptr that was allocated by
a helper function and passed to a BPF program. Unlike PTR_TO_STACK
dynptrs which are allocated on the stack by a BPF program, PTR_TO_DYNPTR
dynptrs need not use reference tracking, as the BPF helper is trusted to
properly free the dynptr before returning. The verifier currently only
supports PTR_TO_DYNPTR registers that are also DYNPTR_TYPE_LOCAL.
Note that while the corresponding user-space libbpf logic will be added
in a subsequent patch, this patch does contain an implementation of the
.map_poll() callback for BPF_MAP_TYPE_USER_RINGBUF maps. This
.map_poll() callback guarantees that an epoll-waiting user-space
producer will receive at least one event notification whenever at least
one sample is drained in an invocation of bpf_user_ringbuf_drain(),
provided that the function is not invoked with the BPF_RB_NO_WAKEUP
flag. If the BPF_RB_FORCE_WAKEUP flag is provided, a wakeup
notification is sent even if no sample was drained.
Signed-off-by: David Vernet <void@manifault.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20220920000100.477320-3-void@manifault.com
2022-09-21 16:24:58 -07:00
..
2022-06-27 16:16:30 +02:00
2021-12-21 15:09:46 -08:00
2022-08-03 16:29:08 -07:00
2021-09-13 14:51:10 -05:00
2021-08-23 09:49:09 -07:00
2022-02-21 19:33:05 +00:00
2021-01-25 18:44:44 +01:00
2022-06-28 21:26:05 +02:00
2022-08-04 12:12:54 -07:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-08-09 19:51:05 +02:00
2021-10-02 15:50:45 -04:00
2022-06-28 21:26:05 +02:00
2022-04-19 13:13:47 +01:00
2021-06-16 17:47:53 +02:00
2022-04-19 12:20:45 +02:00
2022-08-04 11:41:28 -07:00
2022-04-29 14:38:03 -07:00
2021-10-05 16:14:10 +02:00
2022-05-13 10:56:10 +02:00
2021-11-01 13:36:08 +00:00
2022-08-11 10:31:19 -07:00
2022-06-03 20:09:27 +08:00
2021-05-19 11:40:15 +02:00
2021-02-06 09:22:10 +01:00
2021-02-06 09:22:10 +01:00
2021-02-15 18:28:30 +01:00
2021-04-02 11:18:30 -06:00
2022-06-28 21:26:05 +02:00
2022-09-21 16:24:58 -07:00
2022-06-07 10:20:42 -07:00
2022-06-28 21:26:05 +02:00
2022-08-03 14:54:52 -07:00
2022-05-18 00:11:18 +08:00
2021-05-27 09:42:21 +02:00
2021-07-12 15:17:47 -05:00
2021-01-12 17:31:14 +01:00
2022-05-15 18:31:28 -06:00
2021-06-02 14:08:09 +02:00
2022-04-24 07:40:13 +01:00
2020-12-04 12:06:15 +01:00
2021-11-26 16:48:59 +01:00
2022-06-28 21:26:05 +02:00
2020-12-15 12:13:36 -08:00
2022-03-18 14:04:30 +01:00
2022-04-22 16:12:04 -07:00
2022-01-26 14:49:46 +01:00
2022-06-28 21:26:05 +02:00
2022-07-28 21:56:53 -07:00
2021-10-18 12:28:53 -07:00
2022-08-02 19:50:47 -07:00
2022-06-28 21:26:05 +02:00
2022-06-20 18:21:25 +02:00
2021-03-18 17:03:54 +01:00
2022-06-03 20:09:27 +08:00
2022-07-28 18:05:24 +02:00
2022-04-15 11:41:35 -07:00
2022-06-28 21:26:05 +02:00
2022-08-05 04:17:57 -07:00
2022-08-02 19:50:47 -07:00
2022-04-04 08:55:23 +02:00
2021-04-20 08:59:03 -06:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-06-10 16:40:18 +08:00
2022-02-21 19:38:17 +10:30
2021-01-27 15:13:52 +01:00
2022-02-17 09:09:37 +01:00
2021-02-07 14:51:19 -08:00
2021-12-14 11:09:36 +01:00
2021-10-07 13:51:11 +02:00
2022-08-10 13:49:50 +01:00
2021-02-08 13:01:24 +01:00
2022-05-04 11:06:13 +02:00
2022-03-11 08:28:05 -08:00
2022-02-18 13:08:18 +00:00
2021-11-15 07:53:10 -08:00
2021-11-15 07:53:10 -08:00
2021-06-03 15:31:34 -07:00
2021-03-30 13:29:39 -07:00
2022-07-21 18:10:43 +05:30
2022-02-18 21:20:06 -08:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2021-07-29 15:06:50 +01:00
2021-05-07 00:26:34 -07:00
2022-03-17 16:49:57 -07:00
2022-06-27 11:37:55 +01:00
2021-03-10 12:45:16 -08:00
2022-06-24 11:27:59 +01:00
2022-08-18 20:37:35 -07:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-03-11 08:28:27 -08:00
2022-06-28 21:26:05 +02:00
2021-07-21 08:14:33 -07:00
2022-09-03 09:51:10 +01:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-04-17 13:13:53 -07:00
2022-07-17 07:52:46 -07:00
2022-08-23 07:22:33 -06:00
2021-07-21 08:14:33 -07:00
2022-02-04 20:24:45 -08:00
2021-07-21 08:14:33 -07:00
2022-02-28 13:25:48 +01:00
2021-08-18 07:23:15 -06:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2021-10-05 06:54:16 -05:00
2022-05-31 11:36:57 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2020-12-15 12:13:36 -08:00
2022-06-03 20:09:27 +08:00
2022-07-12 16:50:44 -04:00
2022-01-11 15:44:27 -05:00
2021-06-17 14:25:39 -04:00
2022-08-04 14:59:54 -07:00
2021-03-03 16:55:02 -08:00
2022-05-23 13:27:59 +02:00
2022-05-25 09:51:36 -07:00
2022-07-08 10:46:53 -07:00
2022-05-10 06:30:05 -06:00
2021-07-21 08:14:33 -07:00
2022-08-02 12:34:03 -04:00
2021-03-10 09:34:06 +01:00
2021-03-24 08:26:29 +01:00
2021-10-21 23:36:28 +02:00
2022-02-09 12:00:11 +00:00
2022-05-01 17:45:35 +01:00
2022-06-20 21:15:04 +02:00
2022-04-24 08:27:37 +01:00
2021-09-03 09:58:17 -07:00
2022-06-28 21:26:05 +02:00
2022-01-11 18:45:02 -08:00
2021-07-26 14:45:18 +02:00
2022-06-28 20:45:43 -07:00
2022-02-19 16:05:54 +00:00
2021-01-23 12:38:42 -08:00
2021-06-30 15:34:04 -06:00
2022-06-28 21:26:05 +02:00
2022-06-30 13:14:35 +02:00
2022-06-28 21:26:05 +02:00
2021-12-29 12:31:36 -08:00
2021-06-18 13:02:45 -07:00
2021-10-14 23:06:28 +02:00
2022-08-30 12:20:43 +02:00
2021-03-11 16:12:59 -08:00
2021-12-27 14:58:37 +00:00
2021-01-25 09:36:25 -05:00
2022-02-25 18:50:12 -05:00
2022-03-13 12:59:35 -04:00
2021-09-14 11:11:20 +02:00
2021-10-21 17:25:17 +02:00
2022-09-03 17:04:29 +02:00
2022-05-20 06:17:33 -06:00
2022-02-27 10:58:04 -08:00
2021-01-04 11:42:26 -05:00
2022-08-26 19:31:20 -07:00
2022-07-19 15:38:04 -07:00
2021-07-06 10:37:46 -05:00
2022-08-02 19:50:47 -07:00
2021-12-23 09:32:51 +01:00
2021-12-27 17:12:58 +01:00
2022-08-03 16:29:08 -07:00
2021-10-20 15:24:36 -07:00
2020-12-21 17:36:48 -08:00
2022-04-22 18:50:54 +01:00
2021-03-25 15:31:22 -07:00
2022-02-21 16:02:55 +00:00
2022-03-18 09:44:19 -05:00
2022-06-28 21:26:05 +02:00
2022-02-17 09:09:38 +01:00
2021-12-10 17:10:55 -08:00
2022-05-09 14:00:07 +02:00
2021-04-06 10:29:56 +02:00
2022-06-28 21:26:05 +02:00
2021-01-25 15:14:16 -08:00
2022-03-13 11:49:53 -05:00
2022-02-02 13:11:34 +01:00
2022-03-23 19:58:40 +01:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-05-03 14:11:58 -07:00
2022-08-03 16:29:08 -07:00
2021-06-18 11:35:47 -07:00
2022-06-28 21:26:05 +02:00
2022-07-16 08:16:01 +02:00
2022-06-27 14:41:31 +02:00
2022-06-27 14:44:20 +02:00
2022-04-07 16:47:12 +02:00
2021-05-18 16:20:54 -05:00
2022-02-02 07:42:41 -08:00
2022-07-18 11:19:17 +01:00
2022-07-11 19:48:33 -07:00
2022-06-01 16:48:05 -07:00
2022-01-08 17:41:00 +09:00
2020-12-03 10:03:14 -08:00
2022-03-31 13:04:44 -07:00
2022-06-28 21:26:05 +02:00
2022-06-16 19:58:21 -07:00
2022-06-30 13:14:35 +02:00
2022-06-28 21:26:05 +02:00
2022-06-01 15:55:25 -07:00
2021-02-11 18:25:05 -08:00
2022-04-26 10:17:03 +02:00
2021-01-07 16:17:32 +01:00
2022-02-03 19:50:49 +01:00
2022-04-06 13:48:02 +01:00
2022-07-06 12:56:35 +01:00
2021-04-10 10:36:34 +02:00
2022-06-27 16:25:41 +02:00
2022-05-25 10:08:59 -07:00
2022-08-02 21:13:40 -06:00
2022-06-28 21:26:05 +02:00
2022-05-13 07:20:11 -07:00
2022-01-20 08:52:54 +02:00
2021-03-22 10:24:07 +01:00
2022-07-15 17:36:58 +01:00
2021-03-22 10:22:22 +01:00
2022-05-31 12:44:20 -04:00
2022-08-11 04:26:08 -04:00
2022-07-11 09:54:37 +02:00
2022-05-16 12:39:43 -06:00
2022-08-12 09:50:34 -07:00
2022-08-11 04:31:15 -04:00
2022-07-17 10:58:06 +01:00
2022-06-28 21:26:05 +02:00
2021-04-08 12:26:34 +02:00
2022-08-11 04:06:40 -04:00
2022-03-28 16:52:58 -04:00
2021-11-04 16:36:54 +01:00
2021-09-29 09:22:29 +02:00
2021-11-01 05:26:48 -04:00
2022-05-10 07:22:28 -04:00
2021-12-06 15:03:05 +01:00
2021-11-10 15:32:38 +01:00
2022-08-30 22:44:25 -07:00
2022-08-11 04:06:40 -04:00
2021-08-26 22:28:03 +02:00
2022-08-16 01:40:24 -04:00
2021-08-05 10:24:08 +01:00
2021-03-07 09:07:16 +01:00
2021-09-05 16:23:09 -04:00
2021-10-08 16:21:53 +01:00
2021-06-12 13:16:45 -07:00
2022-08-24 12:51:50 +01:00