Subject: Re: [patch 1/4] network dev read_mostly

From: Eric Dumazet <[email-masked]>
Date: Thu, 15 Mar 2007 07:28:35 +0100

Benjamin LaHaise a écrit :
> On Mon, Mar 12, 2007 at 02:08:18PM -0700, Stephen Hemminger wrote:
>> For Eric, mark packet type and network device watermarks
>> as read mostly.
> 
> The following x86-64 bits might be intersting, as they allow you to 
> completely eliminate the memory access for run time defined constants.  
> Note that read_always writes are non-atomic, so some other form of 
> protection is necessary for readers (and rcu won't cut it).  That can be 
> fixed somewhat by specifying the alignment for the mov instruction to 
> ensure writes are atomic, but for many uses that is overkill.  This kind 
> of change can make the biggest difference for high-latency cases, like L1 
> cache misses on the Prescott P4.  I've not benched it on a P4 of late, 
> though.
> 

Very very nice idea Ben !

However netdev_nit is not a good condidate because it might change quite often 
in fact :(

Clearly kmem_cache pointers are very good candidates.

One problem with your patch is that all read_always() of pointers are going to 
use 3 bytes more of code, thus raising icache pressure.

48 b8 c3 08 e8 8c af    mov    $0x71af8ce808c3,%rax
71 00 00

instead of %rip relative addressing

48 8b 05 99 f3 09 00    mov    652185(%rip),%rax