[ofa-general] Re: [PATCH for-2.6.22] IB/cm: improve local id allocation
Michael S. Tsirkin
mst at dev.mellanox.co.il
Mon May 21 05:34:22 PDT 2007
> Quoting Or Gerlitz <ogerlitz at voltaire.com>:
> Subject: Re: [PATCH for-2.6.22] IB/cm: improve local id allocation
>
> 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.
No - the "cm.random_id_operand" is initialized at module load time.
That's why we have the static next_id iterator.
--
MST
More information about the general
mailing list