Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched: Remove branch hints within context_switch()

With 710390d9 "sched: Optimize branch hint in context_switch()"
the branch hint logic within context_switch() got inversed.

In fact the hints "if (likely(!mm))" and "if (likely(!prev->mm))"
mean that it is likely that the previous and next task are kernel
threads.

That assumption is certainly counter intuitive, but Tim has shown
that at least with his workload this is true. Nevertheless the
truth is: it depends on the current workload. So just remove the
annotations which also improves readability.

Reported-by: Tim Blechmann <tim@klingt.org>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <20100916124225.GA2209@osiris.boeblingen.de.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Heiko Carstens and committed by
Ingo Molnar
31915ab4 7740191c

+2 -2
+2 -2
kernel/sched.c
··· 2845 2845 */ 2846 2846 arch_start_context_switch(prev); 2847 2847 2848 - if (likely(!mm)) { 2848 + if (!mm) { 2849 2849 next->active_mm = oldmm; 2850 2850 atomic_inc(&oldmm->mm_count); 2851 2851 enter_lazy_tlb(oldmm, next); 2852 2852 } else 2853 2853 switch_mm(oldmm, mm, next); 2854 2854 2855 - if (likely(!prev->mm)) { 2855 + if (!prev->mm) { 2856 2856 prev->active_mm = NULL; 2857 2857 rq->prev_mm = oldmm; 2858 2858 }