Joanne Koong
e6f2dd0f80
bpf: Add bpf_loop helper
...
This patch adds the kernel-side and API changes for a new helper
function, bpf_loop:
long bpf_loop(u32 nr_loops, void *callback_fn, void *callback_ctx,
u64 flags);
where long (*callback_fn)(u32 index, void *ctx);
bpf_loop invokes the "callback_fn" **nr_loops** times or until the
callback_fn returns 1. The callback_fn can only return 0 or 1, and
this is enforced by the verifier. The callback_fn index is zero-indexed.
A few things to please note:
~ The "u64 flags" parameter is currently unused but is included in
case a future use case for it arises.
~ In the kernel-side implementation of bpf_loop (kernel/bpf/bpf_iter.c),
bpf_callback_t is used as the callback function cast.
~ A program can have nested bpf_loop calls but the program must
still adhere to the verifier constraint of its stack depth (the stack depth
cannot exceed MAX_BPF_STACK))
~ Recursive callback_fns do not pass the verifier, due to the call stack
for these being too deep.
~ The next patch will include the tests and benchmark
Signed-off-by: Joanne Koong <joannekoong@fb.com >
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
Acked-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20211130030622.4131246-2-joannekoong@fb.com
2021-11-30 10:56:28 -08:00
..
2021-10-29 13:11:53 -07:00
2021-10-27 11:07:59 +02:00
2021-11-03 14:22:00 +00:00
2021-11-08 11:55:21 -08:00
2021-10-27 00:16:00 +02:00
2021-11-02 16:36:28 -07:00
2021-11-08 12:07:52 -08:00
2021-11-01 14:49:20 -03:00
2021-11-01 18:55:12 -07:00
2021-11-10 11:36:43 -08:00
2021-11-10 16:15:54 -08:00
2021-11-03 21:18:44 -07:00
2021-11-12 11:53:16 -08:00
2021-11-10 16:45:54 -08:00
2021-11-05 08:41:02 +01:00
2021-11-10 11:52:40 -08:00
2021-10-29 22:34:31 -05:00
2021-10-26 21:01:48 -06:00
2021-11-01 21:17:39 -07:00
2021-11-06 13:30:34 -07:00
2021-11-06 14:08:17 -07:00
2021-10-27 06:54:58 -06:00
2021-10-26 19:30:38 -07:00
2021-11-09 11:20:07 -08:00
2021-11-01 10:25:27 -07:00
2021-11-09 10:02:49 -08:00
2021-11-01 19:59:46 -07:00
2021-11-02 15:37:27 -07:00
2021-11-30 10:56:28 -08:00
2021-11-12 10:19:09 -08:00
2021-11-06 13:30:39 -07:00
2021-11-07 10:38:17 -08:00
2021-11-07 10:38:17 -08:00
2021-11-06 14:08:17 -07:00
2021-11-09 10:02:49 -08:00
2021-11-02 19:31:28 +01:00
2021-11-02 19:31:28 +01:00
2021-11-06 13:30:38 -07:00
2021-11-09 10:02:52 -08:00
2021-11-06 13:30:46 -07:00
2021-11-09 10:02:49 -08:00
2021-11-03 08:05:59 -07:00
2021-11-05 13:50:15 +10:00
2021-11-03 11:20:45 +00:00
2021-10-27 12:53:45 +02:00
2021-11-10 16:29:58 -08:00
2021-11-01 13:44:26 -05:00
2021-11-11 09:49:36 -08:00
2021-11-03 17:44:29 +09:00
2021-10-27 12:35:05 +02:00
2021-10-27 12:34:49 +02:00
2021-11-09 10:02:49 -08:00
2021-11-09 10:02:49 -08:00
2021-11-09 11:16:20 -08:00
2021-11-06 14:08:17 -07:00
2021-11-06 14:08:17 -07:00
2021-11-09 10:02:48 -08:00
2021-10-28 11:26:40 +00:00
2021-11-15 07:53:10 -08:00
2021-11-02 06:20:58 -07:00
2021-11-01 19:57:14 -07:00
2021-11-09 10:02:49 -08:00
2021-11-06 13:30:36 -07:00
2021-11-02 12:25:03 -07:00
2021-11-01 19:57:14 -07:00
2021-10-28 13:34:57 +01:00
2021-10-28 21:11:34 +01:00
2021-11-06 14:36:12 -07:00
2021-11-09 10:02:51 -08:00
2021-11-06 14:08:17 -07:00
2021-11-09 10:11:53 -08:00
2021-11-06 13:30:43 -07:00
2021-11-12 08:05:17 +09:00
2021-11-09 10:02:49 -08:00
2021-11-09 10:02:49 -08:00
2021-10-30 16:37:28 +02:00
2021-11-03 11:09:20 +00:00
2021-11-03 11:09:20 +00:00
2021-11-10 11:29:30 -08:00
2021-11-06 14:08:17 -07:00
2021-11-06 13:30:42 -07:00
2021-11-06 13:30:42 -07:00
2021-11-06 13:30:41 -07:00
2021-11-06 13:30:41 -07:00
2021-11-11 09:34:35 -08:00
2021-11-06 14:08:17 -07:00
2021-11-06 14:08:17 -07:00
2021-11-06 13:30:40 -07:00
2021-11-02 12:31:23 -04:00
2021-11-05 14:54:40 -04:00
2021-11-05 14:54:39 -04:00
2021-11-06 13:30:42 -07:00
2021-10-27 08:03:19 +02:00
2021-11-11 09:34:35 -08:00
2021-11-06 14:08:17 -07:00
2021-11-09 10:11:53 -08:00
2021-11-11 15:10:18 -08:00
2021-11-06 13:30:34 -07:00
2021-11-02 06:20:58 -07:00
2021-11-15 14:31:00 +00:00
2021-11-09 10:02:49 -08:00
2021-10-27 20:49:32 +02:00
2021-11-01 20:05:19 -07:00
2021-11-05 11:51:41 +01:00
2021-11-09 10:02:49 -08:00
2021-11-10 09:05:11 -08:00
2021-10-30 16:37:28 +02:00
2021-10-30 16:37:28 +02:00
2021-11-09 10:02:49 -08:00
2021-11-09 10:11:53 -08:00
2021-11-03 12:15:29 -07:00
2021-11-03 11:09:20 +00:00
2021-11-09 10:02:52 -08:00
2021-11-03 14:09:26 -05:00
2021-11-09 10:11:53 -08:00
2021-11-03 11:19:49 +00:00
2021-11-09 00:56:35 +01:00
2021-11-06 13:30:43 -07:00
2021-11-06 13:30:32 -07:00
2021-11-09 10:02:49 -08:00
2021-10-30 16:37:28 +02:00
2021-10-30 16:37:28 +02:00
2021-11-09 10:11:53 -08:00
2021-11-09 10:02:50 -08:00
2021-11-06 13:30:43 -07:00
2021-11-09 10:02:50 -08:00
2021-11-03 11:41:25 -07:00
2021-11-06 14:08:17 -07:00
2021-10-27 12:27:17 -04:00
2021-11-01 20:05:19 -07:00
2021-10-30 11:02:00 +02:00
2021-11-01 05:26:49 -04:00
2021-11-01 05:26:48 -04:00
2021-11-01 04:30:34 -04:00
2021-11-01 05:26:48 -04:00
2021-11-06 13:30:36 -07:00
2021-11-01 09:19:50 -07:00