LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] xtensa: Increase size of gcc stack frame check
@ 2021-09-12  2:52 Guenter Roeck
  2021-09-12  3:05 ` Max Filippov
  2021-09-13 15:57 ` David Laight
  0 siblings, 2 replies; 9+ messages in thread
From: Guenter Roeck @ 2021-09-12  2:52 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Masahiro Yamada, linux-xtensa, linux-kernel, Guenter Roeck,
	Chris Zankel, Max Filippov

xtensa frame size is larger than the frame size for almost all other
architectures. This results in more than 50 "the frame size of <n> is
larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.

Increase frame size for xtensa to 1536 bytes to avoid compile errors
due to frame size limits.

Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ed4a31e34098..afad11e57d6b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -346,7 +346,7 @@ config FRAME_WARN
 	int "Warn for stack frames larger than"
 	range 0 8192
 	default 2048 if GCC_PLUGIN_LATENT_ENTROPY
-	default 1536 if (!64BIT && PARISC)
+	default 1536 if (!64BIT && (PARISC || XTENSA))
 	default 1024 if (!64BIT && !PARISC)
 	default 2048 if 64BIT
 	help
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-12  2:52 [PATCH] xtensa: Increase size of gcc stack frame check Guenter Roeck
@ 2021-09-12  3:05 ` Max Filippov
  2021-09-12  4:02   ` Guenter Roeck
  2021-09-13 15:57 ` David Laight
  1 sibling, 1 reply; 9+ messages in thread
From: Max Filippov @ 2021-09-12  3:05 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Andrew Morton, Masahiro Yamada,
	open list:TENSILICA XTENSA PORT (xtensa),
	LKML, Chris Zankel

On Sat, Sep 11, 2021 at 7:52 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> xtensa frame size is larger than the frame size for almost all other
> architectures. This results in more than 50 "the frame size of <n> is
> larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
>
> Increase frame size for xtensa to 1536 bytes to avoid compile errors
> due to frame size limits.
>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  lib/Kconfig.debug | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index ed4a31e34098..afad11e57d6b 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -346,7 +346,7 @@ config FRAME_WARN
>         int "Warn for stack frames larger than"
>         range 0 8192
>         default 2048 if GCC_PLUGIN_LATENT_ENTROPY
> -       default 1536 if (!64BIT && PARISC)
> +       default 1536 if (!64BIT && (PARISC || XTENSA))
>         default 1024 if (!64BIT && !PARISC)

Shouldn't that line also be changed to
  default 1024 if (!64BIT && !(PARISC || XTENSA))
?

>         default 2048 if 64BIT
>         help
> --
> 2.33.0
>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-12  3:05 ` Max Filippov
@ 2021-09-12  4:02   ` Guenter Roeck
  2021-09-12  5:16     ` Max Filippov
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2021-09-12  4:02 UTC (permalink / raw)
  To: Max Filippov
  Cc: Andrew Morton, Masahiro Yamada,
	open list:TENSILICA XTENSA PORT (xtensa),
	LKML, Chris Zankel

On 9/11/21 8:05 PM, Max Filippov wrote:
> On Sat, Sep 11, 2021 at 7:52 PM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> xtensa frame size is larger than the frame size for almost all other
>> architectures. This results in more than 50 "the frame size of <n> is
>> larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
>>
>> Increase frame size for xtensa to 1536 bytes to avoid compile errors
>> due to frame size limits.
>>
>> Cc: Chris Zankel <chris@zankel.net>
>> Cc: Max Filippov <jcmvbkbc@gmail.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   lib/Kconfig.debug | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
>> index ed4a31e34098..afad11e57d6b 100644
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -346,7 +346,7 @@ config FRAME_WARN
>>          int "Warn for stack frames larger than"
>>          range 0 8192
>>          default 2048 if GCC_PLUGIN_LATENT_ENTROPY
>> -       default 1536 if (!64BIT && PARISC)
>> +       default 1536 if (!64BIT && (PARISC || XTENSA))
>>          default 1024 if (!64BIT && !PARISC)
> 
> Shouldn't that line also be changed to
>    default 1024 if (!64BIT && !(PARISC || XTENSA))
> ?

I could do that, but I tested it and it looks like the evaluation
is top-down, so it didn't seem necessary or useful. For example,
the default value is 2048 for 32-bit systems (such as arm, riscv32,
or i386) if GCC_PLUGIN_LATENT_ENTROPY is enabled, even though the
line with the default of 1024 matches as well.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-12  4:02   ` Guenter Roeck
@ 2021-09-12  5:16     ` Max Filippov
  0 siblings, 0 replies; 9+ messages in thread
From: Max Filippov @ 2021-09-12  5:16 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Andrew Morton, Masahiro Yamada,
	open list:TENSILICA XTENSA PORT (xtensa),
	LKML, Chris Zankel

