[openib-general] [PATCH][kdapl] replace spin_lock with spin_lock_irqsave in kdapltest

Itamar itamar at mellanox.co.il
Sun May 29 05:10:29 PDT 2005


With this patch i can run kdapltest -T T ... -t 4 -w 8 ...
I still see problems but in general this patch helps the stability a lot.

replace spin_lock with spin_lock_irqsave in kdapltest
Signed-off-by: Itamar Rabenstein <itamar at mellanox.co.il>

Index: test/dapl_transaction_stats.c
===================================================================
--- test/dapl_transaction_stats.c	(revision 2509)
+++ test/dapl_transaction_stats.c	(working copy)
@@ -45,12 +45,13 @@
 DT_transaction_stats_set_ready (DT_Tdep_Print_Head *phead, 
 				Transaction_Stats_t * transaction_stats)
 {
-    DT_Mdep_Lock (&transaction_stats->lock);
+	unsigned long flags;
+    spin_lock_irqsave (&transaction_stats->lock,flags);
     transaction_stats->wait_count--;
 
     DT_Tdep_PT_Debug (1,(phead,"Received Sync Message from server (%d left)\n",
 		    transaction_stats->wait_count));
-    DT_Mdep_Unlock (&transaction_stats->lock);
+    spin_unlock_irqrestore (&transaction_stats->lock,flags);
 }
 
 boolean_t
@@ -86,7 +87,8 @@
 		       unsigned int bytes_rdma_read,
 		       unsigned int bytes_rdma_write)
 {
-    DT_Mdep_Lock (&transaction_stats->lock);
+	unsigned long flags;
+    spin_lock_irqsave (&transaction_stats->lock,flags);
 
     /* look for the longest time... */
     if (time_ms > transaction_stats->time_ms)
@@ -99,5 +101,5 @@
     transaction_stats->bytes_recv += bytes_recv;
     transaction_stats->bytes_rdma_read += bytes_rdma_read;
     transaction_stats->bytes_rdma_write += bytes_rdma_write;
-    DT_Mdep_Unlock (&transaction_stats->lock);
+    spin_unlock_irqrestore (&transaction_stats->lock,flags);
 }
Index: test/dapl_server.c
===================================================================
--- test/dapl_server.c	(revision 2509)
+++ test/dapl_server.c	(working copy)
@@ -49,7 +49,7 @@
     unsigned char       *buffp          = NULL;
     unsigned char       *module         = "DT_cs_Server";
     int 		status 		= 0;
-
+	unsigned long flags;
     DAT_DTO_COOKIE	dto_cookie;
     struct dat_dto_completion_event_data dto_stat;
     u32          ret;
@@ -616,9 +616,9 @@
 
 
 	/* Count this new client and get ready for the next */
-	DT_Mdep_Lock (&ps_ptr->num_clients_lock);
+	spin_lock_irqsave (&ps_ptr->num_clients_lock,flags);
 	ps_ptr->num_clients++;
-	DT_Mdep_Unlock (&ps_ptr->num_clients_lock);
+	spin_unlock_irqrestore (&ps_ptr->num_clients_lock,flags);
 
 	/* we passed the pt_ptr to the thread and must now 'forget' it */
 	pt_ptr = NULL;
