Skip to content

Commit 6159ce4

Browse files
tklauserkernel-patches-bot
authored andcommitted
bpf: simplify cases in bpf_base_func_proto
!perfmon_capable() is checked before the last switch(func_id) in bpf_base_func_proto. Thus, the cases BPF_FUNC_trace_printk and BPF_FUNC_snprintf_btf can be moved to that last switch(func_id) to omit the inline !perfmon_capable() checks. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
1 parent 9e22e93 commit 6159ce4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

kernel/bpf/helpers.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,6 @@ bpf_base_func_proto(enum bpf_func_id func_id)
720720
return &bpf_spin_lock_proto;
721721
case BPF_FUNC_spin_unlock:
722722
return &bpf_spin_unlock_proto;
723-
case BPF_FUNC_trace_printk:
724-
if (!perfmon_capable())
725-
return NULL;
726-
return bpf_get_trace_printk_proto();
727-
case BPF_FUNC_snprintf_btf:
728-
if (!perfmon_capable())
729-
return NULL;
730-
return &bpf_snprintf_btf_proto;
731723
case BPF_FUNC_jiffies64:
732724
return &bpf_jiffies64_proto;
733725
case BPF_FUNC_per_cpu_ptr:
@@ -742,6 +734,8 @@ bpf_base_func_proto(enum bpf_func_id func_id)
742734
return NULL;
743735

744736
switch (func_id) {
737+
case BPF_FUNC_trace_printk:
738+
return bpf_get_trace_printk_proto();
745739
case BPF_FUNC_get_current_task:
746740
return &bpf_get_current_task_proto;
747741
case BPF_FUNC_probe_read_user:
@@ -752,6 +746,8 @@ bpf_base_func_proto(enum bpf_func_id func_id)
752746
return &bpf_probe_read_user_str_proto;
753747
case BPF_FUNC_probe_read_kernel_str:
754748
return &bpf_probe_read_kernel_str_proto;
749+
case BPF_FUNC_snprintf_btf:
750+
return &bpf_snprintf_btf_proto;
755751
default:
756752
return NULL;
757753
}

0 commit comments

Comments
 (0)