Discussion:
[patch] reduce stack usage of prism2mib_priv
Richard Kennedy
2008-04-26 13:33:50 UTC
Permalink
hi,
there's been a discussion on lkml about making 4k stacks the default for
x86, and Fedora already uses 4k stacks so we don't seem to have any
problems.

Even so, this simple patch just moves temporary buffers to allow gcc to
better manage the stack usage in prism2mib_priv.

checkstack reports the usage going from 1120 down to 480 in
prism2_usb.ko

I think it's worth doing this just to head off any problems before we
have them.

Cheers
Richard


diff --git a/src/prism2/driver/prism2mib.c b/src/prism2/driver/prism2mib.c
index 527816c..71cdf63 100644
--- a/src/prism2/driver/prism2mib.c
+++ b/src/prism2/driver/prism2mib.c
@@ -2698,15 +2698,6 @@ void *data)

int i, cnt, result, done;

- prism2sta_authlist_t old;
-
- /*
- ** "test" is a lot longer than necessary but who cares? ...as long as
- ** it is long enough!
- */
-
- UINT8 test[sizeof(wlandev->rx) + sizeof(hw->tallies)];
-
DBFENTER;

switch (mib->did) {
@@ -2727,13 +2718,14 @@ void *data)
** we copy the values.
*/

- if (isget)
+ if (isget) {
+ UINT8 test[sizeof(wlandev->rx)];
for (i = 0; i < 10; i++) {
memcpy(data, &wlandev->rx, sizeof(wlandev->rx));
memcpy(test, &wlandev->rx, sizeof(wlandev->rx));
if (memcmp(data, test, sizeof(wlandev->rx)) == 0) break;
}
-
+ }
break;

case DIDmib_p2_p2Table_p2CommunicationTallies:
@@ -2746,6 +2738,7 @@ void *data)
*/

if (isget) {
+ UINT8 test[sizeof(hw->tallies)];
result = hfa384x_drvr_commtallies(hw);

/* ?????? We need to wait a bit here for the */
@@ -2781,6 +2774,7 @@ void *data)
case DIDmib_p2_p2Table_p2Authenticated:

if (isget) {
+ prism2sta_authlist_t old;
prism2mib_priv_authlist(hw, &old);

macarray->cnt = 0;
@@ -2791,12 +2785,13 @@ void *data)
}
}
}
-
+
break;

case DIDmib_p2_p2Table_p2Associated:

if (isget) {
+ prism2sta_authlist_t old;
prism2mib_priv_authlist(hw, &old);

macarray->cnt = 0;
@@ -2807,7 +2802,7 @@ void *data)
}
}
}
-
+
break;

case DIDmib_p2_p2Table_p2PowerSaveUserCount:

Loading...