All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-f2fs-devel@lists.sourceforge.net, kbuild-all@lists.01.org,
	kernel test robot <lkp@intel.com>,
	clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [f2fs-dev] [f2fs:dev-test 48/48] fs/f2fs/super.c:3303:12: warning: stack frame size of 2064 bytes in function 'f2fs_fill_super'
Date: Fri, 5 Jun 2020 12:57:13 -0700	[thread overview]
Message-ID: <20200605195713.GL1373@sol.localdomain> (raw)
In-Reply-To: <CAKwvOdmE_59v6-W+Sk8SGrrXJ4dx5ANWEpD5GL_hrw0ja0w1kg@mail.gmail.com>

On Fri, Jun 05, 2020 at 12:42:59PM -0700, Nick Desaulniers wrote:
> On Fri, Jun 5, 2020 at 12:34 PM Eric Biggers <ebiggers@kernel.org> wrote:
> >
> > On Fri, Jun 05, 2020 at 09:45:43AM -0700, Nick Desaulniers wrote:
> > > On Fri, Jun 5, 2020 at 9:08 AM Eric Biggers <ebiggers@kernel.org> wrote:
> > > >
> > > > On Fri, Jun 05, 2020 at 07:55:46AM -0700, Jaegeuk Kim wrote:
> > > > > Eric,
> > > > >
> > > > > Could you PTAL?
> > > > >
> > > > > On 06/05, kernel test robot wrote:
> > > > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
> > > > > > head:   adf3d3a53cf13d0998c699ba43d8582c875179e3
> > > > > > commit: adf3d3a53cf13d0998c699ba43d8582c875179e3 [48/48] f2fs: don't return vmalloc() memory from f2fs_kmalloc()
> > > > > > config: powerpc64-randconfig-r011-20200605 (attached as .config)
> > > > > > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project ac47588bc4ff5927a01ed6fcd269ce86aba52a7c)
> > > > > > reproduce (this is a W=1 build):
> > > > > >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > > > > >         chmod +x ~/bin/make.cross
> > > > > >         # install powerpc64 cross compiling tool for clang build
> > > > > >         # apt-get install binutils-powerpc64-linux-gnu
> > > > > >         git checkout adf3d3a53cf13d0998c699ba43d8582c875179e3
> > > > > >         # save the attached .config to linux build tree
> > > > > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
> > > > > >
> > > > > > If you fix the issue, kindly add following tag as appropriate
> > > > > > Reported-by: kernel test robot <lkp@intel.com>
> > > >
> > > > I don't know what's causing this.  It doesn't look at all related to my commit,
> > > > and I don't see what's using so much stack in f2fs_fill_super().
> > > >
> > > > @kernel test robot: the directions given above don't actually work.
> > > > First I got an error due to powerpc64-linux-gnu-elfedit not existing.
> > > > So I had to build binutils for powerpc64 myself.
> > > >
> > > > Then I still got an error:
> > > >
> > > >         make: *** No rule to make target 'arch/powerpc64/Makefile'.  Stop.
> > >
> > > If you have the config, then
> > > $ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make CC=clang -j71
> > > If you recompile with CONFIG_DEBUG_INFO, you can get the stack frame
> > > information. I wrote a tool to parse this for these cryptic warnings.
> > > https://github.com/ClangBuiltLinux/frame-larger-than
> >
> > I can build the file and get the warning now, but the frame_larger_than.py
> > script doesn't work:
> >
> > $ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make CC=clang fs/f2fs/super.o
> >   CALL    scripts/checksyscalls.sh
> >   CALL    scripts/atomic/check-atomics.sh
> >   CC [M]  fs/f2fs/super.o
> > fs/f2fs/super.c:3303:12: warning: stack frame size of 2064 bytes in function 'f2fs_fill_super' [-Wframe-larger-than=]
> > static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
> >            ^
> > 1 warning generated.
> >
> > $ python3 ~/src/frame-larger-than/frame_larger_than.py fs/f2fs/super.o f2fs_fill_super
> > failed to parse elf: Unsupported relocation type: 1
> 
> Looks like the python library I'm using to parse the DWARF debug info
> doesn't understand some ppc64 specific relocation kind, and is
> throwing an ELFError.  Let me report it upstream.
> 
> The hard part for these is inlining; it can be hard to tell which
> child has a large local allocation when looking at the warning about
> the parent.
> 
> Then again, my script is just nicer output than `llvm-dwarfdump foo.o`
> or `readelf --debug-dump=info foo.o` for this specific issue.
> 

