[ofa-general] [PATCH for-2.6.22] IB/cm: improve local id allocation

Or Gerlitz ogerlitz at voltaire.com
Mon May 21 05:28:37 PDT 2007


Michael S. Tsirkin wrote:
> IB/cm uses idr for local id allocations, with a running counter
> as start_id. This fails to generate distinct ids 

> static int cm_alloc_id(struct cm_id_private *cm_id_priv)
> {
>         unsigned long flags;
>         int ret, id;
>         static int next_id;
> 
>         do {
>                 spin_lock_irqsave(&cm.lock, flags);
>                 ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
>                                         next_id++, &id);
>                 spin_unlock_irqrestore(&cm.lock, flags);
>         } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
> 
>         cm_id_priv->id.local_id = (__force __be32) (id ^ cm.random_id_operand);

Doesn't this Xor of the resulted ID with a random value done after the 
idr allocation causes the cm to --always-- produce distinct ids???

Or.






More information about the general mailing list