Re: [tip:sched/core] sched, x86: Optimize branch hint in __switch_to()

From: Brian Gerst
Date: Tue Nov 24 2009 - 12:28:45 EST


On Tue, Nov 24, 2009 at 11:57 AM, tip-bot for Tim Blechmann
<tim@xxxxxxxxxx> wrote:
> Commit-ID: Âa3a1de0c34de6f5f8332cd6151c46af7813c0fcb
> Gitweb: Â Â http://git.kernel.org/tip/a3a1de0c34de6f5f8332cd6151c46af7813c0fcb
> Author: Â Â Tim Blechmann <tim@xxxxxxxxxx>
> AuthorDate: Tue, 24 Nov 2009 11:55:15 +0100
> Committer: ÂIngo Molnar <mingo@xxxxxxx>
> CommitDate: Tue, 24 Nov 2009 12:20:04 +0100
>
> sched, x86: Optimize branch hint in __switch_to()
>
> Branch hint profiling on my nehalem machine showed 96%
> incorrect branch hints:
>
> Â6548732 174664120 Â96 __switch_to          Âprocess_64.c
> Â Â406
> Â6548745 174565593 Â96 __switch_to          Âprocess_64.c
> Â Â410
>
> Signed-off-by: Tim Blechmann <tim@xxxxxxxxxx>
> Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Cc: Mike Galbraith <efault@xxxxxx>
> Cc: Paul Mackerras <paulus@xxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> LKML-Reference: <4B0BBB93.3080307@xxxxxxxxxx>
> Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
> ---
> Âarch/x86/kernel/process_64.c | Â Â5 ++---
> Â1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> index ad535b6..d9db104 100644
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -406,11 +406,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
> Â Â Â Â * This won't pick up thread selector changes, but I guess that is ok.
> Â Â Â Â */
> Â Â Â Âsavesegment(es, prev->es);
> - Â Â Â if (unlikely(next->es | prev->es))
> + Â Â Â if (next->es | prev->es)
> Â Â Â Â Â Â Â Âloadsegment(es, next->es);
> -
> Â Â Â Âsavesegment(ds, prev->ds);
> - Â Â Â if (unlikely(next->ds | prev->ds))
> + Â Â Â if (next->ds | prev->ds)
> Â Â Â Â Â Â Â Âloadsegment(ds, next->ds);
>
>

64-bit tasks should have %ds and %es set to null selectors. The only
time they should be different is for 32-bit tasks. It lookx like some
versions of GCC just aren't using the hint. I've tested it with 4.4.2
and the generated assembly is the same with or without the hint.

--
Brian Gerst
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/