Skip to content

Commit

Permalink
[PATCH] sched: ->task_new cleanup
Browse files Browse the repository at this point in the history
make sched_class.task_new == NULL a 'default method', this
allows the removal of task_rt_new.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed Aug 2, 2007
1 parent 4e6f96f commit cad60d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ struct sched_class {

void (*set_curr_task) (struct rq *rq);
void (*task_tick) (struct rq *rq, struct task_struct *p);
void (*task_new) (struct rq *rq, struct task_struct *p);
void (*task_new) (struct rq *rq, struct task_struct *p, u64 now);
};

struct load_weight {
Expand Down
11 changes: 8 additions & 3 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1641,22 +1641,27 @@ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
unsigned long flags;
struct rq *rq;
int this_cpu;
u64 now;

rq = task_rq_lock(p, &flags);
BUG_ON(p->state != TASK_RUNNING);
this_cpu = smp_processor_id(); /* parent's CPU */
now = rq_clock(rq);

p->prio = effective_prio(p);

if (!sysctl_sched_child_runs_first || (clone_flags & CLONE_VM) ||
task_cpu(p) != this_cpu || !current->se.on_rq) {
if (!p->sched_class->task_new || !sysctl_sched_child_runs_first ||
(clone_flags & CLONE_VM) || task_cpu(p) != this_cpu ||
!current->se.on_rq) {

activate_task(rq, p, 0);
} else {
/*
* Let the scheduling class do new task startup
* management (if any):
*/
p->sched_class->task_new(rq, p);
p->sched_class->task_new(rq, p, now);
inc_nr_running(p, rq, now);
}
check_preempt_curr(rq, p);
task_rq_unlock(rq, &flags);
Expand Down
4 changes: 1 addition & 3 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,10 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr)
* monopolize the CPU. Note: the parent runqueue is locked,
* the child is not running yet.
*/
static void task_new_fair(struct rq *rq, struct task_struct *p)
static void task_new_fair(struct rq *rq, struct task_struct *p, u64 now)
{
struct cfs_rq *cfs_rq = task_cfs_rq(p);
struct sched_entity *se = &p->se;
u64 now = rq_clock(rq);

sched_info_queued(p);

Expand All @@ -1072,7 +1071,6 @@ static void task_new_fair(struct rq *rq, struct task_struct *p)
p->se.wait_runtime = -(sysctl_sched_granularity / 2);

__enqueue_entity(cfs_rq, se);
inc_nr_running(p, rq, now);
}

#ifdef CONFIG_FAIR_GROUP_SCHED
Expand Down
10 changes: 0 additions & 10 deletions kernel/sched_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,6 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p)
requeue_task_rt(rq, p);
}

/*
* No parent/child timeslice management necessary for RT tasks,
* just activate them:
*/
static void task_new_rt(struct rq *rq, struct task_struct *p)
{
activate_task(rq, p, 1);
}

static struct sched_class rt_sched_class __read_mostly = {
.enqueue_task = enqueue_task_rt,
.dequeue_task = dequeue_task_rt,
Expand All @@ -251,5 +242,4 @@ static struct sched_class rt_sched_class __read_mostly = {
.load_balance = load_balance_rt,

.task_tick = task_tick_rt,
.task_new = task_new_rt,
};

0 comments on commit cad60d9

Please sign in to comment.