[openib-general] [PATCH] cm: randomize starting local CM ID
Sean Hefty
sean.hefty at intel.com
Wed Aug 2 11:24:32 PDT 2006
Eric,
Can you try running with this patch installed? This should decrease
the chances that a REQ will be seen as an old duplicate, rather than
a new request.
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: cm.c
===================================================================
--- cm.c (revision 8647)
+++ cm.c (working copy)
@@ -42,6 +42,7 @@
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/rbtree.h>
+#include <linux/random.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
@@ -73,6 +74,7 @@ static struct ib_cm {
struct rb_root remote_id_table;
struct rb_root remote_sidr_table;
struct idr local_id_table;
+ int next_id;
struct workqueue_struct *wq;
} cm;
@@ -301,11 +303,11 @@ static int cm_alloc_id(struct cm_id_priv
{
unsigned long flags;
int ret;
- 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++,
+ ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
+ cm.next_id++,
(__force int *) &cm_id_priv->id.local_id);
spin_unlock_irqrestore(&cm.lock, flags);
} while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
@@ -3390,6 +3392,7 @@ static int __init ib_cm_init(void)
cm.remote_id_table = RB_ROOT;
cm.remote_qp_table = RB_ROOT;
cm.remote_sidr_table = RB_ROOT;
+ get_random_bytes(&cm.next_id, sizeof cm.next_id);
idr_init(&cm.local_id_table);
idr_pre_get(&cm.local_id_table, GFP_KERNEL);
More information about the general
mailing list