Index: test/dapl_thread.c
===================================================================
--- test/dapl_thread.c	(revision 2509)
+++ test/dapl_thread.c	(working copy)
@@ -83,6 +83,7 @@
 	      unsigned int stacksize)
 {
     Thread         *thread_ptr;
+	unsigned long flags;
     thread_ptr = (Thread *) DT_MemListAlloc (pt_ptr, "thread.c", THREAD, sizeof (Thread));
     if (thread_ptr == NULL)
     {
@@ -93,9 +94,9 @@
     thread_ptr->thread_handle = 0;
     thread_ptr->stacksize = stacksize;
 
-    DT_Mdep_Lock (&pt_ptr->Thread_counter_lock);
+    spin_lock_irqsave (&pt_ptr->Thread_counter_lock,flags);
     pt_ptr->Thread_counter++;
-    DT_Mdep_Unlock (&pt_ptr->Thread_counter_lock);
+    spin_unlock_irqrestore (&pt_ptr->Thread_counter_lock,flags);
 
     DT_Mdep_Thread_Init_Attributes (thread_ptr);
 
@@ -108,11 +109,12 @@
 void
 DT_Thread_Destroy (Thread * thread_ptr, Per_Test_Data_t * pt_ptr)
 {
+	unsigned long flags;
     if (thread_ptr)
     {
-	DT_Mdep_Lock (&pt_ptr->Thread_counter_lock);
+	spin_lock_irqsave (&pt_ptr->Thread_counter_lock,flags);
 	pt_ptr->Thread_counter--;
-	DT_Mdep_Unlock (&pt_ptr->Thread_counter_lock);
+	spin_unlock_irqrestore (&pt_ptr->Thread_counter_lock,flags);
 
 	DT_Mdep_Thread_Destroy_Attributes (thread_ptr);
 	DT_MemListFree (pt_ptr, thread_ptr);
Index: test/dapl_test_data.c
===================================================================
--- test/dapl_test_data.c	(revision 2509)
+++ test/dapl_test_data.c	(working copy)
@@ -27,7 +27,7 @@
 
 #include "dapl_proto.h"
 
-DT_Mdep_LockType     g_PerfTestLock;
+/*DT_Mdep_LockType     g_PerfTestLock;*/
 /*
  * check memory leaking int             alloc_count; DT_Mdep_LockType
  * Alloc_Count_Lock;
Index: test/dapl_transaction_test.c
===================================================================
--- test/dapl_transaction_test.c	(revision 2509)
+++ test/dapl_transaction_test.c	(working copy)
@@ -99,7 +99,7 @@
     unsigned int      i;
     DT_Tdep_Print_Head *phead;
     int status = 0;
-
+	unsigned long flags;
     phead = pt_ptr->Params.phead;
 
     pt_ptr->Countdown_Counter = cmd->num_threads;
@@ -129,9 +129,9 @@
     }
     DT_Thread_Destroy (pt_ptr->thread, pt_ptr);	    /* destroy Master thread */
 
-    DT_Mdep_Lock (&pt_ptr->ps_ptr->num_clients_lock);
+    spin_lock_irqsave (&pt_ptr->ps_ptr->num_clients_lock,flags);
     pt_ptr->ps_ptr->num_clients--;
-    DT_Mdep_Unlock (&pt_ptr->ps_ptr->num_clients_lock);
+    spin_unlock_irqrestore (&pt_ptr->ps_ptr->num_clients_lock,flags);
 
     /* NB: Server has no pt_ptr->remote_netaddr */
     DT_PrintMemList (pt_ptr);	    /* check if we return all space allocated */
@@ -239,7 +239,7 @@
     enum dat_event_number    event_num;
     DT_Tdep_Print_Head *phead;
     int status = 0;
-
+	unsigned long flags;
     pt_ptr = test_ptr->pt_ptr;
     thread = test_ptr->thread;
     phead = pt_ptr->Params.phead;
@@ -502,7 +502,7 @@
      */
     if (pt_ptr->local_is_server)
     {
-	DT_Mdep_Lock (&pt_ptr->Thread_counter_lock);
+	spin_lock_irqsave (&pt_ptr->Thread_counter_lock,flags);
 	pt_ptr->Countdown_Counter--;
 	/* Deliberate pre-decrement.  Post decrement won't
 	 * work here, so don't do it.
@@ -512,7 +512,7 @@
 	    DT_Mdep_wait_object_wakeup (&pt_ptr->synch_wait_object);
 	}
 
-	DT_Mdep_Unlock (&pt_ptr->Thread_counter_lock);
+	spin_unlock_irqrestore (&pt_ptr->Thread_counter_lock,flags);
     }
 
     for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
Index: test/dapl_performance_server.c
===================================================================
--- test/dapl_performance_server.c	(revision 2509)
+++ test/dapl_performance_server.c	(working copy)
@@ -36,7 +36,7 @@
     Performance_Test_t 		*test_ptr = NULL;
     DT_Tdep_Print_Head		*phead;
     int 			 status = 0;
-
+	unsigned long flags;
     phead = pt_ptr->Params.phead;
     DT_Tdep_PT_Debug (1,(phead,"Server: Starting performance test\n"));
 
@@ -75,9 +75,9 @@
     DT_Mdep_Thread_Detach (DT_Mdep_Thread_SELF ());	 /* AMM */
     DT_Thread_Destroy (pt_ptr->thread, pt_ptr);	    /* destroy Master thread */
 
-    DT_Mdep_Lock (&pt_ptr->ps_ptr->num_clients_lock);
+    spin_lock_irqsave (&pt_ptr->ps_ptr->num_clients_lock,flags);
     pt_ptr->ps_ptr->num_clients--;
-    DT_Mdep_Unlock (&pt_ptr->ps_ptr->num_clients_lock);
+    spin_unlock_irqrestore (&pt_ptr->ps_ptr->num_clients_lock,flags);
 
     DT_PrintMemList (pt_ptr);	    /* check if we return all space allocated */
     DT_Mdep_LockDestroy (&pt_ptr->Thread_counter_lock);
Index: test/dapl_memlist.c
===================================================================
--- test/dapl_memlist.c	(revision 2509)
+++ test/dapl_memlist.c	(working copy)
@@ -42,6 +42,7 @@
 {
     void           *buffptr;
     MemListEntry_t *entry_ptr;
+	unsigned long flags;
     buffptr = NULL;
     entry_ptr = NULL;
 
@@ -64,10 +65,10 @@
     entry_ptr->MemType = t;
     entry_ptr->mem_ptr = buffptr;
 
-    DT_Mdep_Lock (&pt_ptr->MemListLock);
+    spin_lock_irqsave (&pt_ptr->MemListLock,flags);
     entry_ptr->next = pt_ptr->MemListHead;
     pt_ptr->MemListHead = entry_ptr;
-    DT_Mdep_Unlock (&pt_ptr->MemListLock);
+    spin_unlock_irqrestore (&pt_ptr->MemListLock,flags);
 
     return buffptr;
 }
@@ -76,12 +77,13 @@
 DT_MemListFree (Per_Test_Data_t * pt_ptr, void *ptr)
 {
     MemListEntry_t *pre, *cur;
+	unsigned long flags;
     if (pt_ptr == 0)	      /* not use mem_list */
     {
 	DT_Mdep_Free (ptr);
 	return;
     }
-    DT_Mdep_Lock (&pt_ptr->MemListLock);
+    spin_lock_irqsave (&pt_ptr->MemListLock,flags);
     pre = NULL;
     cur = pt_ptr->MemListHead;
     while (cur)
@@ -106,7 +108,7 @@
 	cur = cur->next;
     }
 unlock_and_return:
-    DT_Mdep_Unlock (&pt_ptr->MemListLock);
+    spin_unlock_irqrestore (&pt_ptr->MemListLock,flags);
 }
 
 void
@@ -119,9 +121,9 @@
     };
     DT_Tdep_Print_Head *phead;
     MemListEntry_t *cur;
-
+	unsigned long flags;
     phead = pt_ptr->Params.phead;
-    DT_Mdep_Lock (&pt_ptr->MemListLock);
+    spin_lock_irqsave (&pt_ptr->MemListLock,flags);
     cur = pt_ptr->MemListHead;
     if (cur != 0)
     {
@@ -133,5 +135,5 @@
 		    cur->filename, type[cur->MemType]);
 	cur = cur->next;
     }
-    DT_Mdep_Unlock (&pt_ptr->MemListLock);
+    spin_unlock_irqrestore (&pt_ptr->MemListLock,flags);
 }
Index: include/dapl_test_data.h
===================================================================
--- include/dapl_test_data.h	(revision 2509)
+++ include/dapl_test_data.h	(working copy)
@@ -42,7 +42,7 @@
  * problems on the server side occasionally
  * the server will reject connections.
  */
-extern	 	DT_Mdep_LockType    g_PerfTestLock;
+/*extern	 	DT_Mdep_LockType    g_PerfTestLock; */
 
 /*
  * check memory leaking extern int              alloc_count ; extern
Index: kdapl/kdapl_module.c
===================================================================
--- kdapl/kdapl_module.c	(revision 2509)
+++ kdapl/kdapl_module.c	(working copy)
@@ -95,10 +95,10 @@
 				break;
 			}
 
-			DT_Mdep_Lock(&kdapltest_lock);
+			spin_lock_irq(&kdapltest_lock);
 			kdapltest_num++;
 			instance = kdapltest_num;
-			DT_Mdep_Unlock(&kdapltest_lock);
+			spin_unlock_irq(&kdapltest_lock);
 
 			local_params->phead = KDT_Print_Alloc(instance);
 			if (!local_params->phead) {
@@ -201,7 +201,7 @@
 static __init int kdapltest_init(void)
 {
 
-	DT_Mdep_LockInit(&g_PerfTestLock);	/* For uDAPL, this is done in Tdep_init() */
+   /* DT_Mdep_LockInit(&g_PerfTestLock);	 For uDAPL, this is done in Tdep_init() */
 	kdapltest_major = register_chrdev(0, "kdapltest", &kdapltest_fops);
 	DT_Mdep_LockInit(&kdapltest_lock);
 	kdapltest_num = 0;
@@ -218,7 +218,7 @@
 	KDT_Print_Destroy();
 	KDT_Evd_Destroy();
 	DT_Mdep_LockDestroy(&kdapltest_lock);
-	DT_Mdep_LockDestroy(&g_PerfTestLock);	/* For uDAPL, this is done in Tdep_end() */
+   /* DT_Mdep_LockDestroy(&g_PerfTestLock);	 For uDAPL, this is done in Tdep_end() */  
 }
 
 module_init(kdapltest_init);