I did confirm that my commit "f2fs: don't return vmalloc() memory from
f2fs_kmalloc()" actually caused this, in particular the following part:

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a71da699cb2d55..f3c15116954218 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3033,7 +3033,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
        if (nr_sectors & (bdev_zone_sectors(bdev) - 1))
                FDEV(devi).nr_blkz++;
 
-       FDEV(devi).blkz_seq = f2fs_kzalloc(sbi,
+       FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,
                                        BITS_TO_LONGS(FDEV(devi).nr_blkz)
                                        * sizeof(unsigned long),
                                        GFP_KERNEL);

This is inlined as:

    f2fs_fill_super()
     => f2fs_scan_devices()
        => init_blkz_info()
           => f2fs_kvzalloc()

Somehow this change increased the frame size of f2fs_fill_super() from 1984 to
2064 bytes.  That exceeds the 2048-byte limit, triggering the warning.

So, f2fs_fill_super() was very close to the limit already.  I'm not sure why; I
don't see any huge stack allocations in it or in static functions it calls.
Maybe there is a kconfig option that is increasing the stack usage?

If I add noinline_for_stack to f2fs_scan_devices(), the frame drops to 1744
bytes.  Or if I add noinline_for_stack to read_raw_super_block(), the frame
drops to 1776 bytes.  We could do either (or both) of those to avoid the
warning.  But we'd still wouldn't be that far from this 2048-byte "limit".

- Eric


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: kbuild-all@lists.01.org
Subject: Re: [f2fs-dev] [f2fs:dev-test 48/48] fs/f2fs/super.c:3303:12: warning: stack frame size of 2064 bytes in function 'f2fs_fill_super'
Date: Fri, 05 Jun 2020 12:57:13 -0700	[thread overview]
Message-ID: <20200605195713.GL1373@sol.localdomain> (raw)
In-Reply-To: <CAKwvOdmE_59v6-W+Sk8SGrrXJ4dx5ANWEpD5GL_hrw0ja0w1kg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5409 bytes --]

On Fri, Jun 05, 2020 at 12:42:59PM -0700, Nick Desaulniers wrote:
> On Fri, Jun 5, 2020 at 12:34 PM Eric Biggers <ebiggers@kernel.org> wrote:
> >
> > On Fri, Jun 05, 2020 at 09:45:43AM -0700, Nick Desaulniers wrote:
> > > On Fri, Jun 5, 2020 at 9:08 AM Eric Biggers <ebiggers@kernel.org> wrote:
> > > >
> > > > On Fri, Jun 05, 2020 at 07:55:46AM -0700, Jaegeuk Kim wrote:
> > > > > Eric,
> > > > >
> > > > > Could you PTAL?
> > > > >
> > > > > On 06/05, kernel test robot wrote:
> > > > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
> > > > > > head:   adf3d3a53cf13d0998c699ba43d8582c875179e3
> > > > > > commit: adf3d3a53cf13d0998c699ba43d8582c875179e3 [48/48] f2fs: don't return vmalloc() memory from f2fs_kmalloc()
> > > > > > config: powerpc64-randconfig-r011-20200605 (attached as .config)
> > > > > > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project ac47588bc4ff5927a01ed6fcd269ce86aba52a7c)
> > > > > > reproduce (this is a W=1 build):
> > > > > >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > > > > >         chmod +x ~/bin/make.cross
> > > > > >         # install powerpc64 cross compiling tool for clang build
> > > > > >         # apt-get install binutils-powerpc64-linux-gnu
> > > > > >         git checkout adf3d3a53cf13d0998c699ba43d8582c875179e3
> > > > > >         # save the attached .config to linux build tree
> > > > > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
> > > > > >
> > > > > > If you fix the issue, kindly add following tag as appropriate
> > > > > > Reported-by: kernel test robot <lkp@intel.com>
> > > >
> > > > I don't know what's causing this.  It doesn't look at all related to my commit,
> > > > and I don't see what's using so much stack in f2fs_fill_super().
> > > >
> > > > @kernel test robot: the directions given above don't actually work.
> > > > First I got an error due to powerpc64-linux-gnu-elfedit not existing.
> > > > So I had to build binutils for powerpc64 myself.
> > > >
> > > > Then I still got an error:
> > > >
> > > >         make: *** No rule to make target 'arch/powerpc64/Makefile'.  Stop.
> > >
> > > If you have the config, then
> > > $ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make CC=clang -j71
> > > If you recompile with CONFIG_DEBUG_INFO, you can get the stack frame
> > > information. I wrote a tool to parse this for these cryptic warnings.
> > > https://github.com/ClangBuiltLinux/frame-larger-than
> >
> > I can build the file and get the warning now, but the frame_larger_than.py
> > script doesn't work:
> >
> > $ ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- make CC=clang fs/f2fs/super.o
> >   CALL    scripts/checksyscalls.sh
> >   CALL    scripts/atomic/check-atomics.sh
> >   CC [M]  fs/f2fs/super.o
> > fs/f2fs/super.c:3303:12: warning: stack frame size of 2064 bytes in function 'f2fs_fill_super' [-Wframe-larger-than=]
> > static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
> >            ^
> > 1 warning generated.
> >
> > $ python3 ~/src/frame-larger-than/frame_larger_than.py fs/f2fs/super.o f2fs_fill_super
> > failed to parse elf: Unsupported relocation type: 1
> 
> Looks like the python library I'm using to parse the DWARF debug info
> doesn't understand some ppc64 specific relocation kind, and is
> throwing an ELFError.  Let me report it upstream.
> 
> The hard part for these is inlining; it can be hard to tell which
> child has a large local allocation when looking at the warning about
> the parent.
> 
> Then again, my script is just nicer output than `llvm-dwarfdump foo.o`
> or `readelf --debug-dump=info foo.o` for this specific issue.
> 

