Skip to content

Commit 0b1777f

Browse files
committed
Merge branch 'tip/sched/core' into sched_ext/for-6.12
Pull in tip/sched/core to resolve two merge conflicts: - 96fd6c6 ("sched: Factor out update_other_load_avgs() from __update_blocked_others()") 5d871a6 ("sched/fair: Move effective_cpu_util() and effective_cpu_util() in fair.c") A simple context conflict. The former added __update_blocked_others() in the same #ifdef CONFIG_SMP block that effective_cpu_util() and sched_cpu_util() are in and the latter moved those functions to fair.c. This makes __update_blocked_others() more out of place. Will follow up with a patch to relocate. - 96fd6c6 ("sched: Factor out update_other_load_avgs() from __update_blocked_others()") 84d2652 ("sched/pelt: Use rq_clock_task() for hw_pressure") The former factored out the body of __update_blocked_others() into update_other_load_avgs(). The latter changed how update_hw_load_avg() is called in the body. Resolved by applying the change to update_other_load_avgs() instead. Signed-off-by: Tejun Heo <[email protected]>
2 parents 513ed0c + bc9057d commit 0b1777f

File tree

9 files changed

+189
-152
lines changed

9 files changed

+189
-152
lines changed

Documentation/scheduler/sched-deadline.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -749,21 +749,19 @@ Appendix A. Test suite
749749
of the command line options. Please refer to rt-app documentation for more
750750
details (`<rt-app-sources>/doc/*.json`).
751751

752-
The second testing application is a modification of schedtool, called
753-
schedtool-dl, which can be used to setup SCHED_DEADLINE parameters for a
754-
certain pid/application. schedtool-dl is available at:
755-
https://github.com/scheduler-tools/schedtool-dl.git.
752+
The second testing application is done using chrt which has support
753+
for SCHED_DEADLINE.
756754

757755
The usage is straightforward::
758756

759-
# schedtool -E -t 10000000:100000000 -e ./my_cpuhog_app
757+
# chrt -d -T 10000000 -D 100000000 0 ./my_cpuhog_app
760758

761759
With this, my_cpuhog_app is put to run inside a SCHED_DEADLINE reservation
762-
of 10ms every 100ms (note that parameters are expressed in microseconds).
763-
You can also use schedtool to create a reservation for an already running
760+
of 10ms every 100ms (note that parameters are expressed in nanoseconds).
761+
You can also use chrt to create a reservation for an already running
764762
application, given that you know its pid::
765763

766-
# schedtool -E -t 10000000:100000000 my_app_pid
764+
# chrt -d -T 10000000 -D 100000000 -p 0 my_app_pid
767765

768766
Appendix B. Minimal main()
769767
==========================

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ static void __init cppc_freq_invariance_init(void)
224224
* Fake (unused) bandwidth; workaround to "fix"
225225
* priority inheritance.
226226
*/
227-
.sched_runtime = 1000000,
228-
.sched_deadline = 10000000,
229-
.sched_period = 10000000,
227+
.sched_runtime = NSEC_PER_MSEC,
228+
.sched_deadline = 10 * NSEC_PER_MSEC,
229+
.sched_period = 10 * NSEC_PER_MSEC,
230230
};
231231
int ret;
232232

include/uapi/linux/sched/types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
*
5959
* This is reflected by the following fields of the sched_attr structure:
6060
*
61-
* @sched_deadline representative of the task's deadline
62-
* @sched_runtime representative of the task's runtime
63-
* @sched_period representative of the task's period
61+
* @sched_deadline representative of the task's deadline in nanoseconds
62+
* @sched_runtime representative of the task's runtime in nanoseconds
63+
* @sched_period representative of the task's period in nanoseconds
6464
*
6565
* Given this task model, there are a multiplicity of scheduling algorithms
6666
* and policies, that can be used to ensure all the tasks will make their

kernel/kthread.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,16 @@ int kthread_worker_fn(void *worker_ptr)
845845
* event only cares about the address.
846846
*/
847847
trace_sched_kthread_work_execute_end(work, func);
848-
} else if (!freezing(current))
848+
} else if (!freezing(current)) {
849849
schedule();
850+
} else {
851+
/*
852+
* Handle the case where the current remains
853+
* TASK_INTERRUPTIBLE. try_to_freeze() expects
854+
* the current to be TASK_RUNNING.
855+
*/
856+
__set_current_state(TASK_RUNNING);
857+
}
850858

851859
try_to_freeze();
852860
cond_resched();

