public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Arnd Bergmann" <arnd@kernel.org>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Peter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	"Daniel Baluta" <daniel.baluta@nxp.com>,
	"Seppo Ingalsuo" <seppo.ingalsuo@linux.intel.com>
Cc: "Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Brent Lu" <brent.lu@intel.com>,
	sound-open-firmware@alsa-project.org,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH] sound: sof: ioc4-topology: avoid extra dai_params copy
Date: Wed, 07 Aug 2024 10:47:28 +0200	[thread overview]
Message-ID: <b821f357-8a11-4814-8ae0-e0e8d8cd4afb@app.fastmail.com> (raw)
In-Reply-To: <250c63d7-d81e-49ea-ac8f-2e3496075f20@linux.intel.com>

On Wed, Aug 7, 2024, at 10:37, Pierre-Louis Bossart wrote:
> On 8/7/24 10:02, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> The snd_pcm_hw_params structure is really too large to fit on the
>> stack. Because of the way that clang inlines functions, it ends up
>> twice in one function, which exceeds the 1024 byte limit for 32-bit
>> architecutes:
>> 
>> sound/soc/sof/ipc4-topology.c:1700:1: error: stack frame size (1304) exceeds limit (1024) in 'sof_ipc4_prepare_copier_module' [-Werror,-Wframe-larger-than]
>> sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
>> 
>>>From what I can tell, this was unintentional, as both
>> sof_ipc4_prepare_dai_copier() and sof_ipc4_prepare_copier_module() make a
>> copy for the same purpose, but copying it once has the exact same effect.
>
> Humm, not sure. I think the copy was intentional so that if one of the
> fixups fails, then the initial hw_params structure is not modified.

It's clear that one of the two copies was intentional, however
the same logic exists in the caller, which passes the copied
ref_params into sof_ipc4_prepare_dai_copier() instead of the live
'fe_params'. If sof_ipc4_prepare_dai_copier() fails, the copy
is discarded by returning the error, and otherwise it gets
passed on to sof_ipc4_init_input_audio_fmt().

> Also not sure why a compiler would think inlining such a large function
> is a good idea?

I think clang prefers to inline large functions in order to better
do larger scale optimizations. gcc starts by inlining small leaf
functions and doesn't get to this one.

Note that the actual problem of having two giant structures on the
stack does not change through inlining, the risk of overflowing
the 8kb thread stack and the cost of maintaining these variables
is the same. The only difference is that clang triggers the warning
because it sees the total stack size where gcc doesn't see it.

    Arnd

  reply	other threads:[~2024-08-07  8:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  8:02 [PATCH] sound: sof: ioc4-topology: avoid extra dai_params copy Arnd Bergmann
2024-08-07  8:37 ` Pierre-Louis Bossart
2024-08-07  8:47   ` Arnd Bergmann [this message]
2024-08-07 10:00 ` Mark Brown
2024-08-07 15:09 ` Mark Brown
2024-08-07 15:18   ` Arnd Bergmann
2024-08-07 16:21     ` Ranjani Sridharan

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=b821f357-8a11-4814-8ae0-e0e8d8cd4afb@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=brent.lu@intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=justinstitt@google.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=seppo.ingalsuo@linux.intel.com \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox