[lkml]   [2003]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: reducing stack usage in v4l?
"Randy.Dunlap" <> writes:

> Hi,
> I was looking at stack usage in drivers/media/video/v4l1-compat.c::
> v4l_compat_translate_ioctl(). It's 0x924 bytes on my peecee.

Whoops. Hmm. I assumed having the variable declarations within the
case blocks where they are actually used helps to keep the stack size
small, i.e. use this ...

switch (cmd)
case FOO:
struct foo;
case BAR:
struct bar;

... instead of this:

struct foo;
struct bar;

switch (cmd) {

But when looking at the disasm output it is obvious that it isn't true
(at least with gcc 3.2). On the other hand it is common practice in
many drivers, there must be a reason for that, no? Any chance this
used to work with older gcc versions?

> It's fairly straightforward to change the stack space to
> kmalloc() space, but some of these functions (ioctls) are
> speed-critical, so I was wondering if the changes should still
> be done, or done only in some cases and not others, or wait
> until an oops is reported here....

Although v4l_compat_translate_ioctl() is probably one of the worst
offenders, this issue likely exists for lots of other ioctl functions
too: Lot of stack space is allocated but never used because the
variables for all cases are allocated but only one of the switch cases
actually runs ...

Not sure what is the best idea to fix that. Don't like the kmalloc
idea that much. The individual structs are not huge, the real problem
is that many of them are allocated and only few are needed. Any
chance to tell gcc that it should allocate block-local variables at
the start block not at the start of the function?


/join #zonenkinder
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:33    [W:0.086 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site