linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
To: Yum Rayan <yum.rayan@gmail.com>,
	linux-kernel@vger.kernel.org, linux-pcmcia@lists.infradead.org
Cc: dahinds@users.sourceforge.net, joern@wohnheim.fh-wedel.de,
	rddunlap@osdl.org
Subject: Re: [PATCH linux-2.6.12-rc2-mm3] smc91c92_cs: Reduce stack usage in smc91c92_event()
Date: Fri, 22 Apr 2005 11:22:51 +0300	[thread overview]
Message-ID: <200504221122.51579.vda@port.imtp.ilyichevsk.odessa.ua> (raw)
In-Reply-To: <df35dfeb05042115021c24638b@mail.gmail.com>

On Friday 22 April 2005 01:02, Yum Rayan wrote:
> This patch reduces the stack usage of the function smc91c92_event() in
> smc91c92_cs driver from 3540 to 132. Currently this is the highest
> stack user in linux-2.6.12-rc2-mm3. I used a patched version of gcc
> 3.4.3 on i386 with -fno-unit-at-a-time disabled.
> 
> The patch has only been compile tested. It would be nice to get
> feedback if someone that owns the hardware can actually test this
> patch.
> 
> Acked-by: JЖrn Engel <joern@wohnheim.fh-wedel.de>
> Acked-by: Randy Dunlap <rddunlap@osdl.org>
> Signed-off-by: Yum Rayan <yum.rayan@gmail.com>
> 
>  smc91c92_cs.c |  287 ++++++++++++++++++++++++++++++++++++++--------------------
>  1 files changed, 189 insertions(+), 98 deletions(-)
> 
> diff -Nupr -X dontdiff
> linux-2.6.12-rc2-mm3.a/drivers/net/pcmcia/smc91c92_cs.c
> linux-2.6.12-rc2-mm3.b/drivers/net/pcmcia/smc91c92_cs.c
> --- linux-2.6.12-rc2-mm3.a/drivers/net/pcmcia/smc91c92_cs.c	2005-04-14
> 22:15:43.000000000 -0700
> +++ linux-2.6.12-rc2-mm3.b/drivers/net/pcmcia/smc91c92_cs.c	2005-04-20
> 18:12:00.000000000 -0700
> @@ -127,6 +127,12 @@ struct smc_private {
>      int				rx_ovrn;
>  };
>  
> +struct smc_cfg_mem {
> +    tuple_t tuple;
> +    cisparse_t parse;
> +    u_char buf[255];
> +};
> +
>  /* Special definitions for Megahertz multifunction cards */
>  #define MEGAHERTZ_ISR		0x0380
>  
> @@ -498,14 +504,24 @@ static int mhz_mfc_config(dev_link_t *li
>  {
>      struct net_device *dev = link->priv;
>      struct smc_private *smc = netdev_priv(dev);
> -    tuple_t tuple;
> -    cisparse_t parse;
> -    u_char buf[255];
> -    cistpl_cftable_entry_t *cf = &parse.cftable_entry;
> +    struct smc_cfg_mem *cfg_mem;
> +    tuple_t *tuple;
> +    cisparse_t *parse;
> +    cistpl_cftable_entry_t *cf;
> +    u_char *buf;

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.
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

Look into nfs4_proc_unlink_setup() for example.
I see that Trond do not use locally declared struct there,
but otherwise it is done as described above.
--
vda


  parent reply	other threads:[~2005-04-22  8:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21 22:02 [PATCH linux-2.6.12-rc2-mm3] smc91c92_cs: Reduce stack usage in smc91c92_event() 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 ` Denis Vlasenko [this message]
2005-04-23  0:12   ` [PATCH linux-2.6.12-rc2-mm3] smc91c92_cs: Reduce stack usage in smc91c92_event() Jörn Engel
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=200504221122.51579.vda@port.imtp.ilyichevsk.odessa.ua \
    --to=vda@port.imtp.ilyichevsk.odessa.ua \
    --cc=dahinds@users.sourceforge.net \
    --cc=joern@wohnheim.fh-wedel.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.org \
    --cc=rddunlap@osdl.org \
    --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;
as well as URLs for NNTP newsgroup(s).