@@ -5407,77 +5407,15 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
54075407#include <linux/bpf.h>
54085408#include <linux/btf.h>
54095409
5410- extern struct btf * btf_vmlinux ;
54115410static const struct btf_type * task_struct_type ;
54125411
5413- static bool set_arg_maybe_null (const char * op , int arg_n , int off , int size ,
5414- enum bpf_access_type type ,
5415- const struct bpf_prog * prog ,
5416- struct bpf_insn_access_aux * info )
5417- {
5418- struct btf * btf = bpf_get_btf_vmlinux ();
5419- const struct bpf_struct_ops_desc * st_ops_desc ;
5420- const struct btf_member * member ;
5421- const struct btf_type * t ;
5422- u32 btf_id , member_idx ;
5423- const char * mname ;
5424-
5425- /* struct_ops op args are all sequential, 64-bit numbers */
5426- if (off != arg_n * sizeof (__u64 ))
5427- return false;
5428-
5429- /* btf_id should be the type id of struct sched_ext_ops */
5430- btf_id = prog -> aux -> attach_btf_id ;
5431- st_ops_desc = bpf_struct_ops_find (btf , btf_id );
5432- if (!st_ops_desc )
5433- return false;
5434-
5435- /* BTF type of struct sched_ext_ops */
5436- t = st_ops_desc -> type ;
5437-
5438- member_idx = prog -> expected_attach_type ;
5439- if (member_idx >= btf_type_vlen (t ))
5440- return false;
5441-
5442- /*
5443- * Get the member name of this struct_ops program, which corresponds to
5444- * a field in struct sched_ext_ops. For example, the member name of the
5445- * dispatch struct_ops program (callback) is "dispatch".
5446- */
5447- member = & btf_type_member (t )[member_idx ];
5448- mname = btf_name_by_offset (btf_vmlinux , member -> name_off );
5449-
5450- if (!strcmp (mname , op )) {
5451- /*
5452- * The value is a pointer to a type (struct task_struct) given
5453- * by a BTF ID (PTR_TO_BTF_ID). It is trusted (PTR_TRUSTED),
5454- * however, can be a NULL (PTR_MAYBE_NULL). The BPF program
5455- * should check the pointer to make sure it is not NULL before
5456- * using it, or the verifier will reject the program.
5457- *
5458- * Longer term, this is something that should be addressed by
5459- * BTF, and be fully contained within the verifier.
5460- */
5461- info -> reg_type = PTR_MAYBE_NULL | PTR_TO_BTF_ID | PTR_TRUSTED ;
5462- info -> btf = btf_vmlinux ;
5463- info -> btf_id = btf_tracing_ids [BTF_TRACING_TYPE_TASK ];
5464-
5465- return true;
5466- }
5467-
5468- return false;
5469- }
5470-
54715412static bool bpf_scx_is_valid_access (int off , int size ,
54725413 enum bpf_access_type type ,
54735414 const struct bpf_prog * prog ,
54745415 struct bpf_insn_access_aux * info )
54755416{
54765417 if (type != BPF_READ )
54775418 return false;
5478- if (set_arg_maybe_null ("dispatch" , 1 , off , size , type , prog , info ) ||
5479- set_arg_maybe_null ("yield" , 1 , off , size , type , prog , info ))
5480- return true;
54815419 if (off < 0 || off >= sizeof (__u64 ) * MAX_BPF_FUNC_ARGS )
54825420 return false;
54835421 if (off % size != 0 )
@@ -5637,13 +5575,13 @@ static int bpf_scx_validate(void *kdata)
56375575static s32 sched_ext_ops__select_cpu (struct task_struct * p , s32 prev_cpu , u64 wake_flags ) { return - EINVAL ; }
56385576static void sched_ext_ops__enqueue (struct task_struct * p , u64 enq_flags ) {}
56395577static void sched_ext_ops__dequeue (struct task_struct * p , u64 enq_flags ) {}
5640- static void sched_ext_ops__dispatch (s32 prev_cpu , struct task_struct * p ) {}
5578+ static void sched_ext_ops__dispatch (s32 prev_cpu , struct task_struct * prev__nullable ) {}
56415579static void sched_ext_ops__tick (struct task_struct * p ) {}
56425580static void sched_ext_ops__runnable (struct task_struct * p , u64 enq_flags ) {}
56435581static void sched_ext_ops__running (struct task_struct * p ) {}
56445582static void sched_ext_ops__stopping (struct task_struct * p , bool runnable ) {}
56455583static void sched_ext_ops__quiescent (struct task_struct * p , u64 deq_flags ) {}
5646- static bool sched_ext_ops__yield (struct task_struct * from , struct task_struct * to ) { return false; }
5584+ static bool sched_ext_ops__yield (struct task_struct * from , struct task_struct * to__nullable ) { return false; }
56475585static bool sched_ext_ops__core_sched_before (struct task_struct * a , struct task_struct * b ) { return false; }
56485586static void sched_ext_ops__set_weight (struct task_struct * p , u32 weight ) {}
56495587static void sched_ext_ops__set_cpumask (struct task_struct * p , const struct cpumask * mask ) {}
0 commit comments