mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Anders Larsen <al@alarsen.net>
Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] Fix sysrq caused USB performance regressions and leak
Date: Fri, 10 Jul 2009 10:34:12 +0100	[thread overview]
Message-ID: <20090710103412.70152f8c@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <1247216873l.25954l.0l@i-dmzi_al.realan.de>

On Fri, 10 Jul 2009 11:07:53 +0200
Anders Larsen <al@alarsen.net> wrote:

> On 2009-07-10 02:01:37, Alan Cox wrote:
> > > shouldn't it be
> > > +	if (likely(!port->console || !port->sysrq))
> > > respectively
> > > +	if (unlikely(port->console && port->sysrq)) {
> > > 
> > > at least for clarity?
> > 
> > It'll get predicted by the CPU just fine I suspect.
> 
> I thought likely() / unlikely() were for the _compiler_ to arrange the
> blocks more efficiently?

Bit of both. Some systems have indicators for whether jumps are likely to
be taken, others you do things like conditionally jump forward to a jump
table which jumps back.

gcc itself says "programmers are notoriously bad at predicting how their
programs actually perform." 8)

Benchmarking I've not had any luck with unlikely() on a modern CPU
(the CPU is dynamically predicting anyway). The pentium iv does add
branch prediction hints (DS: and CS: overrides get reused) but they seem
to make things slower in the case where the CPU will get it right anyway.

So I'd like to see benchmarking evidence for an unlikely on such a hot
and predictible path.


      reply	other threads:[~2009-07-10  9:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-09 12:35 Alan Cox
2009-07-09 12:35 ` [PATCH 1/3] tty: Sort out the USB sysrq changes that wrecked performance Alan Cox
2009-07-09 15:49   ` Fengwei Yin
2009-07-09 23:22     ` Fengwei Yin
2009-07-09 12:36 ` [PATCH 2/3] tty: Fix USB kref leak Alan Cox
2009-07-09 12:36 ` [PATCH 3/3] tty: Fix the PL2303 private methods for sysrq Alan Cox
2009-07-09 15:46 ` [PATCH 0/3] Fix sysrq caused USB performance regressions and leak Anders Larsen
2009-07-10  0:02   ` Alan Cox
2009-07-10  9:07     ` Anders Larsen
2009-07-10  9:34       ` Alan Cox [this message]

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=20090710103412.70152f8c@lxorguk.ukuu.org.uk \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=al@alarsen.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®