[Libguestfs] [PATCH v2] Use less stack.

Richard W.M. Jones rjones at redhat.com
Mon Mar 7 18:00:29 UTC 2016


On Mon, Mar 07, 2016 at 05:12:33PM +0100, Pino Toscano wrote:
> On Monday 07 March 2016 11:18:32 Richard W.M. Jones wrote:
> > +#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wstack-usage=10000"
> > +#endif
> > +
> >  /* Takes optional arguments, consult optargs_bitmask. */
> >  int
> >  do_btrfs_filesystem_resize (const char *filesystem, int64_t size)
> 
> Is this because of the argv[MAX_ARGS] here ^ and in do_mkfs_btrfs?
> (Similar notes for all the other diagnostic markers added by this
> patch.)

Yes.

> As slightly related change (although that can be done after this patch),
> something to reduce a bit the stacks in the daemon would be reduce the
> MAX_ARGS to values closer (but not too much) than the actual needs.
> I see most of the MAX_ARGS=64 cases have no more than 10 arguments
> added, even in the worst case...

OK, but I wouldn't want to go too small.  There's not any particular
need to reduce stack frames below, say, 4K.  The real issues with
large stack frames are:

 - JVM & other environments with small per-thread stacks

 - arbitrarily large stack frames controlled from untrusted sources

 - avoiding using BUFSIZ, PATH_MAX and similar where we don't directly
   control those constants, so we might encounter a system where they
   are much larger [mostly we've got rid of PATH_MAX for other reasons]

 - to a lesser extent the previous point applies even to things we do
   control like GUESTFS_MAX_CHUNK_SIZE where we might conceivably wish
   to increase them in future.

I have fixed all the other things you noted, and am just testing
everything again.

Thanks,

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list