Re: subl $0x<huge_number>,%esp (was Re: a.out 66% faster...)

Philip Blundell (pjb27@cam.ac.uk)
Sun, 2 Mar 1997 15:44:24 +0000 (GMT)


On Sun, 2 Mar 1997, Paul Gortmaker wrote:

> Okay, here are the list of 0x100+ "offenders" for v2.0.29. Out of interest

> d54 (gcc2.7.2) <de4x5_ioctl> <--- Wheee! 3412/4096 = 83%

Yow. That's what comes of allocating an automatic array of 512 ethernet
addresses. A patch something along the lines of the following ought to
make things better.

phil

--- de4x5.c~ Sun Feb 2 13:18:37 1997
+++ de4x5.c Sun Mar 2 15:42:34 1997
@@ -4656,11 +4656,17 @@
int i, j, status = 0;
s32 omr;
union {
- u8 addr[(HASH_TABLE_LEN * ETH_ALEN)];
- u16 sval[(HASH_TABLE_LEN * ETH_ALEN) >> 1];
- u32 lval[(HASH_TABLE_LEN * ETH_ALEN) >> 2];
+ u8 *addr;
+ u16 *sval;
+ u32 *lval;
} tmp;
-
+
+ tmp = kmalloc(GFP_KERNEL, HASH_TABLE_LEN * ETH_ALEN);
+ if (!tmp) {
+ printk("%s: memory squeeze\n");
+ return -ENOMEM;
+ }
+
switch(ioc->cmd) {
case DE4X5_GET_HWADDR: /* Get the hardware address */
ioc->len = ETH_ALEN;
@@ -4912,6 +4918,7 @@
status = -EOPNOTSUPP;
}

+ kfree(tmp);
return status;
}