mirror of
https://git.openafs.org/openafs.git
synced 2025-01-20 16:00:12 +00:00
hyperthreading-bad-20040625
Give folks an option of running afsd_service.exe on fewer processors than are installed in the machine. A new registry value TransarcAfsDaemon/Parameters MaxCPUs allows a restriction to be applied. Set to 1 to use a single CPU (or hyperthreading instance) The restriction is applied with SetProcessAffinityMask()
This commit is contained in:
parent
291f2e2043
commit
5f1c38764d
@ -205,6 +205,7 @@ int afsd_InitCM(char **reasonP)
|
||||
long logChunkSize;
|
||||
long stats;
|
||||
long traceBufSize;
|
||||
long maxcpus;
|
||||
long ltt, ltto;
|
||||
long rx_mtu, rx_nojumbo;
|
||||
char rootCellName[256];
|
||||
@ -258,6 +259,42 @@ int afsd_InitCM(char **reasonP)
|
||||
osi_panic(buf, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
dummyLen = sizeof(maxcpus);
|
||||
code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL,
|
||||
(BYTE *) &maxcpus, &dummyLen);
|
||||
if (code == ERROR_SUCCESS) {
|
||||
HANDLE hProcess;
|
||||
DWORD_PTR processAffinityMask, systemAffinityMask;
|
||||
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION,
|
||||
FALSE, GetCurrentProcessId());
|
||||
if ( hProcess != NULL &&
|
||||
GetProcessAffinityMask(hProcess, &processAffinityMask, &systemAffinityMask) )
|
||||
{
|
||||
int i, n, bits;
|
||||
DWORD_PTR mask, newAffinityMask;
|
||||
|
||||
#if defined(_WIN64)
|
||||
bits = 64;
|
||||
#else
|
||||
bits = 32;
|
||||
#endif
|
||||
for ( i=0, n=0, mask=1, newAffinityMask=0; i<bits && n<maxcpus; i++ ) {
|
||||
if ( processAffinityMask & mask ) {
|
||||
newAffinityMask |= mask;
|
||||
n++;
|
||||
}
|
||||
mask *= 2;
|
||||
}
|
||||
|
||||
SetProcessAffinityMask(hProcess, newAffinityMask);
|
||||
CloseHandle(hProcess);
|
||||
afsi_log("CPU Restrictions set to %d cpu(s); %d cpu(s) available", maxcpus, n);
|
||||
} else {
|
||||
afsi_log("CPU Restrictions set to %d cpu(s); unable to access process information", maxcpus);
|
||||
}
|
||||
}
|
||||
|
||||
dummyLen = sizeof(traceBufSize);
|
||||
code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
|
||||
(BYTE *) &traceBufSize, &dummyLen);
|
||||
|
Loading…
Reference in New Issue
Block a user