[OpenAFS-devel] Force processor affinity on OpenAFS for Windows

Murawski, Rob rsm4@cssd.pitt.edu
Thu, 7 Aug 2003 13:30:21 -0400


We've been having some issues with the OpenAFS client on our Windows
2000 web servers (all multiprocessor machines) that we have been having
issues tracking down completely.  Most notably was the hang issue where
a request hangs IIS.

I haven't had a chance to find out where the issue lies, but I believe
that this is a work-around for the problem.  (We haven't had a hang in
weeks and we were seeing them at most every couple days)  In any case, I
believe that this is a useful feature to have available as Microsoft SQL
server now has the ability to force affinity to a single processor.

This proposed DIFF (against the 1.2.10 source) allows a new registry
setting (ProcessorAffinity which is a REG_DWORD) to force the processor
affinity of all of the AFS threads.  It is a bit-mapped field in a DWORD
value.  Setting the value to 0 forces no affinity, 1 forces it to
processor 1, 2 forces to processor 2, 3 forces to processor 1 *AND* 2, 4
forces to processor 3, etc.

Any comments or suggestions are welcome.  I also have a patch that
allows CM_DAEMONS and SMB_SERVERS threads to be dynamically created so
you are no longer limited to the startup values.  (It increases the
threads when needed)  This doesn't seem to help performance too much as
far as I can tell unless you have your threads set to low on
initialization.  Any interest in this?

--------------------------

--- openafs-1.2.10/src/WINNT/afsd/afsd_init.c	2003-06-06
17:12:09.000000000 -0400
+++ afsd_init.c	2003-08-07 13:15:35.000000000 -0400
@@ -182,7 +182,8 @@
 	long code;
 	/*int freelanceEnabled;*/
 	WSADATA WSAjunk;
-
+   long ProcessorAffinity;
+  =20
 	WSAStartup(0x0101, &WSAjunk);
=20
 	/* setup osidebug server at RPC slot 1000 */
@@ -435,6 +436,16 @@
 	}
 #endif /* AFS_FREELANCE_CLIENT */
=20
+	dummyLen =3D sizeof(ProcessorAffinity);
+	code =3D RegQueryValueEx(parmKey, "ProcessorAffinity", NULL, NULL,
+				(BYTE *) &ProcessorAffinity, &dummyLen);
+	if (code =3D=3D ERROR_SUCCESS)
+		afsi_log("Processor Affinity is %d",
ProcessorAffinity);
+	else {
+		ProcessorAffinity =3D 0;
+		afsi_log("Processor affinity defaulting to NONE");
+	}  =20
+  =20
 	RegCloseKey (parmKey);
=20
 	/* setup early variables */
@@ -476,6 +487,29 @@
 	cm_initParams.setTime =3D 0;
 	cm_initParams.memCache =3D 0;
=20
+   /* If we force a processor affinity, set it here */
+   if(ProcessorAffinity !=3D 0)
+   {
+
if(!SetProcessAffinityMask(GetCurrentProcess(),ProcessorAffinity))
+     	{
+	        HANDLE h; char *ptbuf[1];
+           h =3D RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
+           ptbuf[0] =3D "Unable to set processor affinity";
+           ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 0, NULL, 1, 0,
ptbuf, NULL);
+           DeregisterEventSource(h);
+           afsi_log("Unable to set processor affinity:
%d",GetLastError());
+      }
+      else
+      {
+	        HANDLE h; char *ptbuf[1];
+           h =3D RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
+           ptbuf[0] =3D "Set processor affinity";
+           ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,
ptbuf, NULL);
+           DeregisterEventSource(h);
+           afsi_log("Set processor affinity: %d",ProcessorAffinity);
+      }
+   }  =20
+  =20
 	/* initialize RX, and tell it to listen to port 7001, which is
used for
          * callback RPC messages.
          */


--------------------------
Rob Murawski=20
University of Pittsburgh=20
Computing Services and Systems Development=20