I did confirm that my commit "f2fs: don't return vmalloc() memory from
f2fs_kmalloc()" actually caused this, in particular the following part:

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a71da699cb2d55..f3c15116954218 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3033,7 +3033,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
        if (nr_sectors & (bdev_zone_sectors(bdev) - 1))
                FDEV(devi).nr_blkz++;
 
-       FDEV(devi).blkz_seq = f2fs_kzalloc(sbi,
+       FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,
                                        BITS_TO_LONGS(FDEV(devi).nr_blkz)
                                        * sizeof(unsigned long),
                                        GFP_KERNEL);

This is inlined as:

    f2fs_fill_super()
     => f2fs_scan_devices()
        => init_blkz_info()
           => f2fs_kvzalloc()

Somehow this change increased the frame size of f2fs_fill_super() from 1984 to
2064 bytes.  That exceeds the 2048-byte limit, triggering the warning.

So, f2fs_fill_super() was very close to the limit already.  I'm not sure why; I
don't see any huge stack allocations in it or in static functions it calls.
Maybe there is a kconfig option that is increasing the stack usage?

If I add noinline_for_stack to f2fs_scan_devices(), the frame drops to 1744
bytes.  Or if I add noinline_for_stack to read_raw_super_block(), the frame
drops to 1776 bytes.  We could do either (or both) of those to avoid the
warning.  But we'd still wouldn't be that far from this 2048-byte "limit".

- Eric

  reply	other threads:[~2020-06-05 19:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05  9:15 [f2fs:dev-test 48/48] fs/f2fs/super.c:3303:12: warning: stack frame size of 2064 bytes in function 'f2fs_fill_super' kernel test robot
2020-06-05 14:55 ` [f2fs-dev] " Jaegeuk Kim
2020-06-05 14:55   ` Jaegeuk Kim
2020-06-05 16:08   ` [f2fs-dev] " Eric Biggers
2020-06-05 16:08     ` Eric Biggers
2020-06-05 16:45     ` Nick Desaulniers via Linux-f2fs-devel
2020-06-05 16:45       ` Nick Desaulniers
2020-06-05 19:33       ` Eric Biggers
2020-06-05 19:33         ` Eric Biggers
2020-06-05 19:42         ` Nick Desaulniers via Linux-f2fs-devel
2020-06-05 19:42           ` Nick Desaulniers
2020-06-05 19:57           ` Eric Biggers [this message]
2020-06-05 19:57             ` Eric Biggers
2020-06-05 20:02             ` Nick Desaulniers via Linux-f2fs-devel
2020-06-05 20:02               ` Nick Desaulniers
2020-06-05 20:33               ` Eric Biggers
2020-06-05 20:33                 ` Eric Biggers
2020-06-05 21:28                 ` Nick Desaulniers via Linux-f2fs-devel
2020-06-05 21:28                   ` Nick Desaulniers

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=20200605195713.GL1373@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=jaegeuk@kernel.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=lkp@intel.com \
    --cc=ndesaulniers@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.