Skip to content

Commit 01d36d0

Browse files
committed
sched: Account rr tasks
In order to evaluate the scheduler tick dependency without probing context switches, we need to know how much SCHED_RR and SCHED_FIFO tasks are enqueued as those policies don't have the same preemption requirements. To prepare for that, let's account SCHED_RR tasks, we'll be able to deduce SCHED_FIFO tasks as well from it and the total RT tasks in the runqueue. Reviewed-by: Chris Metcalf <cmetcalf@ezchip.com> Cc: Christoph Lameter <cl@linux.com> Cc: Chris Metcalf <cmetcalf@ezchip.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
1 parent 555e0c1 commit 01d36d0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

kernel/sched/rt.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,13 +1141,28 @@ unsigned int rt_se_nr_running(struct sched_rt_entity *rt_se)
11411141
return 1;
11421142
}
11431143

1144+
static inline
1145+
unsigned int rt_se_rr_nr_running(struct sched_rt_entity *rt_se)
1146+
{
1147+
struct rt_rq *group_rq = group_rt_rq(rt_se);
1148+
struct task_struct *tsk;
1149+
1150+
if (group_rq)
1151+
return group_rq->rr_nr_running;
1152+
1153+
tsk = rt_task_of(rt_se);
1154+
1155+
return (tsk->policy == SCHED_RR) ? 1 : 0;
1156+
}
1157+
11441158
static inline
11451159
void inc_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
11461160
{
11471161
int prio = rt_se_prio(rt_se);
11481162

11491163
WARN_ON(!rt_prio(prio));
11501164
rt_rq->rt_nr_running += rt_se_nr_running(rt_se);
1165+
rt_rq->rr_nr_running += rt_se_rr_nr_running(rt_se);
11511166

11521167
inc_rt_prio(rt_rq, prio);
11531168
inc_rt_migration(rt_se, rt_rq);
@@ -1160,6 +1175,7 @@ void dec_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
11601175
WARN_ON(!rt_prio(rt_se_prio(rt_se)));
11611176
WARN_ON(!rt_rq->rt_nr_running);
11621177
rt_rq->rt_nr_running -= rt_se_nr_running(rt_se);
1178+
rt_rq->rr_nr_running -= rt_se_rr_nr_running(rt_se);
11631179

11641180
dec_rt_prio(rt_rq, rt_se_prio(rt_se));
11651181
dec_rt_migration(rt_se, rt_rq);

kernel/sched/sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ static inline int rt_bandwidth_enabled(void)
450450
struct rt_rq {
451451
struct rt_prio_array active;
452452
unsigned int rt_nr_running;
453+
unsigned int rr_nr_running;
453454
#if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED
454455
struct {
455456
int curr; /* highest queued rt task prio */

0 commit comments

Comments
 (0)