Re: [PATCH] reduce large do_mount stack usage with noinlines

Eric Sandeen
2008-02-06T23:35:40Z

Andrew Morton wrote:
> On Wed, 06 Feb 2008 17:11:38 -0600
> Eric Sandeen <sandeen@redhat.com> wrote:
>
>> /*
>> * recursively change the type of the mountpoint.
>> + * noinline this do_mount helper to save do_mount stack space.
>> */
>> -static int do_change_type(struct nameidata *nd, int flag)
>> +static noinline int do_change_type(struct nameidata *nd, int flag)
>
> What we could do here is defined a new noinline_because_of_stack_suckiness
> and use that. Reasons:
>
> - self-documenting, so we don't need to comment each site
>
> - can be made a no-op for suitable __GNUC__ values if gcc ever fixes this
>
> - our children we can go through and delete them all when nobody is using
> the offending gcc versions any more.
>
> what thinkest thou?

Yes, sounds very good to me. I'm sure there are more places which could
use this.

Or perhaps there are some magic flags to gcc so that it doesn't inline
so aggressively in situations like this? IOW is it gcc breakage, or
design - but maybe with defaults that don't fit well in the limited
stack... (well, I suppose the "for N mutually exclusive helper functions
each with stack usage S, use about N*S stack when inlining them all" bit
probably isn't a feature.)

FWIW the XFS team finally just wrested control from GCC.
http://oss.sgi.com/archives/xfs/2006-11/msg00195.html

-Eric