Index: kdapl/kdapl_tdep_print.c
===================================================================
--- kdapl/kdapl_tdep_print.c	(revision 2509)
+++ kdapl/kdapl_tdep_print.c	(working copy)
@@ -106,7 +106,7 @@
     va_list		args;
     int			len;
     Tdep_Print_Entry 	*entry;
-
+	unsigned long flags;
     entry = DT_Mdep_Malloc (sizeof (Tdep_Print_Entry));
 
     va_start (args, fmt);
@@ -120,7 +120,7 @@
     }
     entry->next = NULL;
 
-    DT_Mdep_Lock (&phead->lock);
+    spin_lock_irqsave (&phead->lock,flags);
 
     if (phead->head == NULL)
     {
@@ -133,7 +133,7 @@
 	phead->tail = entry;
     }
     DT_Mdep_wait_object_wakeup (&phead->wait_object);
-    DT_Mdep_Unlock (&phead->lock);
+    spin_unlock_irqrestore (&phead->lock,flags);
 }
 
 int
@@ -143,10 +143,10 @@
     DT_Tdep_Print_Head  *phead;
     Tdep_Print_Entry    *entry;
     int rc;
-
+	unsigned long flags;
     buffer[0] = '\0';
 
-    DT_Mdep_Lock (&DT_Print_List_Lock);
+    spin_lock_irqsave (&DT_Print_List_Lock,flags);
     phead = DT_Print_List;
     while (phead)
     {
@@ -156,7 +156,7 @@
 	}
 	phead = phead->next;
     }
