public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: Optimize branch hint in context_switch()
@ 2009-11-29 12:01 Tim Blechmann
  2009-11-29 15:12 ` Avi Kivity
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Blechmann @ 2009-11-29 12:01 UTC (permalink / raw)
  To: Peter Zijlstra, linux-kernel, Peter Zijlstra, Ingo Molnar,
	Thomas Gleixner


[-- Attachment #1.1: Type: text/plain, Size: 385 bytes --]


Branch hint profiling on my nehalem machine showed 88%
incorrect branch hints:

42017484 326957902  88 context_switch                 sched.c              3043
42038493 326953687  88 context_switch                 sched.c              3050

Signed-off-by: Tim Blechmann <tim@klingt.org>
---
 kernel/sched.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-sched-Optimize-branch-hint-in-context_switch.patch --]
[-- Type: text/x-patch; name="0001-sched-Optimize-branch-hint-in-context_switch.patch", Size: 553 bytes --]

diff --git a/kernel/sched.c b/kernel/sched.c
index 2a78b38..c78dcfe 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3040,14 +3040,14 @@ context_switch(struct rq *rq, struct task_struct *prev,
 	 */
 	arch_start_context_switch(prev);
 
-	if (likely(!mm)) {
+	if (unlikely(!mm)) {
 		next->active_mm = oldmm;
 		atomic_inc(&oldmm->mm_count);
 		enter_lazy_tlb(oldmm, next);
 	} else
 		switch_mm(oldmm, mm, next);
 
-	if (likely(!prev->mm)) {
+	if (unlikely(!prev->mm)) {
 		prev->active_mm = NULL;
 		rq->prev_mm = oldmm;
 	}


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-30  9:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-29 12:01 [PATCH] sched: Optimize branch hint in context_switch() Tim Blechmann
2009-11-29 15:12 ` Avi Kivity
2009-11-29 15:20   ` Peter Zijlstra
2009-11-29 15:25     ` Avi Kivity
2009-11-29 16:02       ` Tim Blechmann
2009-11-30  9:25       ` Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox