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_{init|exit|enable|disable}[_task]() 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_{init|exit|enable|disable}[_task]() and friends.

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

+46 -46
+46 -46
kernel/sched/ext.c
··· 915 915 static unsigned long scx_in_softlockup; 916 916 static atomic_t scx_breather_depth = ATOMIC_INIT(0); 917 917 static int scx_bypass_depth; 918 - static bool scx_ops_init_task_enabled; 918 + static bool scx_init_task_enabled; 919 919 static bool scx_switching_all; 920 920 DEFINE_STATIC_KEY_FALSE(__scx_switched_all); 921 921 ··· 2956 2956 * scheduler wants to handle this explicitly, it should 2957 2957 * implement ->cpu_release(). 2958 2958 * 2959 - * See scx_ops_disable_workfn() for the explanation on the 2960 - * bypassing test. 2959 + * See scx_disable_workfn() for the explanation on the bypassing 2960 + * test. 2961 2961 */ 2962 2962 if (prev_on_rq && prev->scx.slice && !scx_rq_bypassing(rq)) { 2963 2963 rq->scx.flags |= SCX_RQ_BAL_KEEP; ··· 3611 3611 p->scx.flags |= state << SCX_TASK_STATE_SHIFT; 3612 3612 } 3613 3613 3614 - static int scx_ops_init_task(struct task_struct *p, struct task_group *tg, bool fork) 3614 + static int scx_init_task(struct task_struct *p, struct task_group *tg, bool fork) 3615 3615 { 3616 3616 int ret; 3617 3617 ··· 3662 3662 return 0; 3663 3663 } 3664 3664 3665 - static void scx_ops_enable_task(struct task_struct *p) 3665 + static void scx_enable_task(struct task_struct *p) 3666 3666 { 3667 3667 u32 weight; 3668 3668 ··· 3687 3687 SCX_CALL_OP_TASK(SCX_KF_REST, set_weight, p, p->scx.weight); 3688 3688 } 3689 3689 3690 - static void scx_ops_disable_task(struct task_struct *p) 3690 + static void scx_disable_task(struct task_struct *p) 3691 3691 { 3692 3692 lockdep_assert_rq_held(task_rq(p)); 3693 3693 WARN_ON_ONCE(scx_get_task_state(p) != SCX_TASK_ENABLED); ··· 3697 3697 scx_set_task_state(p, SCX_TASK_READY); 3698 3698 } 3699 3699 3700 - static void scx_ops_exit_task(struct task_struct *p) 3700 + static void scx_exit_task(struct task_struct *p) 3701 3701 { 3702 3702 struct scx_exit_task_args args = { 3703 3703 .cancelled = false, ··· 3714 3714 case SCX_TASK_READY: 3715 3715 break; 3716 3716 case SCX_TASK_ENABLED: 3717 - scx_ops_disable_task(p); 3717 + scx_disable_task(p); 3718 3718 break; 3719 3719 default: 3720 3720 WARN_ON_ONCE(true); ··· 3754 3754 { 3755 3755 percpu_rwsem_assert_held(&scx_fork_rwsem); 3756 3756 3757 - if (scx_ops_init_task_enabled) 3758 - return scx_ops_init_task(p, task_group(p), true); 3757 + if (scx_init_task_enabled) 3758 + return scx_init_task(p, task_group(p), true); 3759 3759 else 3760 3760 return 0; 3761 3761 } 3762 3762 3763 3763 void scx_post_fork(struct task_struct *p) 3764 3764 { 3765 - if (scx_ops_init_task_enabled) { 3765 + if (scx_init_task_enabled) { 3766 3766 scx_set_task_state(p, SCX_TASK_READY); 3767 3767 3768 3768 /* ··· 3775 3775 struct rq *rq; 3776 3776 3777 3777 rq = task_rq_lock(p, &rf); 3778 - scx_ops_enable_task(p); 3778 + scx_enable_task(p); 3779 3779 task_rq_unlock(rq, p, &rf); 3780 3780 } 3781 3781 } ··· 3795 3795 3796 3796 rq = task_rq_lock(p, &rf); 3797 3797 WARN_ON_ONCE(scx_get_task_state(p) >= SCX_TASK_READY); 3798 - scx_ops_exit_task(p); 3798 + scx_exit_task(p); 3799 3799 task_rq_unlock(rq, p, &rf); 3800 3800 } 3801 3801 ··· 3811 3811 spin_unlock_irqrestore(&scx_tasks_lock, flags); 3812 3812 3813 3813 /* 3814 - * @p is off scx_tasks and wholly ours. scx_ops_enable()'s READY -> 3815 - * ENABLED transitions can't race us. Disable ops for @p. 3814 + * @p is off scx_tasks and wholly ours. scx_enable()'s READY -> ENABLED 3815 + * transitions can't race us. Disable ops for @p. 3816 3816 */ 3817 3817 if (scx_get_task_state(p) != SCX_TASK_NONE) { 3818 3818 struct rq_flags rf; 3819 3819 struct rq *rq; 3820 3820 3821 3821 rq = task_rq_lock(p, &rf); 3822 - scx_ops_exit_task(p); 3822 + scx_exit_task(p); 3823 3823 task_rq_unlock(rq, p, &rf); 3824 3824 } 3825 3825 } ··· 3840 3840 3841 3841 static void switching_to_scx(struct rq *rq, struct task_struct *p) 3842 3842 { 3843 - scx_ops_enable_task(p); 3843 + scx_enable_task(p); 3844 3844 3845 3845 /* 3846 3846 * set_cpus_allowed_scx() is not called while @p is associated with a ··· 3853 3853 3854 3854 static void switched_from_scx(struct rq *rq, struct task_struct *p) 3855 3855 { 3856 - scx_ops_disable_task(p); 3856 + scx_disable_task(p); 3857 3857 } 3858 3858 3859 3859 static void wakeup_preempt_scx(struct rq *rq, struct task_struct *p,int wake_flags) {} ··· 4662 4662 } 4663 4663 } 4664 4664 4665 - static void scx_ops_disable_workfn(struct kthread_work *work) 4665 + static void scx_disable_workfn(struct kthread_work *work) 4666 4666 { 4667 4667 struct scx_exit_info *ei = scx_exit_info; 4668 4668 struct scx_task_iter sti; ··· 4714 4714 4715 4715 /* 4716 4716 * Shut down cgroup support before tasks so that the cgroup attach path 4717 - * doesn't race against scx_ops_exit_task(). 4717 + * doesn't race against scx_exit_task(). 4718 4718 */ 4719 4719 scx_cgroup_lock(); 4720 4720 scx_cgroup_exit(); ··· 4726 4726 */ 4727 4727 percpu_down_write(&scx_fork_rwsem); 4728 4728 4729 - scx_ops_init_task_enabled = false; 4729 + scx_init_task_enabled = false; 4730 4730 4731 4731 scx_task_iter_start(&sti); 4732 4732 while ((p = scx_task_iter_next_locked(&sti))) { ··· 4746 4746 sched_enq_and_set_task(&ctx); 4747 4747 4748 4748 check_class_changed(task_rq(p), p, old_class, p->prio); 4749 - scx_ops_exit_task(p); 4749 + scx_exit_task(p); 4750 4750 } 4751 4751 scx_task_iter_stop(&sti); 4752 4752 percpu_up_write(&scx_fork_rwsem); ··· 4828 4828 scx_bypass(false); 4829 4829 } 4830 4830 4831 - static DEFINE_KTHREAD_WORK(scx_ops_disable_work, scx_ops_disable_workfn); 4831 + static DEFINE_KTHREAD_WORK(scx_disable_work, scx_disable_workfn); 4832 4832 4833 - static void schedule_scx_ops_disable_work(void) 4833 + static void schedule_scx_disable_work(void) 4834 4834 { 4835 4835 struct kthread_worker *helper = READ_ONCE(scx_helper); 4836 4836 ··· 4839 4839 * scx_helper isn't set up yet, there's nothing to do. 4840 4840 */ 4841 4841 if (helper) 4842 - kthread_queue_work(helper, &scx_ops_disable_work); 4842 + kthread_queue_work(helper, &scx_disable_work); 4843 4843 } 4844 4844 4845 - static void scx_ops_disable(enum scx_exit_kind kind) 4845 + static void scx_disable(enum scx_exit_kind kind) 4846 4846 { 4847 4847 int none = SCX_EXIT_NONE; 4848 4848 ··· 4851 4851 4852 4852 atomic_try_cmpxchg(&scx_exit_kind, &none, kind); 4853 4853 4854 - schedule_scx_ops_disable_work(); 4854 + schedule_scx_disable_work(); 4855 4855 } 4856 4856 4857 4857 static void dump_newline(struct seq_buf *s) ··· 5156 5156 if (ei->kind >= SCX_EXIT_ERROR) 5157 5157 scx_dump_state(ei, scx_ops.exit_dump_len); 5158 5158 5159 - schedule_scx_ops_disable_work(); 5159 + schedule_scx_disable_work(); 5160 5160 } 5161 5161 5162 5162 static DEFINE_IRQ_WORK(scx_error_irq_work, scx_error_irq_workfn); ··· 5182 5182 5183 5183 /* 5184 5184 * Set ei->kind and ->reason for scx_dump_state(). They'll be set again 5185 - * in scx_ops_disable_workfn(). 5185 + * in scx_disable_workfn(). 5186 5186 */ 5187 5187 ei->kind = kind; 5188 5188 ei->reason = scx_exit_reason(ei->kind); ··· 5243 5243 return 0; 5244 5244 } 5245 5245 5246 - static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link) 5246 + static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link) 5247 5247 { 5248 5248 struct scx_task_iter sti; 5249 5249 struct task_struct *p; ··· 5421 5421 */ 5422 5422 percpu_down_write(&scx_fork_rwsem); 5423 5423 5424 - WARN_ON_ONCE(scx_ops_init_task_enabled); 5425 - scx_ops_init_task_enabled = true; 5424 + WARN_ON_ONCE(scx_init_task_enabled); 5425 + scx_init_task_enabled = true; 5426 5426 5427 5427 /* 5428 5428 * Enable ops for every task. Fork is excluded by scx_fork_rwsem ··· 5431 5431 * tasks. Prep all tasks first and then enable them with preemption 5432 5432 * disabled. 5433 5433 * 5434 - * All cgroups should be initialized before scx_ops_init_task() so that 5435 - * the BPF scheduler can reliably track each task's cgroup membership 5436 - * from scx_ops_init_task(). Lock out cgroup on/offlining and task 5437 - * migrations while tasks are being initialized so that 5438 - * scx_cgroup_can_attach() never sees uninitialized tasks. 5434 + * All cgroups should be initialized before scx_init_task() so that the 5435 + * BPF scheduler can reliably track each task's cgroup membership from 5436 + * scx_init_task(). Lock out cgroup on/offlining and task migrations 5437 + * while tasks are being initialized so that scx_cgroup_can_attach() 5438 + * never sees uninitialized tasks. 5439 5439 */ 5440 5440 scx_cgroup_lock(); 5441 5441 ret = scx_cgroup_init(); ··· 5454 5454 5455 5455 scx_task_iter_unlock(&sti); 5456 5456 5457 - ret = scx_ops_init_task(p, task_group(p), false); 5457 + ret = scx_init_task(p, task_group(p), false); 5458 5458 if (ret) { 5459 5459 put_task_struct(p); 5460 5460 scx_task_iter_relock(&sti); ··· 5553 5553 * wasn't already invoked and exit indicating success so that the error 5554 5554 * is notified through ops.exit() with all the details. 5555 5555 * 5556 - * Flush scx_ops_disable_work to ensure that error is reported before 5557 - * init completion. 5556 + * Flush scx_disable_work to ensure that error is reported before init 5557 + * completion. 5558 5558 */ 5559 - scx_error("scx_ops_enable() failed (%d)", ret); 5560 - kthread_flush_work(&scx_ops_disable_work); 5559 + scx_error("scx_enable() failed (%d)", ret); 5560 + kthread_flush_work(&scx_disable_work); 5561 5561 return 0; 5562 5562 } 5563 5563 ··· 5701 5701 5702 5702 static int bpf_scx_reg(void *kdata, struct bpf_link *link) 5703 5703 { 5704 - return scx_ops_enable(kdata, link); 5704 + return scx_enable(kdata, link); 5705 5705 } 5706 5706 5707 5707 static void bpf_scx_unreg(void *kdata, struct bpf_link *link) 5708 5708 { 5709 - scx_ops_disable(SCX_EXIT_UNREG); 5710 - kthread_flush_work(&scx_ops_disable_work); 5709 + scx_disable(SCX_EXIT_UNREG); 5710 + kthread_flush_work(&scx_disable_work); 5711 5711 } 5712 5712 5713 5713 static int bpf_scx_init(struct btf *btf) ··· 5830 5830 static void sysrq_handle_sched_ext_reset(u8 key) 5831 5831 { 5832 5832 if (scx_helper) 5833 - scx_ops_disable(SCX_EXIT_SYSRQ); 5833 + scx_disable(SCX_EXIT_SYSRQ); 5834 5834 else 5835 5835 pr_info("sched_ext: BPF scheduler not yet used\n"); 5836 5836 }