From: Con Kolivas <kernel@kolivas.org>
To: Andreas Mohr <andi@rhlx01.fht-esslingen.de>
Cc: ck@vds.kolivas.org, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] -mm: Small schedule() optimization
Date: Sat, 11 Mar 2006 12:00:26 +1100 [thread overview]
Message-ID: <200603111200.27557.kernel@kolivas.org> (raw)
In-Reply-To: <20060308175450.GA28763@rhlx01.fht-esslingen.de>
cc'ed Ingo since he's maintainer.
On Thursday 09 March 2006 04:54, Andreas Mohr wrote:
> Hello all,
>
> I found that there's a possible small optimization right at the very
> beginning of schedule():
>
> if (likely(!current->exit_state)) {
> if (unlikely(in_atomic())) {
>
> can be reversed into
>
> if (unlikely(in_atomic())) {
> if (likely(!current->exit_state)) {
>
> This is a Good Thing since it avoids having to evaluate both checks,
> and both use current_thread_info() which has an inherent AGI stall risk on
> x86 CPUs if it cannot be inter-mingled with other unrelated opcodes.
>
> I'm a bit puzzled that this has not been done like that before.
> Probably since the exit_state check got added as an after-thought...
> Or did I miss some important reason here? (branch prediction??)
This looks good. See below.
> Patch against 2.6.16-rc5-mm3.
>
> Thanks!
>
> Signed-off-by: Andreas Mohr <andi@lisas.de>
>
>
> --- linux-2.6.16-rc5-mm3/kernel/sched.c.orig 2006-03-08 18:36:58.000000000
> +0100 +++ linux-2.6.16-rc5-mm3/kernel/sched.c 2006-03-08 18:39:55.000000000
> +0100 @@ -3022,8 +3022,8 @@
> * schedule() atomically, we ignore that path for now.
> * Otherwise, whine if we are scheduling when we should not be.
> */
> - if (likely(!current->exit_state)) {
> - if (unlikely(in_atomic())) {
> + if (unlikely(in_atomic())) {
> + if (likely(!current->exit_state)) {
I suspect that once we're in_atomic() then we're no longer likely to
be !current->exit_state
Probably better to just
if (unlikely(in_atomic())) {
if (!current->exit_state) {
Ingo?
Cheers,
Con
next prev parent reply other threads:[~2006-03-11 1:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-08 17:54 [PATCH] -mm: Small schedule() optimization Andreas Mohr
2006-03-11 1:00 ` Con Kolivas [this message]
2006-03-17 9:13 ` Ingo Molnar
2006-03-17 9:52 ` [ck] " Andreas Mohr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200603111200.27557.kernel@kolivas.org \
--to=kernel@kolivas.org \
--cc=akpm@osdl.org \
--cc=andi@rhlx01.fht-esslingen.de \
--cc=ck@vds.kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox