From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
Cc: Yum Rayan <yum.rayan@gmail.com>,
linux-kernel@vger.kernel.org, linux-pcmcia@lists.infradead.org,
dahinds@users.sourceforge.net, rddunlap@osdl.org
Subject: Re: [PATCH linux-2.6.12-rc2-mm3] smc91c92_cs: Reduce stack usage in smc91c92_event()
Date: Sat, 23 Apr 2005 02:12:28 +0200 [thread overview]
Message-ID: <20050423001228.GA6418@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <200504221122.51579.vda@port.imtp.ilyichevsk.odessa.ua>
On Fri, 22 April 2005 11:22:51 +0300, Denis Vlasenko wrote:
>
> I do it this way:
>
> int f()
> {
> - tuple_t tuple;
> - cisparse_t parse;
> - u_char buf[255];
> + struct {
> + tuple_t tuple;
> + cisparse_t parse;
> + u_char buf[255];
> + } local;
> + local = kmalloc(sizeof(*local),...); if(!local)...
> ...
> - tuple.Attributes = tuple.TupleOffset = 0;
> - tuple.TupleData = (cisdata_t *)buf;
> - tuple.TupleDataMax = sizeof(buf);
> + local->tuple.Attributes = local->tuple.TupleOffset = 0;
> + local->tuple.TupleData = (cisdata_t *)local->buf;
> + local->tuple.TupleDataMax = sizeof(local->buf);
>
> I see the following advantages:
>
> 1) struct is unnamed and local to function
> 2) Variables do not change their type, the just sit in local-> now.
> I can just add 'local->' to each affected variable,
> without "it was an object, now it is a pointer" changes.
> No need to replace . with ->, remove &, etc.
I'd have proposed the same, before reading further down in the patch.
Basically, the driver is full of duplication, so the exact same struct
can be used several times. Therefore, the downsides of your approach
seem to prevail.
> 3) I do not need to do this part of your patch which adds more locals:
> + tuple_t *tuple;
> + cisparse_t *parse;
> + cistpl_cftable_entry_t *cf;
> + u_char *buf;
> ...
> + tuple = &cfg_mem->tuple;
> + parse = &cfg_mem->parse;
> + buf = cfg_mem->buf;
> 4) in resulting asm one base pointer instead of many will require
> less registers
Yup. There are thousands of detail to improve in that driver. It's
current maintainership (there is none) may explain that state.
Jörn
--
Fantasy is more important than knowledge. Knowledge is limited,
while fantasy embraces the whole world.
-- Albert Einstein
next prev parent reply other threads:[~2005-04-23 0:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-21 22:02 Yum Rayan
2005-04-21 22:12 ` [PATCH linux-2.6.12-rc2-mm3] serial_cs: Reduce stack usage in serial_event() Yum Rayan
2005-04-22 8:22 ` [PATCH linux-2.6.12-rc2-mm3] smc91c92_cs: Reduce stack usage in smc91c92_event() Denis Vlasenko
2005-04-23 0:12 ` Jörn Engel [this message]
2005-04-23 15:21 ` Denis Vlasenko
2005-04-26 7:18 ` Yum Rayan
2005-04-26 9:46 ` Jörn Engel
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=20050423001228.GA6418@wohnheim.fh-wedel.de \
--to=joern@wohnheim.fh-wedel.de \
--cc=dahinds@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pcmcia@lists.infradead.org \
--cc=rddunlap@osdl.org \
--cc=vda@port.imtp.ilyichevsk.odessa.ua \
--cc=yum.rayan@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®