Blame view
kernel/sched/stop_task.c
3.15 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
34f971f6f sched: Create spe... |
2 3 4 5 6 7 8 9 |
/* * stop-task scheduling class. * * The stop task is the highest priority task in the system, it preempts * everything and will be preempted by nothing. * * See kernel/stop_machine.c */ |
97fb7a0a8 sched: Clean up a... |
10 |
#include "sched.h" |
34f971f6f sched: Create spe... |
11 12 13 |
#ifdef CONFIG_SMP static int |
ac66f5477 sched/numa: Intro... |
14 |
select_task_rq_stop(struct task_struct *p, int cpu, int sd_flag, int flags) |
34f971f6f sched: Create spe... |
15 16 17 |
{ return task_cpu(p); /* stop tasks as never migrate */ } |
6e2df0581 sched: Fix pick_n... |
18 19 20 21 22 23 |
static int balance_stop(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) { return sched_stop_runnable(rq); } |
34f971f6f sched: Create spe... |
24 25 26 27 28 |
#endif /* CONFIG_SMP */ static void check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags) { |
1e5a74059 sched: Fix cross-... |
29 |
/* we're never preempted */ |
34f971f6f sched: Create spe... |
30 |
} |
a0e813f26 sched/core: Furth... |
31 |
static void set_next_task_stop(struct rq *rq, struct task_struct *stop, bool first) |
03b7fad16 sched: Add task_s... |
32 33 34 |
{ stop->se.exec_start = rq_clock_task(rq); } |
98c2f700e sched/core: Simpl... |
35 |
static struct task_struct *pick_next_task_stop(struct rq *rq) |
34f971f6f sched: Create spe... |
36 |
{ |
6e2df0581 sched: Fix pick_n... |
37 |
if (!sched_stop_runnable(rq)) |
606dba2e2 sched: Push put_p... |
38 |
return NULL; |
34f971f6f sched: Create spe... |
39 |
|
a0e813f26 sched/core: Furth... |
40 |
set_next_task_stop(rq, rq->stop, true); |
6e2df0581 sched: Fix pick_n... |
41 |
return rq->stop; |
34f971f6f sched: Create spe... |
42 43 44 45 46 |
} static void enqueue_task_stop(struct rq *rq, struct task_struct *p, int flags) { |
724654478 sched, nohz: Chan... |
47 |
add_nr_running(rq, 1); |
34f971f6f sched: Create spe... |
48 49 50 51 52 |
} static void dequeue_task_stop(struct rq *rq, struct task_struct *p, int flags) { |
724654478 sched, nohz: Chan... |
53 |
sub_nr_running(rq, 1); |
34f971f6f sched: Create spe... |
54 55 56 57 58 59 |
} static void yield_task_stop(struct rq *rq) { BUG(); /* the stop task should never yield, its pointless. */ } |
6e2df0581 sched: Fix pick_n... |
60 |
static void put_prev_task_stop(struct rq *rq, struct task_struct *prev) |
34f971f6f sched: Create spe... |
61 |
{ |
8f6189684 sched: Fix migrat... |
62 63 |
struct task_struct *curr = rq->curr; u64 delta_exec; |
78becc270 sched: Use an acc... |
64 |
delta_exec = rq_clock_task(rq) - curr->se.exec_start; |
8f6189684 sched: Fix migrat... |
65 66 67 68 69 70 71 72 |
if (unlikely((s64)delta_exec < 0)) delta_exec = 0; schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); curr->se.sum_exec_runtime += delta_exec; account_group_exec_runtime(curr, delta_exec); |
78becc270 sched: Use an acc... |
73 |
curr->se.exec_start = rq_clock_task(rq); |
d2cc5ed69 cpuacct: Introduc... |
74 |
cgroup_account_cputime(curr, delta_exec); |
34f971f6f sched: Create spe... |
75 |
} |
d84b31313 sched/isolation: ... |
76 77 78 79 80 81 82 83 |
/* * scheduler tick hitting a task of our scheduling class. * * NOTE: This function can be called remotely by the tick offload that * goes along full dynticks. Therefore no local assumption can be made * and everything must be accessed through the @rq and @curr passed in * parameters. */ |
34f971f6f sched: Create spe... |
84 85 86 |
static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued) { } |
da7a735e5 sched: Fix switch... |
87 |
static void switched_to_stop(struct rq *rq, struct task_struct *p) |
34f971f6f sched: Create spe... |
88 89 90 |
{ BUG(); /* its impossible to change to this class */ } |
da7a735e5 sched: Fix switch... |
91 92 |
static void prio_changed_stop(struct rq *rq, struct task_struct *p, int oldprio) |
34f971f6f sched: Create spe... |
93 94 95 |
{ BUG(); /* how!?, what priority? */ } |
90e362f4a sched: Provide up... |
96 97 98 |
static void update_curr_stop(struct rq *rq) { } |
34f971f6f sched: Create spe... |
99 100 101 |
/* * Simple, special scheduling class for the per-CPU stop tasks: */ |
590d69796 sched: Force the ... |
102 |
const struct sched_class stop_sched_class |
33def8498 treewide: Convert... |
103 |
__section("__stop_sched_class") = { |
34f971f6f sched: Create spe... |
104 105 106 107 108 109 110 111 112 |
.enqueue_task = enqueue_task_stop, .dequeue_task = dequeue_task_stop, .yield_task = yield_task_stop, .check_preempt_curr = check_preempt_curr_stop, .pick_next_task = pick_next_task_stop, .put_prev_task = put_prev_task_stop, |
03b7fad16 sched: Add task_s... |
113 |
.set_next_task = set_next_task_stop, |
34f971f6f sched: Create spe... |
114 115 |
#ifdef CONFIG_SMP |
6e2df0581 sched: Fix pick_n... |
116 |
.balance = balance_stop, |
34f971f6f sched: Create spe... |
117 |
.select_task_rq = select_task_rq_stop, |
c5b280384 sched: Make sched... |
118 |
.set_cpus_allowed = set_cpus_allowed_common, |
34f971f6f sched: Create spe... |
119 |
#endif |
34f971f6f sched: Create spe... |
120 |
.task_tick = task_tick_stop, |
34f971f6f sched: Create spe... |
121 122 |
.prio_changed = prio_changed_stop, .switched_to = switched_to_stop, |
90e362f4a sched: Provide up... |
123 |
.update_curr = update_curr_stop, |
34f971f6f sched: Create spe... |
124 |
}; |