-    DT_Mdep_Unlock (&DT_Print_List_Lock);
+    spin_unlock_irqrestore (&DT_Print_List_Lock,flags);
 
     if (!phead)
     {
@@ -172,7 +172,7 @@
 	    return 0;
 	}
 
-	DT_Mdep_Lock (&phead->lock);
+	spin_lock_irqsave (&phead->lock,flags);
 	entry = phead->head;
 	if (entry)
 	{
@@ -184,7 +184,7 @@
 	    strncpy (buffer, entry->buffer, PRINT_MAX);
 	    DT_Mdep_Free (entry);
 	}
-	DT_Mdep_Unlock (&phead->lock);
+	spin_unlock_irqrestore (&phead->lock,flags);
     }
 
     len = strlen (buffer);
Index: kdapl/kdapl_tdep_evd.c
===================================================================
--- kdapl/kdapl_tdep_evd.c	(revision 2509)
+++ kdapl/kdapl_tdep_evd.c	(working copy)
@@ -105,7 +105,7 @@
     u32 		dat_status;
     struct dat_upcall_object upcall;
     Tdep_Evd		*evd_ptr;
-
+	unsigned long flags;
     evd_ptr = NULL;
     dat_status = DAT_SUCCESS;
 
@@ -139,10 +139,10 @@
     DT_Mdep_wait_object_init (&evd_ptr->wait_object);
 
     /* add evd_ptr to front of evd list */
