|
18 | 18 | #include <linux/in6.h> |
19 | 19 | #include <linux/un.h> |
20 | 20 | #include <linux/filter.h> |
| 21 | +#include <linux/rcupdate_trace.h> |
21 | 22 | #include <net/sock.h> |
22 | 23 | #include <linux/namei.h> |
23 | 24 | #include "bpf_testmod.h" |
@@ -885,6 +886,32 @@ __bpf_kfunc void bpf_kfunc_call_test_sleepable(void) |
885 | 886 | { |
886 | 887 | } |
887 | 888 |
|
| 889 | +struct bpf_kfunc_rcu_tasks_trace_data { |
| 890 | + struct rcu_head rcu; |
| 891 | + int *done; |
| 892 | +}; |
| 893 | + |
| 894 | +static void bpf_kfunc_rcu_tasks_trace_cb(struct rcu_head *rhp) |
| 895 | +{ |
| 896 | + struct bpf_kfunc_rcu_tasks_trace_data *data; |
| 897 | + |
| 898 | + data = container_of(rhp, struct bpf_kfunc_rcu_tasks_trace_data, rcu); |
| 899 | + WRITE_ONCE(*data->done, 1); |
| 900 | + kfree(data); |
| 901 | +} |
| 902 | + |
| 903 | +__bpf_kfunc int bpf_kfunc_call_test_call_rcu_tasks_trace(int *done) |
| 904 | +{ |
| 905 | + struct bpf_kfunc_rcu_tasks_trace_data *data; |
| 906 | + |
| 907 | + data = kmalloc(sizeof(*data), GFP_ATOMIC); |
| 908 | + if (!data) |
| 909 | + return -ENOMEM; |
| 910 | + data->done = done; |
| 911 | + call_rcu_tasks_trace(&data->rcu, bpf_kfunc_rcu_tasks_trace_cb); |
| 912 | + return 0; |
| 913 | +} |
| 914 | + |
888 | 915 | __bpf_kfunc int bpf_kfunc_init_sock(struct init_sock_args *args) |
889 | 916 | { |
890 | 917 | int proto; |
@@ -1222,6 +1249,7 @@ BTF_ID_FLAGS(func, bpf_kfunc_call_test_destructive, KF_DESTRUCTIVE) |
1222 | 1249 | BTF_ID_FLAGS(func, bpf_kfunc_call_test_static_unused_arg) |
1223 | 1250 | BTF_ID_FLAGS(func, bpf_kfunc_call_test_offset) |
1224 | 1251 | BTF_ID_FLAGS(func, bpf_kfunc_call_test_sleepable, KF_SLEEPABLE) |
| 1252 | +BTF_ID_FLAGS(func, bpf_kfunc_call_test_call_rcu_tasks_trace) |
1225 | 1253 | BTF_ID_FLAGS(func, bpf_kfunc_init_sock, KF_SLEEPABLE) |
1226 | 1254 | BTF_ID_FLAGS(func, bpf_kfunc_close_sock, KF_SLEEPABLE) |
1227 | 1255 | BTF_ID_FLAGS(func, bpf_kfunc_call_kernel_connect, KF_SLEEPABLE) |
|
0 commit comments