[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251030205641.47b2241f@pumpkin>
Date: Thu, 30 Oct 2025 20:56:41 +0000
From: David Laight <david.laight.linux@...il.com>
To: Christian Kujau <lists@...dbynature.de>
Cc: linux-kernel@...r.kernel.org, "Liam R. Howlett"
 <Liam.Howlett@...cle.com>, Arnd Bergmann <arnd@...db.de>
Subject: Re: maple_tree.c:3738:1: error: the frame size of 1040 bytes is
 larger than 1024 bytes
On Thu, 30 Oct 2025 18:13:33 +0100 (CET)
Christian Kujau <lists@...dbynature.de> wrote:
> On Thu, 30 Oct 2025, David Laight wrote:
> > It is horrendous - best part of 4k code, the stack frame is 0x408.
> > Which means I must be building with a larger stack frame limit.
> > Is one of your debug options reducing it?  
> 
> No that I know of. I've attached the config to my initial posting.
> 
> > OTOH it looks as though the actual place to force a stack frame 'break' is to
> > stop mas_rebalance() and mas_split() being inlined into mas_commit_b_node().
> > (Probably instead of all the current noinline_for_kasan.)
> > Both those functions are large and don't have many parameters.  
> 
> Cool, that helped! Leaving mas_wr_bnode() as it was, and only changed:
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 39bb779cb311..949fd2a0554b 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -2746,7 +2746,7 @@ static void mas_spanning_rebalance(struct ma_state *mas,
>   * Rebalance two nodes into a single node or two new nodes that are sufficient.
>   * Continue upwards until tree is sufficient.
>   */
> -static inline void mas_rebalance(struct ma_state *mas,
> +static noinline void mas_rebalance(struct ma_state *mas,
>  				struct maple_big_node *b_node)
>  {
>  	char empty_count = mas_mt_height(mas);
> @@ -2967,7 +2967,7 @@ static inline bool mas_push_data(struct ma_state *mas,
>   * @mas: The maple state
>   * @b_node: The maple big node
>   */
> -static void mas_split(struct ma_state *mas, struct maple_big_node *b_node)
> +static noinline void mas_split(struct ma_state *mas, struct maple_big_node *b_node)
>  {
>  	struct maple_subtree_state mast;
>  	int height = 0;
Someone really ought to look at that code though.
1k stack frames tend to indicate 'sub-optimal' coding.
Especially since there are several 'rep stosd' to zero 64byte items
and an inlined (unrolled) copy of two larger on-stack structures.
I've implemented a balanced tree in the past, I don't what to try and
work out how a 'maple tree' is expected to work.
But the sheer amount of code makes be think there are better ways
to do things.
	David
> 
> > Oh, and the WARN_ON_ONCE() in there is all wrong.
> > A WARN_ON_ONCE(type != wr_split_store) after the call to mas_rebalance()
> > might make sense.  
> 
> I'll leave that for someone else to fix :-)
> 
> Thanks,
> Christian.
Powered by blists - more mailing lists
 