-    DT_Mdep_Lock (&DT_Evd_Lock);
+    spin_lock_irqsave (&DT_Evd_Lock, flags);
     evd_ptr->evd_next = DT_Evd_List;
     DT_Evd_List = evd_ptr;
-    DT_Mdep_Unlock (&DT_Evd_Lock);
+    spin_unlock_irqrestore (&DT_Evd_Lock, flags);
 
 error:
     if (dat_status != DAT_SUCCESS)
@@ -161,7 +161,7 @@
     u32 dat_status;
     Tdep_Evd   *evd_ptr;    
     Tdep_Event *event;
-
+	unsigned long flags;
     dat_status = DAT_SUCCESS;
 
     /* find the evd_ptr associated with evd_handle */
@@ -181,7 +181,7 @@
                DAT_INTERNAL_ERROR;
     }
     /* Get event */
-    DT_Mdep_Lock (&DT_Evd_Lock);
+    spin_lock_irqsave (&DT_Evd_Lock, flags);
     event = evd_ptr->event_next; /* event present in evd_ptr corresponding to the given evd_handle */
     if (event)
     {
@@ -207,7 +207,7 @@
     {
         dat_status = DAT_QUEUE_EMPTY;
     }
-    DT_Mdep_Unlock (&DT_Evd_Lock);
+    spin_unlock_irqrestore (&DT_Evd_Lock, flags);
 
     return dat_status;
 }
@@ -261,7 +261,7 @@
     }
 
     /* Got event */
-    DT_Mdep_Lock (&DT_Evd_Lock);
+    spin_lock_irq (&DT_Evd_Lock);
     event = evd_ptr->event_next;
     if (event)
     {
@@ -286,7 +286,7 @@
 	}
     }
 
-    DT_Mdep_Unlock (&DT_Evd_Lock);
+    spin_unlock_irq (&DT_Evd_Lock);
     return dat_status;
 }
 
@@ -297,7 +297,7 @@
     Tdep_Evd	*last;
 
     last = NULL;
-    DT_Mdep_Lock (&DT_Evd_Lock);
+    spin_lock_irq (&DT_Evd_Lock);
     next = DT_Evd_List;
     if (next->evd_handle == evd_handle)
     {
@@ -315,7 +315,7 @@
 	    last->evd_next = next->evd_next;
 	}
     }
-    DT_Mdep_Unlock (&DT_Evd_Lock);
+    spin_unlock_irq (&DT_Evd_Lock);
 
     DT_Mdep_Free (next);
     return dat_evd_free(evd_handle);
@@ -331,7 +331,7 @@
 
     evd_ptr = (Tdep_Evd *) instance_data;
 
-    DT_Mdep_Lock (&DT_Evd_Lock);
+    spin_lock_irq (&DT_Evd_Lock);
     if (DT_Event_Free_List)
     {
 	event = DT_Event_Free_List;
@@ -356,6 +356,6 @@
 	    evd_ptr->event_last = event;
 	}
     }
-    DT_Mdep_Unlock (&DT_Evd_Lock);
+    spin_unlock_irq (&DT_Evd_Lock);
     DT_Mdep_wait_object_wakeup (&evd_ptr->wait_object);
 }
-- 
Itamar



More information about the general mailing list