aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@dev.mellanox.co.il>2007-05-21 12:06:54 -0400
committerRoland Dreier <rolandd@cisco.com>2007-05-21 16:41:29 -0400
commit9f81036c54ed1f860d2807c5a6aa4f2b30c21204 (patch)
treeab0eacf7aa4a78bce8aa96073678244d01c8175d /drivers/infiniband
parent518b1646f8a31904ca637b8df0c1e31c34a7a3c2 (diff)
IB/cm: Improve local id allocation
The IB CM uses an idr for local id allocations, with a running counter as start_id. This fails to generate distinct ids if 1. An id is constantly created and destroyed 2. A chunk of ids just beyond the current next_id value is occupied This in turn leads to an increased chance of connection request being mis-detected as a duplicate, sometimes for several retries, until next_id gets past the block of allocated ids. This has been observed in practice. As a fix, remember the last id allocated and start immediately above it. This also fixes a problem with the old code, where next_id might overflow and become negative. Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il> Acked-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/cm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index eff591deeb46..e840434a96d8 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -306,7 +306,9 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
306 do { 306 do {
307 spin_lock_irqsave(&cm.lock, flags); 307 spin_lock_irqsave(&cm.lock, flags);
308 ret = idr_get_new_above(&cm.local_id_table, cm_id_priv, 308 ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
309 next_id++, &id); 309 next_id, &id);
310 if (!ret)
311 next_id = ((unsigned) id + 1) & MAX_ID_MASK;
310 spin_unlock_irqrestore(&cm.lock, flags); 312 spin_unlock_irqrestore(&cm.lock, flags);
311 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); 313 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
312 314