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: idle: introduce check_builtin_idle_enabled() helper

Minor refactoring to add a helper function for checking if the built-in
idle CPU selection policy is enabled.

Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Andrea Righi and committed by
Tejun Heo
c0cf3530 02f034dc

+14 -15
+14 -15
kernel/sched/ext.c
··· 6297 6297 6298 6298 __bpf_kfunc_start_defs(); 6299 6299 6300 + static bool check_builtin_idle_enabled(void) 6301 + { 6302 + if (static_branch_likely(&scx_builtin_idle_enabled)) 6303 + return true; 6304 + 6305 + scx_ops_error("built-in idle tracking is disabled"); 6306 + return false; 6307 + } 6308 + 6300 6309 /** 6301 6310 * scx_bpf_select_cpu_dfl - The default implementation of ops.select_cpu() 6302 6311 * @p: task_struct to select a CPU for ··· 6323 6314 __bpf_kfunc s32 scx_bpf_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, 6324 6315 u64 wake_flags, bool *is_idle) 6325 6316 { 6326 - if (!static_branch_likely(&scx_builtin_idle_enabled)) { 6327 - scx_ops_error("built-in idle tracking is disabled"); 6317 + if (!check_builtin_idle_enabled()) 6328 6318 goto prev_cpu; 6329 - } 6330 6319 6331 6320 if (!scx_kf_allowed(SCX_KF_SELECT_CPU)) 6332 6321 goto prev_cpu; ··· 7418 7411 */ 7419 7412 __bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask(void) 7420 7413 { 7421 - if (!static_branch_likely(&scx_builtin_idle_enabled)) { 7422 - scx_ops_error("built-in idle tracking is disabled"); 7414 + if (!check_builtin_idle_enabled()) 7423 7415 return cpu_none_mask; 7424 - } 7425 7416 7426 7417 #ifdef CONFIG_SMP 7427 7418 return idle_masks.cpu; ··· 7437 7432 */ 7438 7433 __bpf_kfunc const struct cpumask *scx_bpf_get_idle_smtmask(void) 7439 7434 { 7440 - if (!static_branch_likely(&scx_builtin_idle_enabled)) { 7441 - scx_ops_error("built-in idle tracking is disabled"); 7435 + if (!check_builtin_idle_enabled()) 7442 7436 return cpu_none_mask; 7443 - } 7444 7437 7445 7438 #ifdef CONFIG_SMP 7446 7439 if (sched_smt_active()) ··· 7476 7473 */ 7477 7474 __bpf_kfunc bool scx_bpf_test_and_clear_cpu_idle(s32 cpu) 7478 7475 { 7479 - if (!static_branch_likely(&scx_builtin_idle_enabled)) { 7480 - scx_ops_error("built-in idle tracking is disabled"); 7476 + if (!check_builtin_idle_enabled()) 7481 7477 return false; 7482 - } 7483 7478 7484 7479 if (ops_cpu_valid(cpu, NULL)) 7485 7480 return test_and_clear_cpu_idle(cpu); ··· 7507 7506 __bpf_kfunc s32 scx_bpf_pick_idle_cpu(const struct cpumask *cpus_allowed, 7508 7507 u64 flags) 7509 7508 { 7510 - if (!static_branch_likely(&scx_builtin_idle_enabled)) { 7511 - scx_ops_error("built-in idle tracking is disabled"); 7509 + if (!check_builtin_idle_enabled()) 7512 7510 return -EBUSY; 7513 - } 7514 7511 7515 7512 return scx_pick_idle_cpu(cpus_allowed, flags); 7516 7513 }