Skip to content

Commit ea0714d

Browse files
mykyta5Alexei Starovoitov
authored andcommitted
bpf:add _impl suffix for bpf_task_work_schedule* kfuncs
Rename: bpf_task_work_schedule_resume()->bpf_task_work_schedule_resume_impl() bpf_task_work_schedule_signal()->bpf_task_work_schedule_signal_impl() This aligns task work scheduling kfuncs with the established naming scheme for kfuncs with the bpf_prog_aux argument provided by the verifier implicitly. This convention will be taken advantage of with the upcoming KF_IMPLICIT_ARGS feature to preserve backwards compatibility to BPF programs. Acked-by: Andrii Nakryiko <[email protected]> Signed-off-by: Mykyta Yatsenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Ihor Solodrai <[email protected]>
1 parent 156c75f commit ea0714d

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

kernel/bpf/helpers.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,7 +4169,8 @@ static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work
41694169
}
41704170

41714171
/**
4172-
* bpf_task_work_schedule_signal - Schedule BPF callback using task_work_add with TWA_SIGNAL mode
4172+
* bpf_task_work_schedule_signal_impl - Schedule BPF callback using task_work_add with TWA_SIGNAL
4173+
* mode
41734174
* @task: Task struct for which callback should be scheduled
41744175
* @tw: Pointer to struct bpf_task_work in BPF map value for internal bookkeeping
41754176
* @map__map: bpf_map that embeds struct bpf_task_work in the values
@@ -4178,15 +4179,17 @@ static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work
41784179
*
41794180
* Return: 0 if task work has been scheduled successfully, negative error code otherwise
41804181
*/
4181-
__bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct bpf_task_work *tw,
4182-
void *map__map, bpf_task_work_callback_t callback,
4183-
void *aux__prog)
4182+
__bpf_kfunc int bpf_task_work_schedule_signal_impl(struct task_struct *task,
4183+
struct bpf_task_work *tw, void *map__map,
4184+
bpf_task_work_callback_t callback,
4185+
void *aux__prog)
41844186
{
41854187
return bpf_task_work_schedule(task, tw, map__map, callback, aux__prog, TWA_SIGNAL);
41864188
}
41874189

41884190
/**
4189-
* bpf_task_work_schedule_resume - Schedule BPF callback using task_work_add with TWA_RESUME mode
4191+
* bpf_task_work_schedule_resume_impl - Schedule BPF callback using task_work_add with TWA_RESUME
4192+
* mode
41904193
* @task: Task struct for which callback should be scheduled
41914194
* @tw: Pointer to struct bpf_task_work in BPF map value for internal bookkeeping
41924195
* @map__map: bpf_map that embeds struct bpf_task_work in the values
@@ -4195,9 +4198,10 @@ __bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct b
41954198
*
41964199
* Return: 0 if task work has been scheduled successfully, negative error code otherwise
41974200
*/
4198-
__bpf_kfunc int bpf_task_work_schedule_resume(struct task_struct *task, struct bpf_task_work *tw,
4199-
void *map__map, bpf_task_work_callback_t callback,
4200-
void *aux__prog)
4201+
__bpf_kfunc int bpf_task_work_schedule_resume_impl(struct task_struct *task,
4202+
struct bpf_task_work *tw, void *map__map,
4203+
bpf_task_work_callback_t callback,
4204+
void *aux__prog)
42014205
{
42024206
return bpf_task_work_schedule(task, tw, map__map, callback, aux__prog, TWA_RESUME);
42034207
}
@@ -4377,8 +4381,8 @@ BTF_ID_FLAGS(func, bpf_strnstr);
43774381
BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
43784382
#endif
43794383
BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS)
4380-
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal, KF_TRUSTED_ARGS)
4381-
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_TRUSTED_ARGS)
4384+
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal_impl, KF_TRUSTED_ARGS)
4385+
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume_impl, KF_TRUSTED_ARGS)
43824386
BTF_KFUNCS_END(common_btf_ids)
43834387

