From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Zijun Hu <zijun_hu@icloud.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org, Zijun Hu <quic_zijuhu@quicinc.com>
Subject: Re: [PATCH 1/3] driver core: Mark impossible return values of bus_type's match() with unlikely()
Date: Wed, 4 Sep 2024 15:53:30 +0200 [thread overview]
Message-ID: <2024090444-earmark-showpiece-b3dc@gregkh> (raw)
In-Reply-To: <20240904-bus_match_unlikely-v1-1-122318285261@quicinc.com>
On Wed, Sep 04, 2024 at 08:56:42PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> Bus_type's match() should return bool type compatible integer 0 or 1
> ideally since its main operations are lookup and comparison normally
> actually, this rule is followed by ALL bus_types but @amba_bustype within
> current v6.10 kernel tree, for @amba_bustype, ONLY extra -EPROBE_DEFER
> may be returned, so mark those impossible or rare return values with
> unlikely() to help readers understand device and driver binding logic.
unlikely() and likely() should ONLY be used when you can measure the
performance impact. And any "scan all devices in the bus" function is
NOT performance critical at all. So this is not the place for that,
sorry.
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> drivers/base/dd.c | 16 ++++++++++++----
> include/linux/device/bus.h | 9 ++++-----
> 2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 9b745ba54de1..288e19c9854b 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -928,7 +928,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
> if (ret == 0) {
> /* no match */
> return 0;
> - } else if (ret == -EPROBE_DEFER) {
> + } else if (unlikely(ret == -EPROBE_DEFER)) {
> + /*
> + * Only match() of @amba_bustype may return this error
> + * in current v6.10 tree, so also give unlikely() here.
version numbers in the kernel source mean nothing, and they age
horribly. This is not going to work out at all.
let's fix up the one user that is doing this wrong and then we don't
have to worry about it, right? We have the source for everything, let's
use it :)
thanks,
greg k-h
next prev parent reply other threads:[~2024-09-04 13:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 12:56 [PATCH 0/3] driver core: bus: Fix issues related to bus_rescan_devices_helper() Zijun Hu
2024-09-04 12:56 ` [PATCH 1/3] driver core: Mark impossible return values of bus_type's match() with unlikely() Zijun Hu
2024-09-04 13:53 ` Greg Kroah-Hartman [this message]
2024-09-04 15:45 ` Zijun Hu
2024-09-04 12:56 ` [PATCH 2/3] driver core: bus: Give error prompt for storing bus attribute drivers_probe failure Zijun Hu
2024-09-04 12:56 ` [PATCH 3/3] driver core: bus: Correct API bus_rescan_devices() behavior Zijun Hu
2024-09-04 13:54 ` Greg Kroah-Hartman
2024-09-04 14:26 ` Zijun Hu
2024-09-04 14:44 ` Greg Kroah-Hartman
2024-09-04 15:42 ` Zijun Hu
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=2024090444-earmark-showpiece-b3dc@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_zijuhu@quicinc.com \
--cc=rafael@kernel.org \
--cc=zijun_hu@icloud.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.