Subject: Re: [PATCH 3/4] llc: use a device based hash table to speed up multicast delivery

From: Eric Dumazet <[email-masked]>
Date: Fri, 04 Dec 2009 01:28:11 +0100

Octavian Purdila a écrit :
> On Friday 04 December 2009 01:52:44 you wrote:
>> Octavian Purdila a écrit :
> 
>>> Since at this point we are using UP ports contention is not really an
>>> issue for us. I've extrapolated this (lock per hash bucket) based on how
>>> locking is done in other places, like UDP.
>> Yes but you know we want to remove those locks per UDP hash bucket, since
>>  we dont really need them anymore. ;)
>>
>> If you remember, we had in the past one rwlock for the whole UDP table.
>>
>> Then this was converted to one spinlock per hash slot (128 slots) + RCU
>>  lookups for unicast RX
>>
>> Then we dynamically sized udp table at boot (up to 65536 slots)
>>
>> multicast optimization (holding lock for small duration + double hashing)
>>
>> bind optimization (thanks to double hashing)
>>
>> To be done :
>>
>> 1) multicast RX can be done without taking any lock, and RCU lookups
>> 2) zap all locks and use one lock, or a small array of hashed spinlocks
>>
> 
> Thanks for the nice summary Eric !
> 
> I still have one doubt related to this: we still need locking for creating and 
> destroying sockets to insert/remove them into/from the hash, RCU can't help us 
> here, right? 

Sure. RCU is used for readers only. We still need locks to protect writers
against them.

> 
> In that case wouldn't spinlock contention become an issue for short lived 
> connections? Probably not for UDP (or LLC), but for TCP I certainly can think 
> of a few usecases for short lived connections.

Yes, this is why an array of hashed spinlocks would be good, (as already done with TCP
for example, or IP route cache)

(Say you have a table of 65536 UDP slots on your high performance server,
handling millions of udp sockets, you dont _need_ 65536 spinlocks, but some number
related to number of cpus)