43844388
static const struct btf_kfunc_id_set common_kfunc_set = {

kernel/bpf/verifier.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12259,8 +12259,8 @@ enum special_kfunc_type {
1225912259
KF_bpf_res_spin_lock_irqsave,
1226012260
KF_bpf_res_spin_unlock_irqrestore,
1226112261
KF___bpf_trap,
12262-
KF_bpf_task_work_schedule_signal,
12263-
KF_bpf_task_work_schedule_resume,
12262+
KF_bpf_task_work_schedule_signal_impl,
12263+
KF_bpf_task_work_schedule_resume_impl,
1226412264
};
1226512265

1226612266
BTF_ID_LIST(special_kfunc_list)
@@ -12331,13 +12331,13 @@ BTF_ID(func, bpf_res_spin_unlock)
1233112331
BTF_ID(func, bpf_res_spin_lock_irqsave)
1233212332
BTF_ID(func, bpf_res_spin_unlock_irqrestore)
1233312333
BTF_ID(func, __bpf_trap)
12334-
BTF_ID(func, bpf_task_work_schedule_signal)
12335-
BTF_ID(func, bpf_task_work_schedule_resume)
12334+
BTF_ID(func, bpf_task_work_schedule_signal_impl)
12335+
BTF_ID(func, bpf_task_work_schedule_resume_impl)
1233612336

1233712337
static bool is_task_work_add_kfunc(u32 func_id)
1233812338
{
12339-
return func_id == special_kfunc_list[KF_bpf_task_work_schedule_signal] ||
12340-
func_id == special_kfunc_list[KF_bpf_task_work_schedule_resume];
12339+
return func_id == special_kfunc_list[KF_bpf_task_work_schedule_signal_impl] ||
12340+
func_id == special_kfunc_list[KF_bpf_task_work_schedule_resume_impl];
1234112341
}
1234212342

1234312343
static bool is_kfunc_ret_null(struct bpf_kfunc_call_arg_meta *meta)

tools/testing/selftests/bpf/progs/task_work.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int oncpu_hash_map(struct pt_regs *args)
6666
if (!work)
6767
return 0;
6868

69-
bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work, NULL);
69+
bpf_task_work_schedule_resume_impl(task, &work->tw, &hmap, process_work, NULL);
7070
return 0;
7171
}
7272

@@ -80,7 +80,7 @@ int oncpu_array_map(struct pt_regs *args)
8080
work = bpf_map_lookup_elem(&arrmap, &key);
8181
if (!work)
8282
return 0;
83-
bpf_task_work_schedule_signal(task, &work->tw, &arrmap, process_work, NULL);
83+
bpf_task_work_schedule_signal_impl(task, &work->tw, &arrmap, process_work, NULL);
8484
return 0;
8585
}
8686

@@ -102,6 +102,6 @@ int oncpu_lru_map(struct pt_regs *args)
102102
work = bpf_map_lookup_elem(&lrumap, &key);
103103
if (!work || work->data[0])
104104
return 0;
105-
bpf_task_work_schedule_resume(task, &work->tw, &lrumap, process_work, NULL);
105+
bpf_task_work_schedule_resume_impl(task, &work->tw, &lrumap, process_work, NULL);
106106
return 0;
107107
}

tools/testing/selftests/bpf/progs/task_work_fail.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int mismatch_map(struct pt_regs *args)
5353
work = bpf_map_lookup_elem(&arrmap, &key);
5454
if (!work)
5555
return 0;
56-
bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work, NULL);
56+
bpf_task_work_schedule_resume_impl(task, &work->tw, &hmap, process_work, NULL);
5757
return 0;
5858
}
5959

@@ -65,7 +65,7 @@ int no_map_task_work(struct pt_regs *args)
6565
struct bpf_task_work tw;
6666

6767
task = bpf_get_current_task_btf();
68-
bpf_task_work_schedule_resume(task, &tw, &hmap, process_work, NULL);
68+
bpf_task_work_schedule_resume_impl(task, &tw, &hmap, process_work, NULL);
6969
return 0;
7070
}
7171

@@ -76,7 +76,7 @@ int task_work_null(struct pt_regs *args)
7676
struct task_struct *task;
7777

7878
task = bpf_get_current_task_btf();
79-
bpf_task_work_schedule_resume(task, NULL, &hmap, process_work, NULL);
79+
bpf_task_work_schedule_resume_impl(task, NULL, &hmap, process_work, NULL);
8080
return 0;
8181
}
8282

@@ -91,6 +91,6 @@ int map_null(struct pt_regs *args)
9191
work = bpf_map_lookup_elem(&arrmap, &key);
9292
if (!work)
9393
return 0;
94-
bpf_task_work_schedule_resume(task, &work->tw, NULL, process_work, NULL);
94+
bpf_task_work_schedule_resume_impl(task, &work->tw, NULL, process_work, NULL);
9595
return 0;
9696
}

tools/testing/selftests/bpf/progs/task_work_stress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ int schedule_task_work(void *ctx)
5151
if (!work)
5252
return 0;
5353
}
54-
err = bpf_task_work_schedule_signal(bpf_get_current_task_btf(), &work->tw, &hmap,
55-
process_work, NULL);
54+
err = bpf_task_work_schedule_signal_impl(bpf_get_current_task_btf(), &work->tw, &hmap,
55+
process_work, NULL);
5656
if (err)
5757
__sync_fetch_and_add(&schedule_error, 1);
5858
else

0 commit comments

Comments
 (0)