Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kbuild@vger.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>,
	Arnd Bergmann <arnd@arndb.de>,
	Bjorn Andersson <andersson@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] err.h: use __always_inline on all error pointer helpers
Date: Tue, 26 May 2026 12:37:33 -0700	[thread overview]
Message-ID: <20260526193733.GC2851089@ax162> (raw)
In-Reply-To: <20260526101851.2495110-1-arnd@kernel.org>

On Tue, May 26, 2026 at 12:18:41PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> While testing randconfig builds on s390, I came across a
> link failure with CONFIG_DMA_SHARED_BUFFER disabled:
> 
> ERROR: modpost: "dma_buf_put" [drivers/iommu/iommufd/iommufd.ko] undefined!
> 
> The problem here is that IS_ERR() is not inlined and dead code elimination
> fails as a consequence.
> 
> The err.h helpers all turn into a trivial assignment ot a bit mask
> and should never result in a function call, so force them to always be
> inline. This should generally result in better object code aside from
> avoiding the link failure above.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Yeah, seems reasonable to me. I agree that this should generally result
in better generated code as opposed to these helpers being generated out
of line.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  include/linux/err.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/err.h b/include/linux/err.h
> index 8c37be0620ab..d3e38d5b3a98 100644
> --- a/include/linux/err.h
> +++ b/include/linux/err.h
> @@ -36,7 +36,7 @@
>   *
>   * Return: A pointer with @error encoded within its value.
>   */
> -static inline void * __must_check ERR_PTR(long error)
> +static __always_inline void * __must_check ERR_PTR(long error)
>  {
>  	return (void *) error;
>  }
> @@ -60,7 +60,7 @@ static inline void * __must_check ERR_PTR(long error)
>   * @ptr: An error pointer.
>   * Return: The error code within @ptr.
>   */
> -static inline long __must_check PTR_ERR(__force const void *ptr)
> +static __always_inline long __must_check PTR_ERR(__force const void *ptr)
>  {
>  	return (long) ptr;
>  }
> @@ -73,7 +73,7 @@ static inline long __must_check PTR_ERR(__force const void *ptr)
>   * @ptr: The pointer to check.
>   * Return: true if @ptr is an error pointer, false otherwise.
>   */
> -static inline bool __must_check IS_ERR(__force const void *ptr)
> +static __always_inline bool __must_check IS_ERR(__force const void *ptr)
>  {
>  	return IS_ERR_VALUE((unsigned long)ptr);
>  }
> @@ -87,7 +87,7 @@ static inline bool __must_check IS_ERR(__force const void *ptr)
>   *
>   * Like IS_ERR(), but also returns true for a null pointer.
>   */
> -static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
> +static __always_inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
>  {
>  	return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
>  }
> @@ -99,7 +99,7 @@ static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
>   * Explicitly cast an error-valued pointer to another pointer type in such a
>   * way as to make it clear that's what's going on.
>   */
> -static inline void * __musggt_check ERR_CAST(__force const void *ptr)
> +static __always_inline void * __must_check ERR_CAST(__force const void *ptr)
>  {
>  	/* cast away the const */
>  	return (void *) ptr;
> @@ -122,7 +122,7 @@ static inline void * __must_check ERR_CAST(__force const void *ptr)
>   *
>   * Return: The error code within @ptr if it is an error pointer; 0 otherwise.
>   */
> -static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
> +static __always_inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
>  {
>  	if (IS_ERR(ptr))
>  		return PTR_ERR(ptr);
> -- 
> 2.39.5
> 

-- 
Cheers,
Nathan

      parent reply	other threads:[~2026-05-26 19:37 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
2026-05-26 19:37 ` Nathan Chancellor [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=20260526193733.GC2851089@ax162 \
    --to=nathan@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --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=nsc@kernel.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