History

sched_ext: Relocate cpu_acquire/cpu_release to end of struct sched_ext_ops

cpu_acquire and cpu_release are deprecated and slated for removal. Move their declarations to the end of struct sched_ext_ops so an upcoming cid-form struct (sched_ext_ops_cid) can omit them entirely without disturbing the offsets of the shared fields. Switch the two SCX_HAS_OP() callers for these ops to direct field checks since the relocated ops sit outside the SCX_OPI_END range covered by the has_op bitmap. scx_kf_allow_flags[] auto-sizes to the highest used SCX_OP_IDX, so SCX_OP_IDX(cpu_release) moving to a higher index just enlarges the sparse array; the lookup logic is unchanged.

Tejun Heo committed 6 months ago

Commit 1e315c41 parent 017ec7d2 files · +34 −24Browse files

Showing the changes to kernel (2 of 2 files). Show all

Unified · Split

2 files
  1. kernel/sched/ext.c +2 −2
  2. kernel/sched/ext_internal.h +32 −22
kernel/sched/ext.c+2−2
@@ -2823,7 +2823,7 @@ static int balance_one(struct rq *rq, struct task_struct *prev) · 2822 unmodified lines
2823 * core. This callback complements ->cpu_release(), which is2823 * core. This callback complements ->cpu_release(), which is
2824 * emitted in switch_class().2824 * emitted in switch_class().
2825 */2825 */
2826 if (SCX_HAS_OP(sch, cpu_acquire))2826 if (sch->ops.cpu_acquire)
2827 SCX_CALL_OP(sch, cpu_acquire, rq, cpu, NULL);2827 SCX_CALL_OP(sch, cpu_acquire, rq, cpu, NULL);
2828 rq->scx.cpu_released = false;2828 rq->scx.cpu_released = false;
2829 }2829 }
@@ -2969,7 +2969,7 @@ static void switch_class(struct rq *rq, struct task_struct *next) · 139 unmodified lines
2969 * next time that balance_one() is invoked.2969 * next time that balance_one() is invoked.
2970 */2970 */
2971 if (!rq->scx.cpu_released) {2971 if (!rq->scx.cpu_released) {
2972 if (SCX_HAS_OP(sch, cpu_release)) {2972 if (sch->ops.cpu_release) {
2973 struct scx_cpu_release_args args = {2973 struct scx_cpu_release_args args = {
2974 .reason = preempt_reason_from_class(next_class),2974 .reason = preempt_reason_from_class(next_class),
2975 .task = next,2975 .task = next,
kernel/sched/ext_internal.h+32−22
@@ -529,28 +529,6 @@ struct sched_ext_ops { · 528 unmodified lines
529 */529 */
530 void (*update_idle)(s32 cpu, bool idle);530 void (*update_idle)(s32 cpu, bool idle);
531 531
532 /**
533 * @cpu_acquire: A CPU is becoming available to the BPF scheduler
534 * @cpu: The CPU being acquired by the BPF scheduler.
535 * @args: Acquire arguments, see the struct definition.
536 *
537 * A CPU that was previously released from the BPF scheduler is now once
538 * again under its control.
539 */
540 void (*cpu_acquire)(s32 cpu, struct scx_cpu_acquire_args *args);
541
542 /**
543 * @cpu_release: A CPU is taken away from the BPF scheduler
544 * @cpu: The CPU being released by the BPF scheduler.
545 * @args: Release arguments, see the struct definition.
546 *
547 * The specified CPU is no longer under the control of the BPF
548 * scheduler. This could be because it was preempted by a higher
549 * priority sched_class, though there may be other reasons as well. The
550 * caller should consult @args->reason to determine the cause.
551 */
552 void (*cpu_release)(s32 cpu, struct scx_cpu_release_args *args);
553
554 /**532 /**
555 * @init_task: Initialize a task to run in a BPF scheduler533 * @init_task: Initialize a task to run in a BPF scheduler
556 * @p: task to initialize for BPF scheduling534 * @p: task to initialize for BPF scheduling
@@ -841,6 +819,38 @@ struct sched_ext_ops { · 284 unmodified lines
841 819
842 /* internal use only, must be NULL */820 /* internal use only, must be NULL */
843 void __rcu *priv;821 void __rcu *priv;
822
823 /*
824 * Deprecated callbacks. Kept at the end of the struct so the cid-form
825 * struct (sched_ext_ops_cid) can omit them without affecting the
826 * shared field offsets. Use SCX_ENQ_IMMED instead. Sitting past
827 * SCX_OPI_END means has_op doesn't cover them, so SCX_HAS_OP() cannot
828 * be used; callers must test sch->ops.cpu_acquire / cpu_release
829 * directly.
830 */
831
832 /**
833 * @cpu_acquire: A CPU is becoming available to the BPF scheduler
834 * @cpu: The CPU being acquired by the BPF scheduler.
835 * @args: Acquire arguments, see the struct definition.
836 *
837 * A CPU that was previously released from the BPF scheduler is now once
838 * again under its control. Deprecated; use SCX_ENQ_IMMED instead.
839 */
840 void (*cpu_acquire)(s32 cpu, struct scx_cpu_acquire_args *args);
841
842 /**
843 * @cpu_release: A CPU is taken away from the BPF scheduler
844 * @cpu: The CPU being released by the BPF scheduler.
845 * @args: Release arguments, see the struct definition.
846 *
847 * The specified CPU is no longer under the control of the BPF
848 * scheduler. This could be because it was preempted by a higher
849 * priority sched_class, though there may be other reasons as well. The
850 * caller should consult @args->reason to determine the cause.
851 * Deprecated; use SCX_ENQ_IMMED instead.
852 */
853 void (*cpu_release)(s32 cpu, struct scx_cpu_release_args *args);
844};854};
845 855
846enum scx_opi {856enum scx_opi {