All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Muchun Song <smuchun@gmail.com>
Cc: rafael@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] driver core: Add branch prediction hints in really_probe()
Date: Tue, 6 Nov 2018 21:26:58 +0100	[thread overview]
Message-ID: <20181106202658.GA26208@kroah.com> (raw)
In-Reply-To: <20181106134630.29591-1-smuchun@gmail.com>

On Tue, Nov 06, 2018 at 09:46:30PM +0800, Muchun Song wrote:
> If condition is false in most cases. So, add an unlikely() to the if
> condition, so that the optimizer assumes that the condition is false.
> 
> Signed-off-by: Muchun Song <smuchun@gmail.com>

As Rafael said, don't do stuff like this unless you can actually measure
the difference.  Last time we tested the kernel for this a few years
ago, about 75% of the unlikely/likely additions were incorrect, removing
them made the kernel faster.  Turns out the compiler and cpu know better
than developers do :)

Also, the probe() path is never a hot-path to worry about stuff like
this.

thanks,

greg k-h

      parent reply	other threads:[~2018-11-06 20:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 13:46 [PATCH] driver core: Add branch prediction hints in really_probe() Muchun Song
2018-11-06 14:30 ` Rafael J. Wysocki
2018-11-06 14:43   ` Muchun Song
2018-11-06 14:59     ` Rafael J. Wysocki
2018-11-06 15:12       ` Muchun Song
2018-11-06 20:26 ` Greg KH [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=20181106202658.GA26208@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=smuchun@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.