[PATCH] reduce stack usage in ixgb_ethtool_ioctl

STALE8007d

4 messages, 3 authors, 2004-09-19 · open the first message on its own page

[PATCH] reduce stack usage in ixgb_ethtool_ioctl

From: Denis Vlasenko <hidden>
Date: 2004-09-19 17:34:32

Stack usage reduced from 3024 (!) to 576.
Most of those 3k came from a bug:

#define IXGB_REG_DUMP_LEN  136*sizeof(uint32_t)
                              ^^^^^^^^^^^^^^^^^
...
uint32_t regs_buff[IXGB_REG_DUMP_LEN];

Bug fixed. Two large on-stack variables moved to kmalloc space.

Stack usage is still high because gcc will
allocate too much space for these cases:

        case ETHTOOL_GSET:{
                        struct ethtool_cmd ecmd = { ETHTOOL_GSET };
                        ixgb_ethtool_gset(adapter, &ecmd);
                        if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
                                return -EFAULT;
                        return 0;
                }
        case ETHTOOL_SSET:{
                        struct ethtool_cmd ecmd;
                        if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
                                return -EFAULT;
                        return ixgb_ethtool_sset(adapter, &ecmd);
                }

There will be space for _two_ ecmd's on stack.

Shall it be worked around with ugly union of structs
or we'll just wait for better gcc?

Compile-tested only.
--
vda

Re: [PATCH] reduce stack usage in ixgb_ethtool_ioctl

From: Dave Dillow <dave@thedillows.org>
Date: 2004-09-19 18:24:54

On Sun, 2004-09-19 at 13:33, Denis Vlasenko wrote:
Stack usage is still high because gcc will
allocate too much space for these cases:

        case ETHTOOL_GSET:{
                        struct ethtool_cmd ecmd = { ETHTOOL_GSET };
                        ixgb_ethtool_gset(adapter, &ecmd);
                        if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
                                return -EFAULT;
                        return 0;
                }
        case ETHTOOL_SSET:{
                        struct ethtool_cmd ecmd;
                        if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
                                return -EFAULT;
                        return ixgb_ethtool_sset(adapter, &ecmd);
                }

There will be space for _two_ ecmd's on stack.

Shall it be worked around with ugly union of structs
or we'll just wait for better gcc?
You could convert it to use ethtool_ops.
-- 
Dave Dillow [off-list ref]

Re: [PATCH] reduce stack usage in ixgb_ethtool_ioctl

From: Jeff Garzik <hidden>
Date: 2004-09-19 18:27:59

Dave Dillow wrote:
On Sun, 2004-09-19 at 13:33, Denis Vlasenko wrote:
quoted
Stack usage is still high because gcc will
allocate too much space for these cases:

       case ETHTOOL_GSET:{
                       struct ethtool_cmd ecmd = { ETHTOOL_GSET };
                       ixgb_ethtool_gset(adapter, &ecmd);
                       if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
                               return -EFAULT;
                       return 0;
               }
       case ETHTOOL_SSET:{
                       struct ethtool_cmd ecmd;
                       if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
                               return -EFAULT;
                       return ixgb_ethtool_sset(adapter, &ecmd);
               }

There will be space for _two_ ecmd's on stack.

Shall it be worked around with ugly union of structs
or we'll just wait for better gcc?

You could convert it to use ethtool_ops.
Check -mm to make sure viro hasn't already converted it to ethtool_ops...

	Jeff

Re: [PATCH] reduce stack usage in ixgb_ethtool_ioctl

From: Denis Vlasenko <hidden>
Date: 2004-09-19 18:47:28

quoted
quoted
       case ETHTOOL_GSET:{
                       struct ethtool_cmd ecmd = { ETHTOOL_GSET };
                       ixgb_ethtool_gset(adapter, &ecmd);
                       if (copy_to_user(addr, &ecmd, sizeof(ecmd)))
                               return -EFAULT;
                       return 0;
               }
       case ETHTOOL_SSET:{
                       struct ethtool_cmd ecmd;
                       if (copy_from_user(&ecmd, addr, sizeof(ecmd)))
                               return -EFAULT;
                       return ixgb_ethtool_sset(adapter, &ecmd);
               }

There will be space for _two_ ecmd's on stack.

Shall it be worked around with ugly union of structs
or we'll just wait for better gcc?
You could convert it to use ethtool_ops.
Check -mm to make sure viro hasn't already converted it to ethtool_ops...
Admit it: it's a conspiracy. Whenever I take some code to hack on, somebody
else takes care of it before I do ;)
--
vda
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help