From: Jeffrey Altman Date: Sat, 14 Jan 2012 15:31:01 +0000 (-0500) Subject: Windows: restrict service to 2 cpus by default X-Git-Tag: upstream/1.6.1.pre4^2~19 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e42640ec102838c8de2185e9247ac504b04aea09;p=packages%2Fo%2Fopenafs.git Windows: restrict service to 2 cpus by default Performance drops off considerably when the number of processors increases due to lock contention and the cm_SyncOp wait processing. If the MaxCPUs registry value is not set, limit ourselves to two. Setting MaxCPUs to zero permits use of all CPUs. Reviewed-on: http://gerrit.openafs.org/6555 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman (cherry picked from commit 69196e41ec9c5a6ce8efd370fb8582f66667bcf7) Change-Id: I0cf2d2eeb3d8f7c708e7c365520f10fcd5f22d83 Reviewed-on: http://gerrit.openafs.org/6822 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index f3d8a315f..ac4c7b299 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -603,7 +603,11 @@ afsd_InitCM(char **reasonP) dummyLen = sizeof(maxcpus); code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL, (BYTE *) &maxcpus, &dummyLen); - if (code == ERROR_SUCCESS) { + if (code != ERROR_SUCCESS) { + maxcpus = 2; + } + + { HANDLE hProcess; DWORD_PTR processAffinityMask, systemAffinityMask; @@ -612,7 +616,7 @@ afsd_InitCM(char **reasonP) if ( hProcess != NULL && GetProcessAffinityMask(hProcess, &processAffinityMask, &systemAffinityMask) ) { - int i, n, bits; + int i, n, bits, cpu_count = 0; DWORD_PTR mask, newAffinityMask; #if defined(_WIN64) @@ -620,19 +624,26 @@ afsd_InitCM(char **reasonP) #else bits = 32; #endif - for ( i=0, n=0, mask=1, newAffinityMask=0; i