On Sat, Sep 11, 2021 at 9:02 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 9/11/21 8:05 PM, Max Filippov wrote:
> > On Sat, Sep 11, 2021 at 7:52 PM Guenter Roeck <linux@roeck-us.net> wrote:
> >>
> >> xtensa frame size is larger than the frame size for almost all other
> >> architectures. This results in more than 50 "the frame size of <n> is
> >> larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
> >>
> >> Increase frame size for xtensa to 1536 bytes to avoid compile errors
> >> due to frame size limits.
> >>
> >> Cc: Chris Zankel <chris@zankel.net>
> >> Cc: Max Filippov <jcmvbkbc@gmail.com>
> >> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> >> ---
> >>   lib/Kconfig.debug | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> >> index ed4a31e34098..afad11e57d6b 100644
> >> --- a/lib/Kconfig.debug
> >> +++ b/lib/Kconfig.debug
> >> @@ -346,7 +346,7 @@ config FRAME_WARN
> >>          int "Warn for stack frames larger than"
> >>          range 0 8192
> >>          default 2048 if GCC_PLUGIN_LATENT_ENTROPY
> >> -       default 1536 if (!64BIT && PARISC)
> >> +       default 1536 if (!64BIT && (PARISC || XTENSA))
> >>          default 1024 if (!64BIT && !PARISC)
> >
> > Shouldn't that line also be changed to
> >    default 1024 if (!64BIT && !(PARISC || XTENSA))
> > ?
>
> I could do that, but I tested it and it looks like the evaluation
> is top-down, so it didn't seem necessary or useful. For example,
> the default value is 2048 for 32-bit systems (such as arm, riscv32,
> or i386) if GCC_PLUGIN_LATENT_ENTROPY is enabled, even though the
> line with the default of 1024 matches as well.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-12  2:52 [PATCH] xtensa: Increase size of gcc stack frame check Guenter Roeck
  2021-09-12  3:05 ` Max Filippov
@ 2021-09-13 15:57 ` David Laight
  2021-09-13 16:11   ` Guenter Roeck
  1 sibling, 1 reply; 9+ messages in thread
From: David Laight @ 2021-09-13 15:57 UTC (permalink / raw)
  To: 'Guenter Roeck', Andrew Morton
  Cc: Masahiro Yamada, linux-xtensa, linux-kernel, Chris Zankel, Max Filippov

From: Guenter Roeck
> Sent: 12 September 2021 03:53
> 
> xtensa frame size is larger than the frame size for almost all other
> architectures. This results in more than 50 "the frame size of <n> is
> larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
> 
> Increase frame size for xtensa to 1536 bytes to avoid compile errors
> due to frame size limits.

Have you done anything to check what happens at run-time?
I'd guess that the deepest stack use is inside printk() in
some obscure error path.

In reality all these 1k+ stack frames need killing
rather than the limit for the compiler warning increased.

While it may be sensible for a system call entry function
so allocate a reasonable size buffer on stack (as poll()
and sendmsg() probably do) allocating big buffers way
down the call stack could easily cause stack overflow.
Even a 1k stack frame is huge.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-13 15:57 ` David Laight
@ 2021-09-13 16:11   ` Guenter Roeck
  2021-09-14  7:04     ` Max Filippov
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2021-09-13 16:11 UTC (permalink / raw)
  To: David Laight, Andrew Morton
  Cc: Masahiro Yamada, linux-xtensa, linux-kernel, Chris Zankel, Max Filippov

On 9/13/21 8:57 AM, David Laight wrote:
> From: Guenter Roeck
>> Sent: 12 September 2021 03:53
>>
>> xtensa frame size is larger than the frame size for almost all other
>> architectures. This results in more than 50 "the frame size of <n> is
>> larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
>>
>> Increase frame size for xtensa to 1536 bytes to avoid compile errors
>> due to frame size limits.
> 
> Have you done anything to check what happens at run-time?
> I'd guess that the deepest stack use is inside printk() in
> some obscure error path.
> 
> In reality all these 1k+ stack frames need killing
> rather than the limit for the compiler warning increased.
> 
> While it may be sensible for a system call entry function
> so allocate a reasonable size buffer on stack (as poll()
> and sendmsg() probably do) allocating big buffers way
> down the call stack could easily cause stack overflow.
> Even a 1k stack frame is huge.
> 

The functions I checked typically have pretty large local data
(like, more than 700-800 bytes). The errors are only observed
with xtensa:allmodconfig test builds. While it may be arguable
if those functions really need that much data on the stack, it
is unreasonable to assume that all those errors (again, more
than 50) are ever going to get fixed, especially since the errors
are only seen with xtensa and not with any other architecture
(including parisc; setting a stack limit of 1024 works just fine
with that architecture, at least with gcc 11.x). So the realistic
options are:

1) accept this or a similar patch
2) stop build testing xtensa:allmodconfig
3) Manually disable CONFIG_WERROR when test building xtensa:allmodconfig

