From: David Laight <david.laight.linux@gmail.com>
To: "Arnd Bergmann" <arnd@arndb.de>
Cc: "Alexander Lobakin" <aleksander.lobakin@intel.com>,
"Arnd Bergmann" <arnd@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-kbuild@vger.kernel.org,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Bjorn Andersson" <andersson@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Christian Marangi" <ansuelsmth@gmail.com>,
linux-kernel@vger.kernel.org,
"Steven Rostedt" <rostedt@goodmis.org>
Subject: Re: [PATCH] err.h: use __always_inline on all error pointer helpers
Date: Wed, 27 May 2026 23:13:49 +0100 [thread overview]
Message-ID: <20260527231349.14bdcfc6@pumpkin> (raw)
In-Reply-To: <21f771b5-b8fe-4357-b081-ae83a39df485@app.fastmail.com>
On Wed, 27 May 2026 16:25:41 +0200
"Arnd Bergmann" <arnd@arndb.de> wrote:
> On Wed, May 27, 2026, at 16:06, Alexander Lobakin wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > Date: Tue, 26 May 2026 23:03:50 +0200
> >>
> >> Without CONFIG_PROFILE_ANNOTATED_BRANCHES, the changes are
> >> very small, with around 100 functions growing or shrinking
> >> by a few bytes.
> >>
> >> I don't think we care much about the size increase when that
> >> option is enabled, but I do wonder what behavior makes more
> >
> > Yup, and even without this option, __always_inline is better here
> > regardless of how it affects the size. Such oneliners must be
> > transparent to the compiler
>
> In general I would trust the compiler to make the right
> choices here, but as I have shown it makes very little difference.
>
> I think one case where an out-of-line copy may legitimately
> be generated by the compiler would be when optimizing known
> cold code for size and the compiler can show that the
> out of line version is indeed shorter.
>
> >> sense regarding the annotation for every single IS_ERR().
> >> Does it make sense to have every instance get its own counter,
> >> or would it make sense to actually try to reduce these
> >> when profiling the annotations?
> >
> > I'm not familiar with branch annotations, but from the stats above, it
> > really looks like it adds a lot of code bloat. Plenty of branches in
> > the kernel are sorta pointless to track (the ones which trigger once
> > in a thousand years, the unlikely() ones etc.), I guess.
>
> Yes, the CONFIG_PROFILE_ANNOTATED_BRANCHES option definitely
> adds a huge amount of bloat. The point here is to find
> incorrect annotations, either a branch that is marked unlikely()
> but taken most of the time or the reverse. I think
> Steven Rosted enables the option occasionally to
> see if there are any outliers, but nobody should use
> this in production environments.
>
> For IS_ERR(), it is fairly clear that unlikely() is the
> correct annotation in almost all cases, and it's helpful to
> mark all of the error handling as unlikely so the compiuler
> can move it away from hot code paths. With 35000 instances
> of IS_ERR() there are likely a few exceptions to this
> rule, but I don't know if any of them are important enough
> to require a code change. Steven might remember if he's
> ever seen one here.
IS_ERR_OR_NULL() is more interesting, see https://godbolt.org/z/z3b1Yxqe9
The last one ((unsigned long)p - 1 >= -MAX_ERRNO - 1) only contains
a single branch.
I'm sure I remember Linus ranting about something similar.
-- David
>
> Arnd
>
next prev parent reply other threads:[~2026-05-27 22:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 10:18 [PATCH] err.h: use __always_inline on all error pointer helpers Arnd Bergmann
2026-05-26 15:01 ` Alexander Lobakin
2026-05-26 21:03 ` Arnd Bergmann
2026-05-27 14:06 ` Alexander Lobakin
2026-05-27 14:25 ` Arnd Bergmann
2026-05-27 14:30 ` Alexander Lobakin
2026-05-27 22:13 ` David Laight [this message]
2026-05-26 19:37 ` Nathan Chancellor
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=20260527231349.14bdcfc6@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=aleksander.lobakin@intel.com \
--cc=andersson@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ansuelsmth@gmail.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=rostedt@goodmis.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 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.