kernel/sched/core.c

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ static inline int rb_sched_core_cmp(const void *key, const struct rb_node *node)
267267

268268
void sched_core_enqueue(struct rq *rq, struct task_struct *p)
269269
{
270+
if (p->se.sched_delayed)
271+
return;
272+
270273
rq->core->core_task_seq++;
271274

272275
if (!p->core_cookie)
@@ -277,6 +280,9 @@ void sched_core_enqueue(struct rq *rq, struct task_struct *p)
277280

278281
void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags)
279282
{
283+
if (p->se.sched_delayed)
284+
return;
285+
280286
rq->core->core_task_seq++;
281287

282288
if (sched_core_enqueued(p)) {
@@ -6477,19 +6483,12 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
64776483
* Constants for the sched_mode argument of __schedule().
64786484
*
64796485
* The mode argument allows RT enabled kernels to differentiate a
6480-
* preemption from blocking on an 'sleeping' spin/rwlock. Note that
6481-
* SM_MASK_PREEMPT for !RT has all bits set, which allows the compiler to
6482-
* optimize the AND operation out and just check for zero.
6486+
* preemption from blocking on an 'sleeping' spin/rwlock.
64836487
*/
6484-
#define SM_NONE 0x0
6485-
#define SM_PREEMPT 0x1
6486-
#define SM_RTLOCK_WAIT 0x2
6487-
6488-
#ifndef CONFIG_PREEMPT_RT
6489-
# define SM_MASK_PREEMPT (~0U)
6490-
#else
6491-
# define SM_MASK_PREEMPT SM_PREEMPT
6492-
#endif
6488+
#define SM_IDLE (-1)
6489+
#define SM_NONE 0
6490+
#define SM_PREEMPT 1
6491+
#define SM_RTLOCK_WAIT 2
64936492

64946493
/*
64956494
* __schedule() is the main scheduler function.
@@ -6530,9 +6529,14 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
65306529
*
65316530
* WARNING: must be called with preemption disabled!
65326531
*/
6533-
static void __sched notrace __schedule(unsigned int sched_mode)
6532+
static void __sched notrace __schedule(int sched_mode)
65346533
{
65356534
struct task_struct *prev, *next;
6535+
/*
6536+
* On PREEMPT_RT kernel, SM_RTLOCK_WAIT is noted
6537+
* as a preemption by schedule_debug() and RCU.
6538+
*/
6539+
bool preempt = sched_mode > SM_NONE;
65366540
unsigned long *switch_count;
65376541
unsigned long prev_state;
65386542
struct rq_flags rf;
@@ -6543,13 +6547,13 @@ static void __sched notrace __schedule(unsigned int sched_mode)
65436547
rq = cpu_rq(cpu);
65446548
prev = rq->curr;
65456549

6546-
schedule_debug(prev, !!sched_mode);
6550+
schedule_debug(prev, preempt);
65476551

65486552
if (sched_feat(HRTICK) || sched_feat(HRTICK_DL))
65496553
hrtick_clear(rq);
65506554

65516555
local_irq_disable();
6552-
rcu_note_context_switch(!!sched_mode);
6556+
rcu_note_context_switch(preempt);
65536557

65546558
/*
65556559
* Make sure that signal_pending_state()->signal_pending() below
@@ -6578,12 +6582,20 @@ static void __sched notrace __schedule(unsigned int sched_mode)
65786582

65796583
switch_count = &prev->nivcsw;
65806584

6585+
/* Task state changes only considers SM_PREEMPT as preemption */
6586+
preempt = sched_mode == SM_PREEMPT;
6587+
65816588
/*
65826589
* We must load prev->state once (task_struct::state is volatile), such
65836590
* that we form a control dependency vs deactivate_task() below.
65846591
*/
65856592
prev_state = READ_ONCE(prev->__state);
6586-
if (!(sched_mode & SM_MASK_PREEMPT) && prev_state) {
6593+
if (sched_mode == SM_IDLE) {
6594+
if (!rq->nr_running) {
6595+
next = prev;
6596+
goto picked;
6597+
}
6598+
} else if (!preempt && prev_state) {
65876599
if (signal_pending_state(prev_state, prev)) {
65886600
WRITE_ONCE(prev->__state, TASK_RUNNING);
65896601
} else {
@@ -6614,6 +6626,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
66146626
}
66156627

66166628
next = pick_next_task(rq, prev, &rf);
6629+
picked:
66176630
clear_tsk_need_resched(prev);
66186631
clear_preempt_need_resched();
66196632
#ifdef CONFIG_SCHED_DEBUG
@@ -6655,7 +6668,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
66556668
psi_account_irqtime(rq, prev, next);
66566669
psi_sched_switch(prev, next, !task_on_rq_queued(prev));
66576670

6658-
trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev, next, prev_state);
6671+
trace_sched_switch(preempt, prev, next, prev_state);
66596672

66606673
/* Also unlocks the rq: */
66616674
rq = context_switch(rq, prev, next, &rf);
@@ -6731,7 +6744,7 @@ static void sched_update_worker(struct task_struct *tsk)
67316744
}
67326745
}
67336746

6734-
static __always_inline void __schedule_loop(unsigned int sched_mode)
6747+
static __always_inline void __schedule_loop(int sched_mode)
67356748
{
67366749
do {
67376750
preempt_disable();
@@ -6776,7 +6789,7 @@ void __sched schedule_idle(void)
67766789
*/
67776790
WARN_ON_ONCE(current->__state);
67786791
do {
6779-
__schedule(SM_NONE);
6792+
__schedule(SM_IDLE);
67806793
} while (need_resched());
67816794
}
67826795

kernel/sched/cpufreq_schedutil.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
662662
* Fake (unused) bandwidth; workaround to "fix"
663663
* priority inheritance.
664664
*/
665-
.sched_runtime = 1000000,
666-
.sched_deadline = 10000000,
667-
.sched_period = 10000000,
665+
.sched_runtime = NSEC_PER_MSEC,
666+
.sched_deadline = 10 * NSEC_PER_MSEC,
667+
.sched_period = 10 * NSEC_PER_MSEC,
668668
};
669669
struct cpufreq_policy *policy = sg_policy->policy;
670670
int ret;

kernel/sched/debug.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
739739
else
740740
SEQ_printf(m, " %c", task_state_to_char(p));
741741

742-
SEQ_printf(m, "%15s %5d %9Ld.%06ld %c %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
742+
SEQ_printf(m, " %15s %5d %9Ld.%06ld %c %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
743743
p->comm, task_pid_nr(p),
744744
SPLIT_NS(p->se.vruntime),
745745
entity_eligible(cfs_rq_of(&p->se), &p->se) ? 'E' : 'N',
@@ -750,17 +750,16 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
750750
(long long)(p->nvcsw + p->nivcsw),
751751
p->prio);
752752

753-
SEQ_printf(m, "%9lld.%06ld %9lld.%06ld %9lld.%06ld %9lld.%06ld",
753+
SEQ_printf(m, "%9lld.%06ld %9lld.%06ld %9lld.%06ld",
754754
SPLIT_NS(schedstat_val_or_zero(p->stats.wait_sum)),
755-
SPLIT_NS(p->se.sum_exec_runtime),
756755
SPLIT_NS(schedstat_val_or_zero(p->stats.sum_sleep_runtime)),
757756
SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime)));
758757

759758
#ifdef CONFIG_NUMA_BALANCING
760-
SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
759+
SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
761760
#endif
762761
#ifdef CONFIG_CGROUP_SCHED
763-
SEQ_printf_task_group_path(m, task_group(p), " %s")
762+
SEQ_printf_task_group_path(m, task_group(p), " %s")
764763
#endif
765764

766765
SEQ_printf(m, "\n");
@@ -772,10 +771,26 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
772771

773772
SEQ_printf(m, "\n");
774773
SEQ_printf(m, "runnable tasks:\n");
775-
SEQ_printf(m, " S task PID tree-key switches prio"
776-
" wait-time sum-exec sum-sleep\n");
774+
SEQ_printf(m, " S task PID vruntime eligible "
775+
"deadline slice sum-exec switches "
776+
"prio wait-time sum-sleep sum-block"
777+
#ifdef CONFIG_NUMA_BALANCING
778+
" node group-id"
779+
#endif
780+
#ifdef CONFIG_CGROUP_SCHED
781+
" group-path"
782+
#endif
783+
"\n");
777784
SEQ_printf(m, "-------------------------------------------------------"
778-
"------------------------------------------------------\n");
785+
"------------------------------------------------------"
786+
"------------------------------------------------------"
787+
#ifdef CONFIG_NUMA_BALANCING
788+
"--------------"
789+
#endif
790+
#ifdef CONFIG_CGROUP_SCHED
791+
"--------------"
792+
#endif
793+
"\n");
779794

780795
rcu_read_lock();
781796
for_each_process_thread(g, p) {

0 commit comments

Comments
 (0)