Subject: Re: [PATCH] tg3 : avoid an expensive divide

From: Eric Dumazet <[email-masked]>
Date: Tue, 06 Feb 2007 22:35:19 +0100

Michael Chan a écrit :
> On Tue, 2007-02-06 at 21:53 +0100, Eric Dumazet wrote:
> 
>> Signed-off-by: Eric Dumazet <[email-masked]>
>> plain text document attachment (tg3_avoid_divide.patch)
>> --- linux-2.6.20/drivers/net/tg3.c.orig	2007-02-06 22:30:39.000000000 +0100
>> +++ linux-2.6.20-ed/drivers/net/tg3.c	2007-02-06 22:32:42.000000000 +0100
>> @@ -3384,7 +3384,7 @@
>>  		}
>>  next_pkt_nopost:
>>  		sw_idx++;
>> -		sw_idx %= TG3_RX_RCB_RING_SIZE(tp);
>> +		sw_idx &= (TG3_RX_RCB_RING_SIZE(tp) - 1);
>>  
>>  		/* Refresh hw_idx to see if there is new work */
>>  		if (sw_idx == hw_idx) {
> 
> There are other places doing similar divide (e.g. tg3_recycle_rx(),
> tg3_alloc_rx_skb()).  I think we should change them all.

Well, I checked whole tg3.o with objdump --disassemble and there are only 
three points using a div : tg3_nvram_phys_addr()/tg3_set_eeprom() &
tg3_open(), wich are seldom used :)

Eric