Skip to content

Commit a8e4f2e

Browse files
Peter ZijlstraIngo Molnar
Peter Zijlstra
authored and
Ingo Molnar
committed
sched: Delay task_contributes_to_load()
In prepratation of having to call task_contributes_to_load() without holding rq->lock, we need to store the result until we do and can update the rq accounting accordingly. Reviewed-by: Frank Rowand <frank.rowand@am.sony.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20110405152729.151523907@chello.nl
1 parent 3fe1698 commit a8e4f2e

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

include/linux/sched.h

+1
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ struct task_struct {
12731273

12741274
/* Revert to default priority/policy when forking */
12751275
unsigned sched_reset_on_fork:1;
1276+
unsigned sched_contributes_to_load:1;
12761277

12771278
pid_t pid;
12781279
pid_t tgid;

kernel/sched.c

+4-12
Original file line numberDiff line numberDiff line change
@@ -2519,18 +2519,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state,
25192519
if (unlikely(task_running(rq, p)))
25202520
goto out_activate;
25212521

2522-
/*
2523-
* In order to handle concurrent wakeups and release the rq->lock
2524-
* we put the task in TASK_WAKING state.
2525-
*
2526-
* First fix up the nr_uninterruptible count:
2527-
*/
2528-
if (task_contributes_to_load(p)) {
2529-
if (likely(cpu_online(orig_cpu)))
2530-
rq->nr_uninterruptible--;
2531-
else
2532-
this_rq()->nr_uninterruptible--;
2533-
}
2522+
p->sched_contributes_to_load = !!task_contributes_to_load(p);
25342523
p->state = TASK_WAKING;
25352524

25362525
if (p->sched_class->task_waking) {
@@ -2555,6 +2544,9 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state,
25552544
WARN_ON(task_cpu(p) != cpu);
25562545
WARN_ON(p->state != TASK_WAKING);
25572546

2547+
if (p->sched_contributes_to_load)
2548+
rq->nr_uninterruptible--;
2549+
25582550
out_activate:
25592551
#endif /* CONFIG_SMP */
25602552
ttwu_activate(rq, p, en_flags);

0 commit comments

Comments
 (0)