Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Factor out reenq_local() from scx_bpf_reenqueue_local()

Factor out the core re-enqueue logic from scx_bpf_reenqueue_local() into a
new reenq_local() helper function. scx_bpf_reenqueue_local() now handles the
BPF kfunc checks and calls reenq_local() to perform the actual work.

This is a prep patch to allow reenq_local() to be called from other contexts.

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

Tejun Heo 8803e6a7 180b4ac3

+29 -21
+29 -21
kernel/sched/ext.c
··· 5879 5879 .set = &scx_kfunc_ids_dispatch, 5880 5880 }; 5881 5881 5882 - __bpf_kfunc_start_defs(); 5883 - 5884 - /** 5885 - * scx_bpf_reenqueue_local - Re-enqueue tasks on a local DSQ 5886 - * 5887 - * Iterate over all of the tasks currently enqueued on the local DSQ of the 5888 - * caller's CPU, and re-enqueue them in the BPF scheduler. Returns the number of 5889 - * processed tasks. Can only be called from ops.cpu_release(). 5890 - */ 5891 - __bpf_kfunc u32 scx_bpf_reenqueue_local(void) 5882 + static u32 reenq_local(struct rq *rq) 5892 5883 { 5893 - struct scx_sched *sch; 5894 5884 LIST_HEAD(tasks); 5895 5885 u32 nr_enqueued = 0; 5896 - struct rq *rq; 5897 5886 struct task_struct *p, *n; 5898 5887 5899 - guard(rcu)(); 5900 - sch = rcu_dereference(scx_root); 5901 - if (unlikely(!sch)) 5902 - return 0; 5903 - 5904 - if (!scx_kf_allowed(sch, SCX_KF_CPU_RELEASE)) 5905 - return 0; 5906 - 5907 - rq = cpu_rq(smp_processor_id()); 5908 5888 lockdep_assert_rq_held(rq); 5909 5889 5910 5890 /* ··· 5919 5939 } 5920 5940 5921 5941 return nr_enqueued; 5942 + } 5943 + 5944 + __bpf_kfunc_start_defs(); 5945 + 5946 + /** 5947 + * scx_bpf_reenqueue_local - Re-enqueue tasks on a local DSQ 5948 + * 5949 + * Iterate over all of the tasks currently enqueued on the local DSQ of the 5950 + * caller's CPU, and re-enqueue them in the BPF scheduler. Returns the number of 5951 + * processed tasks. Can only be called from ops.cpu_release(). 5952 + */ 5953 + __bpf_kfunc u32 scx_bpf_reenqueue_local(void) 5954 + { 5955 + struct scx_sched *sch; 5956 + struct rq *rq; 5957 + 5958 + guard(rcu)(); 5959 + sch = rcu_dereference(scx_root); 5960 + if (unlikely(!sch)) 5961 + return 0; 5962 + 5963 + if (!scx_kf_allowed(sch, SCX_KF_CPU_RELEASE)) 5964 + return 0; 5965 + 5966 + rq = cpu_rq(smp_processor_id()); 5967 + lockdep_assert_rq_held(rq); 5968 + 5969 + return reenq_local(rq); 5922 5970 } 5923 5971 5924 5972 __bpf_kfunc_end_defs();