[WSD] Added support for thread affinity.
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 6 Feb 2007 16:29:35 +0000 (16:29 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 6 Feb 2007 16:29:35 +0000 (16:29 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@572 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/wsd/user/ibsp_iblow.c
ulp/wsd/user/ibspdll.c
ulp/wsd/user/ibspdll.h

index d094ecd..dade094 100644 (file)
@@ -96,6 +96,7 @@ complete_wq(
                switch ( wc->wc_type ) \r
                {\r
                case IB_WC_RECV:\r
+               CL_ASSERT(wc->length != 0);\r
                        lpOverlapped->InternalHigh = wc->length;\r
 #ifdef IBSP_LOGGING\r
                        cl_spinlock_acquire( &socket_info->recv_lock );\r
@@ -113,15 +114,17 @@ complete_wq(
                        cl_atomic_inc(&g_ibsp.total_recv_compleated);\r
 #endif\r
                        break;\r
-#ifdef PERFMON_ENABLED\r
 \r
                case IB_WC_RDMA_READ:\r
                        lpOverlapped->InternalHigh = wc->length;\r
+#ifdef PERFMON_ENABLED\r
                        InterlockedIncrement64( &g_pm_stat.pdata[COMP_RECV] );\r
                        InterlockedExchangeAdd64( &g_pm_stat.pdata[BYTES_READ],\r
                                lpOverlapped->InternalHigh );\r
+#endif /* PERFMON_ENABLED */\r
                        break;\r
 \r
+#ifdef PERFMON_ENABLED\r
                case IB_WC_SEND:\r
                        InterlockedIncrement64( &g_pm_stat.pdata[COMP_SEND] );\r
                        InterlockedExchangeAdd64( &g_pm_stat.pdata[BYTES_SEND],\r
@@ -484,12 +487,21 @@ ib_cq_thread(
        cl_status_t                             cl_status;\r
        ib_api_status_t                 status;\r
        int                                             i;\r
+       DWORD_PTR old_afinity;\r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
 \r
        fzprint(("%s():%d:0x%x:0x%x: cq_tinfo=0x%p\n", __FUNCTION__,\r
                         __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), cq_tinfo));\r
 \r
+       old_afinity = SetThreadAffinityMask (GetCurrentThread (),g_dwPollThreadAffinityMask);\r
+       if (old_afinity == 0) {\r
+               OutputDebugString("SetThreadAffinityMask failed\n");\r
+       } else {\r
+               OutputDebugString("SetThreadAffinityMask succeeded\n");\r
+       }\r
+\r
+\r
        do\r
        {\r
                cl_status = cl_waitobj_wait_on( cq_tinfo->cq_waitobj, EVENT_NO_TIMEOUT, TRUE );\r
index 5be27ad..def0ea6 100644 (file)
@@ -58,6 +58,7 @@ int                           g_connect_err = WSAEADDRNOTAVAIL;
 uint8_t                        g_max_cm_retries = CM_RETRIES;\r
 uint8_t                        g_pkt_life_modifier = 0;\r
 uint8_t                        g_qp_retries = QP_ATTRIB_RETRY_COUNT;\r
+DWORD_PTR              g_dwPollThreadAffinityMask = 0;\r
 \r
 \r
 /*\r
@@ -126,6 +127,17 @@ _DllMain(
                if( i && i <= 16 )\r
                        g_max_poll = _tcstoul( env_var, NULL, 10 );\r
 \r
+               i = GetEnvironmentVariable( "IBWSD_POLL_THREAD_AFFINITY_MASK", env_var, sizeof(env_var) );\r
+               if( i && i <= 16 )\r
+                       g_dwPollThreadAffinityMask = _tcstoul( env_var, NULL, 10 );\r
+               else \r
+               {\r
+                       DWORD_PTR xx;\r
+                       BOOL ret = GetProcessAffinityMask(GetCurrentProcess(), &g_dwPollThreadAffinityMask, &xx);\r
+                       CL_ASSERT(ret != 0);\r
+                       ret = ret; \r
+               }    \r
+\r
                i = GetEnvironmentVariable( "IBWSD_SA_RETRY", env_var, sizeof(env_var) );\r
                if( i && i <= 16 )\r
                        g_sa_retries = _tcstoul( env_var, NULL, 10 );\r
index f76cb07..570a64a 100644 (file)
@@ -61,6 +61,8 @@ extern uint32_t               g_max_inline;
 extern uint32_t                g_max_poll;\r
 extern uint32_t                g_sa_timeout;\r
 extern uint32_t                g_sa_retries;\r
+extern DWORD_PTR       g_dwPollThreadAffinityMask;\r
+\r
 /* Allow users to control SA timeouts behavior - fall back on IPoIB or fail. */\r
 extern int                     g_connect_err;\r
 extern uint8_t         g_max_cm_retries;\r