aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2007-10-15 11:00:19 -0400
committerIngo Molnar <mingo@elte.hu>2007-10-15 11:00:19 -0400
commit71e20f1873d46e138c26ce83f8fe54b7221f572f (patch)
tree3b5c5083d3ffcf7c9d7ddad81acf30c09197ef99
parentd172fcd3ae1ca7ac27ec8904242fd61e0e11d332 (diff)
sched: affine sync wakeups
make sync wakeups affine for cache-cold tasks: if a cache-cold task is woken up by a sync wakeup then use the opportunity to migrate it straight away. (the two tasks are 'related' because they communicate) Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--fs/pipe.c6
-rw-r--r--kernel/sched.c8
-rw-r--r--net/unix/af_unix.c4
3 files changed, 12 insertions, 6 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index f1fa2b412f0e..e66ec48e95d8 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -382,7 +382,7 @@ redo:
382 382
383 /* Signal writers asynchronously that there is more room. */ 383 /* Signal writers asynchronously that there is more room. */
384 if (do_wakeup) { 384 if (do_wakeup) {
385 wake_up_interruptible(&pipe->wait); 385 wake_up_interruptible_sync(&pipe->wait);
386 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); 386 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
387 } 387 }
388 if (ret > 0) 388 if (ret > 0)
@@ -555,7 +555,7 @@ redo2:
555out: 555out:
556 mutex_unlock(&inode->i_mutex); 556 mutex_unlock(&inode->i_mutex);
557 if (do_wakeup) { 557 if (do_wakeup) {
558 wake_up_interruptible(&pipe->wait); 558 wake_up_interruptible_sync(&pipe->wait);
559 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); 559 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
560 } 560 }
561 if (ret > 0) 561 if (ret > 0)
@@ -649,7 +649,7 @@ pipe_release(struct inode *inode, int decr, int decw)
649 if (!pipe->readers && !pipe->writers) { 649 if (!pipe->readers && !pipe->writers) {
650 free_pipe_info(inode); 650 free_pipe_info(inode);
651 } else { 651 } else {
652 wake_up_interruptible(&pipe->wait); 652 wake_up_interruptible_sync(&pipe->wait);
653 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); 653 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
654 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); 654 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
655 } 655 }
diff --git a/kernel/sched.c b/kernel/sched.c
index 5a91fe0b5de6..7fd343462597 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1521,6 +1521,12 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
1521 unsigned long tl = this_load; 1521 unsigned long tl = this_load;
1522 unsigned long tl_per_task; 1522 unsigned long tl_per_task;
1523 1523
1524 /*
1525 * Attract cache-cold tasks on sync wakeups:
1526 */
1527 if (sync && !task_hot(p, rq->clock, this_sd))
1528 goto out_set_cpu;
1529
1524 schedstat_inc(p, se.nr_wakeups_affine_attempts); 1530 schedstat_inc(p, se.nr_wakeups_affine_attempts);
1525 tl_per_task = cpu_avg_load_per_task(this_cpu); 1531 tl_per_task = cpu_avg_load_per_task(this_cpu);
1526 1532
@@ -1598,7 +1604,7 @@ out_activate:
1598 * the waker guarantees that the freshly woken up task is going 1604 * the waker guarantees that the freshly woken up task is going
1599 * to be considered on this CPU.) 1605 * to be considered on this CPU.)
1600 */ 1606 */
1601 if (!sync || cpu != this_cpu) 1607 if (!sync || rq->curr == rq->idle)
1602 check_preempt_curr(rq, p); 1608 check_preempt_curr(rq, p);
1603 success = 1; 1609 success = 1;
1604 1610
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 2b57eaf66abc..6996cba5aa96 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -334,7 +334,7 @@ static void unix_write_space(struct sock *sk)
334 read_lock(&sk->sk_callback_lock); 334 read_lock(&sk->sk_callback_lock);
335 if (unix_writable(sk)) { 335 if (unix_writable(sk)) {
336 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 336 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
337 wake_up_interruptible(sk->sk_sleep); 337 wake_up_interruptible_sync(sk->sk_sleep);
338 sk_wake_async(sk, 2, POLL_OUT); 338 sk_wake_async(sk, 2, POLL_OUT);
339 } 339 }
340 read_unlock(&sk->sk_callback_lock); 340 read_unlock(&sk->sk_callback_lock);
@@ -1639,7 +1639,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
1639 if (!skb) 1639 if (!skb)
1640 goto out_unlock; 1640 goto out_unlock;
1641 1641
1642 wake_up_interruptible(&u->peer_wait); 1642 wake_up_interruptible_sync(&u->peer_wait);
1643 1643
1644 if (msg->msg_name) 1644 if (msg->msg_name)
1645 unix_copy_addr(msg, skb->sk); 1645 unix_copy_addr(msg, skb->sk);