As it looks like, I'll probably implement option 3) in my test builds.
I planned to start doing that around v5.15-rc4/rc5, but I may do it
earlier if it is becoming obvious that the now-errors won't get fixed.

Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-13 16:11   ` Guenter Roeck
@ 2021-09-14  7:04     ` Max Filippov
  2021-09-14 14:02       ` Guenter Roeck
  0 siblings, 1 reply; 9+ messages in thread
From: Max Filippov @ 2021-09-14  7:04 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: David Laight, Andrew Morton, Masahiro Yamada, linux-xtensa,
	linux-kernel, Chris Zankel

On Mon, Sep 13, 2021 at 9:11 AM Guenter Roeck <linux@roeck-us.net> wrote:
> The functions I checked typically have pretty large local data
> (like, more than 700-800 bytes). The errors are only observed
> with xtensa:allmodconfig test builds. While it may be arguable
> if those functions really need that much data on the stack, it
> is unreasonable to assume that all those errors (again, more
> than 50) are ever going to get fixed, especially since the errors
> are only seen with xtensa and not with any other architecture

That's not what I observe. If I build allmodconfig on v5.15-rc1
for arm with gcc-8.3 I get 69 of them.

> (including parisc; setting a stack limit of 1024 works just fine
> with that architecture, at least with gcc 11.x). So the realistic

This comparison is a bit biased because allmodconfig on xtensa
enables KASAN which is not supported by the parisc. Disabling
KASAN roughly halves the size of stack frames for a few
instances that I've checked.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-14  7:04     ` Max Filippov
@ 2021-09-14 14:02       ` Guenter Roeck
  2021-09-14 17:24         ` Max Filippov
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2021-09-14 14:02 UTC (permalink / raw)
  To: Max Filippov
  Cc: David Laight, Andrew Morton, Masahiro Yamada, linux-xtensa,
	linux-kernel, Chris Zankel

On 9/14/21 12:04 AM, Max Filippov wrote:
> On Mon, Sep 13, 2021 at 9:11 AM Guenter Roeck <linux@roeck-us.net> wrote:
>> The functions I checked typically have pretty large local data
>> (like, more than 700-800 bytes). The errors are only observed
>> with xtensa:allmodconfig test builds. While it may be arguable
>> if those functions really need that much data on the stack, it
>> is unreasonable to assume that all those errors (again, more
>> than 50) are ever going to get fixed, especially since the errors
>> are only seen with xtensa and not with any other architecture
> 
> That's not what I observe. If I build allmodconfig on v5.15-rc1
> for arm with gcc-8.3 I get 69 of them.
> 

Interesting. I had used gcc 11.2. Anyway, arm:allmodconfig sets
the limit to 2048 for me, for both gcc 8.3 and 11.2, due to
GCC_PLUGIN_LATENT_ENTROPY=y. But you are right, if I disable
GCC_PLUGIN_LATENT_ENTROPY and set the frame size to 1024,
I get lots of frame size errors on arm as well.

>> (including parisc; setting a stack limit of 1024 works just fine
>> with that architecture, at least with gcc 11.x). So the realistic
> 
> This comparison is a bit biased because allmodconfig on xtensa
> enables KASAN which is not supported by the parisc. Disabling
> KASAN roughly halves the size of stack frames for a few
> instances that I've checked.
> 

It wasn't meant to be biased or unbiased, just a (surprising)
observation. Maybe there is some configuration in parisc that
is not enabled with allmodconfig which increases the frame size.

I still don't think that those stack limit warnings (now errors)
will ever get fixed. Which is the point I was trying to make,
and your observation that the stack frames are really that large
because of KASAN just makes that argument stronger.

Other than that, it is not my call to make that to do with this
patch. If you think that it is inappropriate, by all means
reject it.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xtensa: Increase size of gcc stack frame check
  2021-09-14 14:02       ` Guenter Roeck
@ 2021-09-14 17:24         ` Max Filippov
  0 siblings, 0 replies; 9+ messages in thread
From: Max Filippov @ 2021-09-14 17:24 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: David Laight, Andrew Morton, Masahiro Yamada, linux-xtensa,
	linux-kernel, Chris Zankel

On Tue, Sep 14, 2021 at 7:02 AM Guenter Roeck <linux@roeck-us.net> wrote:
> I still don't think that those stack limit warnings (now errors)
> will ever get fixed. Which is the point I was trying to make,
> and your observation that the stack frames are really that large
> because of KASAN just makes that argument stronger.
>
> Other than that, it is not my call to make that to do with this
> patch. If you think that it is inappropriate, by all means
> reject it.

I like it, also for the reason that with KASAN enabled
kernel stack size on xtensa is 4 times bigger.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-14 17:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-12  2:52 [PATCH] xtensa: Increase size of gcc stack frame check Guenter Roeck
2021-09-12  3:05 ` Max Filippov
2021-09-12  4:02   ` Guenter Roeck
2021-09-12  5:16     ` Max Filippov
2021-09-13 15:57 ` David Laight
2021-09-13 16:11   ` Guenter Roeck
2021-09-14  7:04     ` Max Filippov
2021-09-14 14:02       ` Guenter Roeck
2021-09-14 17:24         ` Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).