Skip to content

Commit

Permalink
sched/deadline: Avoid pointless __setscheduler()
Browse files Browse the repository at this point in the history
There is no need to dequeue/enqueue and push/pull if there are
no scheduling parameters changed for the DL class.

Both fair and RT classes already check if parameters changed for
them to avoid unnecessary overhead. This patch add the parameters
changed test for the DL class in order to reduce overhead.

Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
[ Fixed up the changelog. ]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@arm.com>
Cc: Kirill Tkhai <ktkhai@parallels.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1416962647-76792-5-git-send-email-wanpeng.li@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Wanpeng Li authored and Ingo Molnar committed Feb 4, 2015
1 parent 1019a35 commit 7538160
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3417,6 +3417,20 @@ static bool check_same_owner(struct task_struct *p)
return match;
}

static bool dl_param_changed(struct task_struct *p,
const struct sched_attr *attr)
{
struct sched_dl_entity *dl_se = &p->dl;

if (dl_se->dl_runtime != attr->sched_runtime ||
dl_se->dl_deadline != attr->sched_deadline ||
dl_se->dl_period != attr->sched_period ||
dl_se->flags != attr->sched_flags)
return true;

return false;
}

static int __sched_setscheduler(struct task_struct *p,
const struct sched_attr *attr,
bool user)
Expand Down Expand Up @@ -3545,7 +3559,7 @@ static int __sched_setscheduler(struct task_struct *p,
goto change;
if (rt_policy(policy) && attr->sched_priority != p->rt_priority)
goto change;
if (dl_policy(policy))
if (dl_policy(policy) && dl_param_changed(p, attr))
goto change;

p->sched_reset_on_fork = reset_on_fork;
Expand Down

0 comments on commit 7538160

Please sign in to comment.