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_enable_state and friends

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_enable_state and friends. Update scx_show_state.py
accordingly.

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

+41 -48
+37 -44
kernel/sched/ext.c
··· 838 838 SCX_TG_INITED = 1U << 1, 839 839 }; 840 840 841 - enum scx_ops_enable_state { 842 - SCX_OPS_ENABLING, 843 - SCX_OPS_ENABLED, 844 - SCX_OPS_DISABLING, 845 - SCX_OPS_DISABLED, 841 + enum scx_enable_state { 842 + SCX_ENABLING, 843 + SCX_ENABLED, 844 + SCX_DISABLING, 845 + SCX_DISABLED, 846 846 }; 847 847 848 - static const char *scx_ops_enable_state_str[] = { 849 - [SCX_OPS_ENABLING] = "enabling", 850 - [SCX_OPS_ENABLED] = "enabled", 851 - [SCX_OPS_DISABLING] = "disabling", 852 - [SCX_OPS_DISABLED] = "disabled", 848 + static const char *scx_enable_state_str[] = { 849 + [SCX_ENABLING] = "enabling", 850 + [SCX_ENABLED] = "enabled", 851 + [SCX_DISABLING] = "disabling", 852 + [SCX_DISABLED] = "disabled", 853 853 }; 854 854 855 855 /* ··· 911 911 static DEFINE_MUTEX(scx_ops_enable_mutex); 912 912 DEFINE_STATIC_KEY_FALSE(__scx_ops_enabled); 913 913 DEFINE_STATIC_PERCPU_RWSEM(scx_fork_rwsem); 914 - static atomic_t scx_ops_enable_state_var = ATOMIC_INIT(SCX_OPS_DISABLED); 914 + static atomic_t scx_enable_state_var = ATOMIC_INIT(SCX_DISABLED); 915 915 static unsigned long scx_in_softlockup; 916 916 static atomic_t scx_ops_breather_depth = ATOMIC_INIT(0); 917 917 static int scx_ops_bypass_depth; ··· 1592 1592 1593 1593 static void scx_bpf_events(struct scx_event_stats *events, size_t events__sz); 1594 1594 1595 - static enum scx_ops_enable_state scx_ops_enable_state(void) 1595 + static enum scx_enable_state scx_enable_state(void) 1596 1596 { 1597 - return atomic_read(&scx_ops_enable_state_var); 1597 + return atomic_read(&scx_enable_state_var); 1598 1598 } 1599 1599 1600 - static enum scx_ops_enable_state 1601 - scx_ops_set_enable_state(enum scx_ops_enable_state to) 1600 + static enum scx_enable_state scx_set_enable_state(enum scx_enable_state to) 1602 1601 { 1603 - return atomic_xchg(&scx_ops_enable_state_var, to); 1602 + return atomic_xchg(&scx_enable_state_var, to); 1604 1603 } 1605 1604 1606 - static bool scx_ops_tryset_enable_state(enum scx_ops_enable_state to, 1607 - enum scx_ops_enable_state from) 1605 + static bool scx_tryset_enable_state(enum scx_enable_state to, 1606 + enum scx_enable_state from) 1608 1607 { 1609 1608 int from_v = from; 1610 1609 1611 - return atomic_try_cmpxchg(&scx_ops_enable_state_var, &from_v, to); 1610 + return atomic_try_cmpxchg(&scx_enable_state_var, &from_v, to); 1612 1611 } 1613 1612 1614 1613 static bool scx_rq_bypassing(struct rq *rq) ··· 3282 3283 * Can happen while enabling as SCX_RQ_BAL_PENDING assertion is 3283 3284 * conditional on scx_enabled() and may have been skipped. 3284 3285 */ 3285 - WARN_ON_ONCE(scx_ops_enable_state() == SCX_OPS_ENABLED); 3286 + WARN_ON_ONCE(scx_enable_state() == SCX_ENABLED); 3286 3287 keep_prev = false; 3287 3288 } 3288 3289 ··· 3903 3904 3904 3905 static void scx_cgroup_warn_missing_weight(struct task_group *tg) 3905 3906 { 3906 - if (scx_ops_enable_state() == SCX_OPS_DISABLED || 3907 - cgroup_warned_missing_weight) 3907 + if (scx_enable_state() == SCX_DISABLED || cgroup_warned_missing_weight) 3908 3908 return; 3909 3909 3910 3910 if ((scx_ops.flags & SCX_OPS_HAS_CGROUP_WEIGHT) || !tg->css.parent) ··· 4337 4339 static ssize_t scx_attr_state_show(struct kobject *kobj, 4338 4340 struct kobj_attribute *ka, char *buf) 4339 4341 { 4340 - return sysfs_emit(buf, "%s\n", 4341 - scx_ops_enable_state_str[scx_ops_enable_state()]); 4342 + return sysfs_emit(buf, "%s\n", scx_enable_state_str[scx_enable_state()]); 4342 4343 } 4343 4344 SCX_ATTR(state); 4344 4345 ··· 4446 4449 */ 4447 4450 bool task_should_scx(int policy) 4448 4451 { 4449 - if (!scx_enabled() || 4450 - unlikely(scx_ops_enable_state() == SCX_OPS_DISABLING)) 4452 + if (!scx_enabled() || unlikely(scx_enable_state() == SCX_DISABLING)) 4451 4453 return false; 4452 4454 if (READ_ONCE(scx_switching_all)) 4453 4455 return true; ··· 4465 4469 */ 4466 4470 void scx_softlockup(u32 dur_s) 4467 4471 { 4468 - switch (scx_ops_enable_state()) { 4469 - case SCX_OPS_ENABLING: 4470 - case SCX_OPS_ENABLED: 4472 + switch (scx_enable_state()) { 4473 + case SCX_ENABLING: 4474 + case SCX_ENABLED: 4471 4475 break; 4472 4476 default: 4473 4477 return; ··· 4694 4698 /* guarantee forward progress by bypassing scx_ops */ 4695 4699 scx_ops_bypass(true); 4696 4700 4697 - switch (scx_ops_set_enable_state(SCX_OPS_DISABLING)) { 4698 - case SCX_OPS_DISABLING: 4701 + switch (scx_set_enable_state(SCX_DISABLING)) { 4702 + case SCX_DISABLING: 4699 4703 WARN_ONCE(true, "sched_ext: duplicate disabling instance?"); 4700 4704 break; 4701 - case SCX_OPS_DISABLED: 4705 + case SCX_DISABLED: 4702 4706 pr_warn("sched_ext: ops error detected without ops (%s)\n", 4703 4707 scx_exit_info->msg); 4704 - WARN_ON_ONCE(scx_ops_set_enable_state(SCX_OPS_DISABLED) != 4705 - SCX_OPS_DISABLING); 4708 + WARN_ON_ONCE(scx_set_enable_state(SCX_DISABLED) != SCX_DISABLING); 4706 4709 goto done; 4707 4710 default: 4708 4711 break; ··· 4828 4833 4829 4834 mutex_unlock(&scx_ops_enable_mutex); 4830 4835 4831 - WARN_ON_ONCE(scx_ops_set_enable_state(SCX_OPS_DISABLED) != 4832 - SCX_OPS_DISABLING); 4836 + WARN_ON_ONCE(scx_set_enable_state(SCX_DISABLED) != SCX_DISABLING); 4833 4837 done: 4834 4838 scx_ops_bypass(false); 4835 4839 } ··· 5310 5316 global_dsqs = dsqs; 5311 5317 } 5312 5318 5313 - if (scx_ops_enable_state() != SCX_OPS_DISABLED) { 5319 + if (scx_enable_state() != SCX_DISABLED) { 5314 5320 ret = -EBUSY; 5315 5321 goto err_unlock; 5316 5322 } ··· 5338 5344 */ 5339 5345 scx_ops = *ops; 5340 5346 5341 - WARN_ON_ONCE(scx_ops_set_enable_state(SCX_OPS_ENABLING) != 5342 - SCX_OPS_DISABLED); 5347 + WARN_ON_ONCE(scx_set_enable_state(SCX_ENABLING) != SCX_DISABLED); 5343 5348 5344 5349 atomic_set(&scx_exit_kind, SCX_EXIT_NONE); 5345 5350 scx_warned_zero_slice = false; ··· 5518 5525 5519 5526 scx_ops_bypass(false); 5520 5527 5521 - if (!scx_ops_tryset_enable_state(SCX_OPS_ENABLED, SCX_OPS_ENABLING)) { 5528 + if (!scx_tryset_enable_state(SCX_ENABLED, SCX_ENABLING)) { 5522 5529 WARN_ON_ONCE(atomic_read(&scx_exit_kind) == SCX_EXIT_NONE); 5523 5530 goto err_disable; 5524 5531 } ··· 5987 5994 */ 5988 5995 void print_scx_info(const char *log_lvl, struct task_struct *p) 5989 5996 { 5990 - enum scx_ops_enable_state state = scx_ops_enable_state(); 5997 + enum scx_enable_state state = scx_enable_state(); 5991 5998 const char *all = READ_ONCE(scx_switching_all) ? "+all" : ""; 5992 5999 char runnable_at_buf[22] = "?"; 5993 6000 struct sched_class *class; 5994 6001 unsigned long runnable_at; 5995 6002 5996 - if (state == SCX_OPS_DISABLED) 6003 + if (state == SCX_DISABLED) 5997 6004 return; 5998 6005 5999 6006 /* ··· 6003 6010 if (copy_from_kernel_nofault(&class, &p->sched_class, sizeof(class)) || 6004 6011 class != &ext_sched_class) { 6005 6012 printk("%sSched_ext: %s (%s%s)", log_lvl, scx_ops.name, 6006 - scx_ops_enable_state_str[state], all); 6013 + scx_enable_state_str[state], all); 6007 6014 return; 6008 6015 } 6009 6016 ··· 6014 6021 6015 6022 /* print everything onto one line to conserve console space */ 6016 6023 printk("%sSched_ext: %s (%s%s), task: runnable_at=%s", 6017 - log_lvl, scx_ops.name, scx_ops_enable_state_str[state], all, 6024 + log_lvl, scx_ops.name, scx_enable_state_str[state], all, 6018 6025 runnable_at_buf); 6019 6026 } 6020 6027
+4 -4
tools/sched_ext/scx_show_state.py
··· 24 24 def read_static_key(name): 25 25 return prog[name].key.enabled.counter.value_() 26 26 27 - def ops_state_str(state): 28 - return prog['scx_ops_enable_state_str'][state].string_().decode() 27 + def state_str(state): 28 + return prog['scx_enable_state_str'][state].string_().decode() 29 29 30 30 ops = prog['scx_ops'] 31 - enable_state = read_atomic("scx_ops_enable_state_var") 31 + enable_state = read_atomic("scx_enable_state_var") 32 32 33 33 print(f'ops : {ops.name.string_().decode()}') 34 34 print(f'enabled : {read_static_key("__scx_ops_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 - print(f'enable_state : {ops_state_str(enable_state)} ({enable_state})') 37 + print(f'enable_state : {state_str(enable_state)} ({enable_state})') 38 38 print(f'in_softlockup : {prog["scx_in_softlockup"].value_()}') 39 39 print(f'breather_depth: {read_atomic("scx_ops_breather_depth")}') 40 40 print(f'bypass_depth : {prog["scx_ops_bypass_depth"].value_()}')