From: Gerd Knorr <kraxel@bytesex.org>
To: linux-kernel@vger.kernel.org
Subject: Re: reducing stack usage in v4l?
Date: 05 Mar 2003 10:15:52 +0100 [thread overview]
Message-ID: <87u1eigomv.fsf@bytesex.org> (raw)
In-Reply-To: 32833.4.64.238.61.1046841945.squirrel@www.osdl.org
"Randy.Dunlap" <rddunlap@osdl.org> 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 ...
do_ioctl()
{
switch (cmd)
case FOO:
{
struct foo;
...
}
case BAR:
{
struct bar;
...
}
...
}
... instead of this:
do_ioctl()
{
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?
Gerd
--
/join #zonenkinder
next prev parent reply other threads:[~2003-03-05 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-05 5:25 reducing stack usage in v4l? Randy.Dunlap
2003-03-05 5:43 ` Andrew Morton
2003-03-05 9:15 ` Gerd Knorr [this message]
2003-03-05 9:35 ` Russell King
2003-03-05 15:34 ` Randy.Dunlap
2003-03-05 21:40 ` Jörn Engel
2003-03-11 4:27 ` Randy.Dunlap
2003-03-11 9:19 ` Gerd Knorr
2003-03-11 16:29 ` Alan Cox
2003-03-11 15:36 ` Daniel Jacobowitz
2003-03-05 11:50 ` mdew
2003-03-05 12:28 ` Gerd Knorr
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=87u1eigomv.fsf@bytesex.org \
--to=kraxel@bytesex.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox