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: Drop "ops" from scx_ops_helper, scx_ops_enable_mutex and __scx_ops_enabled

The tag "ops" is used for two different purposes. First, to indicate that
the entity is directly related to the operations such as flags carried in
sched_ext_ops. Second, to indicate that the entity applies to something
global such as enable or bypass states. The second usage is historical and
causes confusion rather than clarifying anything. For example,
scx_ops_enable_state enums are named SCX_OPS_* and thus conflict with
scx_ops_flags. Let's drop the second usages.

Drop "ops" from scx_ops_helper, scx_ops_enable_mutex and __scx_ops_enabled.
Update scx_show_state.py accordingly.

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

+24 -25
+21 -22
kernel/sched/ext.c
··· 907 907 static LIST_HEAD(scx_tasks); 908 908 909 909 /* ops enable/disable */ 910 - static struct kthread_worker *scx_ops_helper; 911 - static DEFINE_MUTEX(scx_ops_enable_mutex); 912 - DEFINE_STATIC_KEY_FALSE(__scx_ops_enabled); 910 + static struct kthread_worker *scx_helper; 911 + static DEFINE_MUTEX(scx_enable_mutex); 912 + DEFINE_STATIC_KEY_FALSE(__scx_enabled); 913 913 DEFINE_STATIC_PERCPU_RWSEM(scx_fork_rwsem); 914 914 static atomic_t scx_enable_state_var = ATOMIC_INIT(SCX_DISABLED); 915 915 static unsigned long scx_in_softlockup; ··· 4712 4712 * we can safely use blocking synchronization constructs. Actually 4713 4713 * disable ops. 4714 4714 */ 4715 - mutex_lock(&scx_ops_enable_mutex); 4715 + mutex_lock(&scx_enable_mutex); 4716 4716 4717 4717 static_branch_disable(&__scx_switched_all); 4718 4718 WRITE_ONCE(scx_switching_all, false); ··· 4766 4766 } 4767 4767 4768 4768 /* no task is on scx, turn off all the switches and flush in-progress calls */ 4769 - static_branch_disable(&__scx_ops_enabled); 4769 + static_branch_disable(&__scx_enabled); 4770 4770 for (i = SCX_OPI_BEGIN; i < SCX_OPI_END; i++) 4771 4771 static_branch_disable(&scx_has_op[i]); 4772 4772 static_branch_disable(&scx_ops_allow_queued_wakeup); ··· 4826 4826 free_exit_info(scx_exit_info); 4827 4827 scx_exit_info = NULL; 4828 4828 4829 - mutex_unlock(&scx_ops_enable_mutex); 4829 + mutex_unlock(&scx_enable_mutex); 4830 4830 4831 4831 WARN_ON_ONCE(scx_set_enable_state(SCX_DISABLED) != SCX_DISABLING); 4832 4832 done: ··· 4837 4837 4838 4838 static void schedule_scx_ops_disable_work(void) 4839 4839 { 4840 - struct kthread_worker *helper = READ_ONCE(scx_ops_helper); 4840 + struct kthread_worker *helper = READ_ONCE(scx_helper); 4841 4841 4842 4842 /* 4843 4843 * We may be called spuriously before the first bpf_sched_ext_reg(). If 4844 - * scx_ops_helper isn't set up yet, there's nothing to do. 4844 + * scx_helper isn't set up yet, there's nothing to do. 4845 4845 */ 4846 4846 if (helper) 4847 4847 kthread_queue_work(helper, &scx_ops_disable_work); ··· 5262 5262 return -EINVAL; 5263 5263 } 5264 5264 5265 - mutex_lock(&scx_ops_enable_mutex); 5265 + mutex_lock(&scx_enable_mutex); 5266 5266 5267 5267 /* 5268 5268 * Clear event counters so a new scx scheduler gets ··· 5273 5273 memset(e, 0, sizeof(*e)); 5274 5274 } 5275 5275 5276 - if (!scx_ops_helper) { 5277 - WRITE_ONCE(scx_ops_helper, 5278 - scx_create_rt_helper("sched_ext_ops_helper")); 5279 - if (!scx_ops_helper) { 5276 + if (!scx_helper) { 5277 + WRITE_ONCE(scx_helper, scx_create_rt_helper("sched_ext_helper")); 5278 + if (!scx_helper) { 5280 5279 ret = -ENOMEM; 5281 5280 goto err_unlock; 5282 5281 } ··· 5399 5400 scx_watchdog_timeout / 2); 5400 5401 5401 5402 /* 5402 - * Once __scx_ops_enabled is set, %current can be switched to SCX 5403 - * anytime. This can lead to stalls as some BPF schedulers (e.g. 5404 - * userspace scheduling) may not function correctly before all tasks are 5405 - * switched. Init in bypass mode to guarantee forward progress. 5403 + * Once __scx_enabled is set, %current can be switched to SCX anytime. 5404 + * This can lead to stalls as some BPF schedulers (e.g. userspace 5405 + * scheduling) may not function correctly before all tasks are switched. 5406 + * Init in bypass mode to guarantee forward progress. 5406 5407 */ 5407 5408 scx_ops_bypass(true); 5408 5409 ··· 5484 5485 * all eligible tasks. 5485 5486 */ 5486 5487 WRITE_ONCE(scx_switching_all, !(ops->flags & SCX_OPS_SWITCH_PARTIAL)); 5487 - static_branch_enable(&__scx_ops_enabled); 5488 + static_branch_enable(&__scx_enabled); 5488 5489 5489 5490 /* 5490 5491 * We're fully committed and can't fail. The task READY -> ENABLED ··· 5528 5529 pr_info("sched_ext: BPF scheduler \"%s\" enabled%s\n", 5529 5530 scx_ops.name, scx_switched_all() ? "" : " (partial)"); 5530 5531 kobject_uevent(scx_root_kobj, KOBJ_ADD); 5531 - mutex_unlock(&scx_ops_enable_mutex); 5532 + mutex_unlock(&scx_enable_mutex); 5532 5533 5533 5534 atomic_long_inc(&scx_enable_seq); 5534 5535 ··· 5544 5545 scx_exit_info = NULL; 5545 5546 } 5546 5547 err_unlock: 5547 - mutex_unlock(&scx_ops_enable_mutex); 5548 + mutex_unlock(&scx_enable_mutex); 5548 5549 return ret; 5549 5550 5550 5551 err_disable_unlock_all: ··· 5552 5553 percpu_up_write(&scx_fork_rwsem); 5553 5554 scx_ops_bypass(false); 5554 5555 err_disable: 5555 - mutex_unlock(&scx_ops_enable_mutex); 5556 + mutex_unlock(&scx_enable_mutex); 5556 5557 /* 5557 5558 * Returning an error code here would not pass all the error information 5558 5559 * to userspace. Record errno using scx_ops_error() for cases ··· 5835 5836 5836 5837 static void sysrq_handle_sched_ext_reset(u8 key) 5837 5838 { 5838 - if (scx_ops_helper) 5839 + if (scx_helper) 5839 5840 scx_ops_disable(SCX_EXIT_SYSRQ); 5840 5841 else 5841 5842 pr_info("sched_ext: BPF scheduler not yet used\n");
+2 -2
kernel/sched/sched.h
··· 1717 1717 #ifdef CONFIG_SCHED_CLASS_EXT 1718 1718 extern const struct sched_class ext_sched_class; 1719 1719 1720 - DECLARE_STATIC_KEY_FALSE(__scx_ops_enabled); /* SCX BPF scheduler loaded */ 1720 + DECLARE_STATIC_KEY_FALSE(__scx_enabled); /* SCX BPF scheduler loaded */ 1721 1721 DECLARE_STATIC_KEY_FALSE(__scx_switched_all); /* all fair class tasks on SCX */ 1722 1722 1723 - #define scx_enabled() static_branch_unlikely(&__scx_ops_enabled) 1723 + #define scx_enabled() static_branch_unlikely(&__scx_enabled) 1724 1724 #define scx_switched_all() static_branch_unlikely(&__scx_switched_all) 1725 1725 1726 1726 static inline void scx_rq_clock_update(struct rq *rq, u64 clock)
+1 -1
tools/sched_ext/scx_show_state.py
··· 31 31 enable_state = read_atomic("scx_enable_state_var") 32 32 33 33 print(f'ops : {ops.name.string_().decode()}') 34 - print(f'enabled : {read_static_key("__scx_ops_enabled")}') 34 + print(f'enabled : {read_static_key("__scx_enabled")}') 35 35 print(f'switching_all : {read_int("scx_switching_all")}') 36 36 print(f'switched_all : {read_static_key("__scx_switched_all")}') 37 37 print(f'enable_state : {state_str(enable_state)} ({enable_state})')