The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	"Dr. David Alan Gilbert" <linux@treblig.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH] drm: omapdrm: reduce clang stack usage
Date: Thu, 12 Jun 2025 10:58:17 +0300	[thread overview]
Message-ID: <f4e42ca9-d6f2-401b-9a53-d3b41915c6a0@ideasonboard.com> (raw)
In-Reply-To: <20250610092737.2641862-1-arnd@kernel.org>

Hi,

On 10/06/2025 12:27, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The thread sanitizer makes the stack usage explode from extra variable
> spills in dispc_runtime_resume:
> 
> drivers/gpu/drm/omapdrm/dss/dispc.c:4735:27: error: stack frame size (1824) exceeds limit (1280) in 'dispc_runtime_resume' [-Werror,-Wframe-larger-than]
> 
> I could not figure out what exactly is going on here, but I see that
> whenever dispc_restore_context() is not inlined, that function
> and its caller shrink below 900 bytes combined of stack usage.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/omapdrm/dss/dispc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 533f70e8a4a6..cf055815077c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -524,7 +524,7 @@ static void dispc_save_context(struct dispc_device *dispc)
>  	DSSDBG("context saved\n");
>  }
>  
> -static void dispc_restore_context(struct dispc_device *dispc)
> +static noinline_for_stack void dispc_restore_context(struct dispc_device *dispc)
>  {
>  	int i, j;
>  

While I don't think this causes any harm, but... What's going on here?
If I compile with gcc (x86 or arm), I see stack usage in few hundreds of
bytes. If I compile with LLVM=1, the stack usage jumps to over a thousand.

Is clang just broken? I don't see anything special with
dispc_restore_context() or dispc_runtime_resume(), so is this same thing
happening all around the kernel, and we need to sprinkle noinlines
everywhere?

Or do we get some extra debugging feature enabled only on clang with
allmodconfig, and that is eating the stack?

 Tomi


  reply	other threads:[~2025-06-12  7:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10  9:27 [PATCH] drm: omapdrm: reduce clang stack usage Arnd Bergmann
2025-06-12  7:58 ` Tomi Valkeinen [this message]
2025-06-12 12:40   ` Arnd Bergmann
2025-06-12 14:37     ` Tomi Valkeinen
2025-06-12 15:19       ` Arnd Bergmann

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=f4e42ca9-d6f2-401b-9a53-d3b41915c6a0@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@treblig.org \
    --cc=llvm@lists.linux.dev \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=morbo@google.com \
    --cc=mripard@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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