mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Serge Semin <fancer.lancer@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
	Vinod Koul <vkoul@kernel.org>,
	Serge Semin <Sergey.Semin@baikalelectronics.ru>,
	Arnd Bergmann <arnd@arndb.de>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Frank Li <Frank.Li@nxp.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: dw-edma: reduce stack usage after debugfs rework
Date: Mon, 30 Jan 2023 20:12:50 +0300	[thread overview]
Message-ID: <20230130171250.5ve3clop4tjv73ri@mobilestation> (raw)
In-Reply-To: <20230130130826.596171-1-arnd@kernel.org>

Hi Arnd

On Mon, Jan 30, 2023 at 02:08:10PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> After the dw_edma_debugfs_entry arrays are no longer compile-time
> constant, they take up space on the stack, which exceeds the
> warning limit after inlining:
> 
> drivers/dma/dw-edma/dw-edma-v0-debugfs.c:280:6: error: stack frame size (1784) exceeds limit (1400) in 'dw_edma_v0_debugfs_on' [-Werror,-Wframe-larger-than]
> void dw_edma_v0_debugfs_on(struct dw_edma *dw)
> 

> Work around this by marking the functions with the largest arrays
> as 'noinline_for_stack' to make them not use up space on the same
> stack together.

You mean the same stack !frame!, right?

> 
> Fixes: 5c0373eafd83 ("dmaengine: dw-edma: Move eDMA data pointer to debugfs node descriptor")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/dma/dw-edma/dw-edma-v0-debugfs.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c
> index 7be23c26ac88..9dfcbbdfb27b 100644
> --- a/drivers/dma/dw-edma/dw-edma-v0-debugfs.c
> +++ b/drivers/dma/dw-edma/dw-edma-v0-debugfs.c
> @@ -116,7 +116,8 @@ static void dw_edma_debugfs_create_x32(struct dw_edma *dw,
>  	}
>  }
>  

> -static void dw_edma_debugfs_regs_ch(struct dw_edma *dw, enum dw_edma_dir dir,
> +static noinline_for_stack void
> +dw_edma_debugfs_regs_ch(struct dw_edma *dw, enum dw_edma_dir dir,
>  				    u16 ch, struct dentry *dent)

This doesn't seem like required. Does it? This method is called from
two functions: dw_edma_debugfs_regs_wr() and dw_edma_debugfs_regs_rd()
and if I am not mistaken will unlikely be inlined. Even if compiler will
inline it the stack memory consumption won't change much since the
functions aren't called from each other.

>  {
>  	struct dw_edma_debugfs_entry debugfs_regs[] = {
> @@ -136,9 +137,10 @@ static void dw_edma_debugfs_regs_ch(struct dw_edma *dw, enum dw_edma_dir dir,
>  	dw_edma_debugfs_create_x32(dw, debugfs_regs, nr_entries, dent);
>  }
>  
> -static void dw_edma_debugfs_regs_wr(struct dw_edma *dw, struct dentry *dent)
> +static noinline_for_stack void
> +dw_edma_debugfs_regs_wr(struct dw_edma *dw, struct dentry *dent)
>  {

> -	static const struct dw_edma_debugfs_entry debugfs_regs[] = {
> +	const struct dw_edma_debugfs_entry debugfs_regs[] = {
>  		/* eDMA global registers */
>  		WR_REGISTER(dw, engine_en),
>  		WR_REGISTER(dw, doorbell),
> @@ -159,7 +161,7 @@ static void dw_edma_debugfs_regs_wr(struct dw_edma *dw, struct dentry *dent)
>  		WR_REGISTER(dw, ch67_imwr_data),
>  		WR_REGISTER(dw, linked_list_err_en),
>  	};
> -	static const struct dw_edma_debugfs_entry debugfs_unroll_regs[] = {
> +	const struct dw_edma_debugfs_entry debugfs_unroll_regs[] = {

I am confused how come these locals've turned to be static const?
Neither my patches nor the Bjorn repo provide such changes:
https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/tree/drivers/dma/dw-edma/dw-edma-v0-debugfs.c?h=next#n139
they were supposed to be just const.

What repo is this patch based on?

>  		/* eDMA channel context grouping */
>  		WR_REGISTER_UNROLL(dw, engine_chgroup),
>  		WR_REGISTER_UNROLL(dw, engine_hshake_cnt.lsb),
> @@ -197,7 +199,8 @@ static void dw_edma_debugfs_regs_wr(struct dw_edma *dw, struct dentry *dent)
>  	}
>  }
>  

> -static void dw_edma_debugfs_regs_rd(struct dw_edma *dw, struct dentry *dent)
> +static noinline void

noinline_for_stack, right?

-Serge(y)

> +dw_edma_debugfs_regs_rd(struct dw_edma *dw, struct dentry *dent)
>  {
>  	const struct dw_edma_debugfs_entry debugfs_regs[] = {
>  		/* eDMA global registers */
> -- 
> 2.39.0
> 

  reply	other threads:[~2023-01-30 17:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 13:08 Arnd Bergmann
2023-01-30 17:12 ` Serge Semin [this message]
2023-01-30 18:50   ` 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=20230130171250.5ve3clop4tjv73ri@mobilestation \
    --to=fancer.lancer@gmail.com \
    --cc=Frank.Li@nxp.com \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=vkoul@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

all inboxes | Powered by JetHome®