mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: andrew.j.wade@gmail.com
Cc: tim.c.chen@linux.intel.com, herbert@gondor.apana.org.au,
	linux-kernel@vger.kernel.org, leonid.i.ananiev@intel.com
Subject: Re: [PATCH] Fix WARN_ON / WARN_ON_ONCE regression
Date: Wed, 4 Oct 2006 15:06:31 -0700	[thread overview]
Message-ID: <20061004150631.65e8953f.akpm@osdl.org> (raw)
In-Reply-To: <200610041251.26166.ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com>

On Wed, 4 Oct 2006 12:47:00 -0400
Andrew James Wade <andrew.j.wade@gmail.com> wrote:

> On Tuesday 03 October 2006 23:32, Andrew Morton wrote:
> 
> > It might help, but we still don't know what's going on (I think).
> > 
> > I mean, if cache misses against __warn_once were sufficiently high for it
> > to affect performance, then __warn_once would be, err, in cache?
> 
> Yes, of course. I'm embarrassed.
> 
> I took a look at the generated code, and GCC is having difficulty
> optimizing WARN_ON_ONCE. Here is the start of __local_bh_enable:
> 
> 00000130 <__local_bh_enable>:
>  130:   83 ec 10                sub    $0x10,%esp
>  133:   8b 15 04 00 00 00       mov    0x4,%edx         <-+
>  139:   89 e0                   mov    %esp,%eax          |
>  13b:   25 00 e0 ff ff          and    $0xffffe000,%eax   | !!!
>  140:   8b 40 14                mov    0x14(%eax),%eax    |
>  143:   25 00 00 ff 0f          and    $0xfff0000,%eax    |

This is the evaluation of in_irq(): calculate `current', grab
current->thread_info->preempt_count.

Normally gcc does manage to CSE the value of current.

>  148:   85 d2                   test   %edx,%edx        <-+
>  14a:   74 04                   je     150 <__local_bh_enable+0x20>
>  14c:   85 c0                   test   %eax,%eax
>  14e:   75 35                   jne    185 <__local_bh_enable+0x55>
>  150:   89 e0                   mov    %esp,%eax
>  152:   8b 0d 00 00 00 00       mov    0x0,%ecx         <-+
>  158:   25 00 e0 ff ff          and    $0xffffe000,%eax   |

but this time it went and reevaluated it.

>  15d:   8b 40 14                mov    0x14(%eax),%eax    | !!!
>  160:   25 00 ff 00 00          and    $0xff00,%eax       |
>  165:   3d 00 01 00 00          cmp    $0x100,%eax        |
>  16a:   0f 94 c0                sete   %al                |
>  16d:   85 c9                   test   %ecx,%ecx        <-+
>  16f:   0f b6 c0                movzbl %al,%eax
>  172:   74 04                   je     178 <__local_bh_enable+0x48>
>  174:   85 c0                   test   %eax,%eax
>  176:   75 42                   jne    1ba <__local_bh_enable+0x8a>
>  178:   b8 00 01 00 00          mov    $0x100,%eax
>  17d:   83 c4 10                add    $0x10,%esp
>  180:   e9 fc ff ff ff          jmp    181 <__local_bh_enable+0x51>
>  185:   c7 44 24 0c 3e 00 00    movl   $0x3e,0xc(%esp)
>  ...
> 
> WARN_ON is better, but still has problems:
> 
> 000011a0 <do_exit>:
>     11a0:       55                      push   %ebp
>     11a1:       57                      push   %edi
>     11a2:       56                      push   %esi
>     11a3:       53                      push   %ebx
>     11a4:       83 ec 30                sub    $0x30,%esp
>     11a7:       89 44 24 18             mov    %eax,0x18(%esp)
>     11ab:       89 e0                   mov    %esp,%eax
>     11ad:       25 00 e0 ff ff          and    $0xffffe000,%eax
>     11b2:       8b 30                   mov    (%eax),%esi
>     11b4:       8b 86 58 0a 00 00       mov    0xa58(%esi),%eax
>     11ba:       89 44 24 2c             mov    %eax,0x2c(%esp)      <-+
>     11be:       8b 44 24 2c             mov    0x2c(%esp),%eax      <-+
>     11c2:       85 c0                   test   %eax,%eax              | !!!
>     11c4:       0f 85 65 07 00 00       jne    192f <do_exit+0x78f>   |
>     11ca:       8b 44 24 2c             mov    0x2c(%esp),%eax      <-+
>     11ce:       89 e0                   mov    %esp,%eax
>      ...

No, that's pretty much the same.  In the __local_bh_enable case we have the
evaluation of in_irq() as well as softirq_count().  do_exit() just has a
single WARN_ON().


> This is gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5), -O2.
> 
> I don't know why this would show up as cache misses, but it does look
> like a compiler bug is being tickled.

The code could be better, but nope, there are no additional cache misses
there.

Still weird.

  reply	other threads:[~2006-10-04 22:06 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-03 23:04 Tim Chen
2006-10-03 23:19 ` Tim Chen
2006-10-04  0:06 ` Jeremy Fitzhardinge
2006-10-03 23:47   ` Tim Chen
2006-10-04  4:39     ` Jeremy Fitzhardinge
2006-10-04 13:21       ` Tim Chen
2006-10-04 16:30         ` Andrew Morton
2006-10-04 16:22           ` Tim Chen
2006-10-04 17:34             ` Andrew Morton
2006-10-04 20:43               ` Tim Chen
2006-10-10  1:09               ` Tim Chen
2006-10-10 13:04                 ` Steven Rostedt
2006-10-10 15:41                   ` Tim Chen
2006-10-10 20:03                   ` Jeremy Fitzhardinge
2006-10-04  0:07 ` Andrew Morton
2006-10-03 23:42   ` Tim Chen
2006-10-04  0:09   ` Tim Chen
2006-10-04  1:14     ` Andrew Morton
2006-10-04  1:47       ` Nick Piggin
2006-10-04  3:24       ` Andrew James Wade
2006-10-04  3:32         ` Andrew Morton
2006-10-04 16:47           ` Andrew James Wade
2006-10-04 22:06             ` Andrew Morton [this message]
2006-10-05  8:13               ` Andrew James Wade
2006-10-05  8:36                 ` Andrew Morton
2006-10-05 21:31                   ` Andrew James Wade
2006-10-05 21:01                     ` Tim Chen
2006-10-04 16:57 Ananiev, Leonid I
2006-10-04 17:28 ` Andrew Morton
2006-10-08  0:28   ` Steven Rostedt
2006-10-08  0:39     ` Jeremy Fitzhardinge
2006-10-04 21:55 Ananiev, Leonid I
2006-10-05 21:37 ` Andrew Morton
2006-10-05 21:43   ` Jeremy Fitzhardinge
2006-10-05 21:52     ` Andrew Morton
2006-10-05 22:02       ` Herbert Xu
2006-10-05 22:40         ` Jeremy Fitzhardinge
2006-10-05 21:51   ` Tim Chen
2006-10-06 16:11   ` Andrew James Wade
2006-10-06  4:06 Ananiev, Leonid I
2006-10-10 21:05 Ananiev, Leonid I
2006-10-10 21:17 ` Steven Rostedt
2006-10-10 21:41   ` Roland Dreier
2006-10-10 22:59   ` Jeremy Fitzhardinge

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=20061004150631.65e8953f.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=andrew.j.wade@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=leonid.i.ananiev@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    /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

Powered by JetHome