From: Bart Van Assche Date: Mon, 6 Jan 2020 04:25:36 +0000 (-0800) Subject: Windows >= 7: Make fio_getaffinity() error reporting more detailed X-Git-Tag: fio-3.18~18^2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=2f56f0a0ba604cc6f3f4628927824cbc45938801 Windows >= 7: Make fio_getaffinity() error reporting more detailed Report different error messages for GetProcessGroupAffinity() failures and also if a process is associated with multiple process groups. Signed-off-by: Bart Van Assche --- diff --git a/os/windows/cpu-affinity.c b/os/windows/cpu-affinity.c index 87cb6650..69997b24 100644 --- a/os/windows/cpu-affinity.c +++ b/os/windows/cpu-affinity.c @@ -307,23 +307,32 @@ int fio_getaffinity(int pid, os_cpu_mask_t *mask) goto err; } - group_count = 1; + group_count = 16; /* * GetProcessGroupAffinity() seems to expect more than the natural * alignment for a USHORT from the area pointed to by current_groups so * arrange for maximum alignment by allocating via malloc() */ - current_groups = malloc(sizeof(USHORT)); + current_groups = malloc(group_count * sizeof(USHORT)); if (!current_groups) { log_err("fio_getaffinity: malloc failed\n"); goto err; } - if (GetProcessGroupAffinity(handle, &group_count, current_groups) == 0) { - /* NB: we also fail here if we are a multi-group process */ - log_err("fio_getaffinity: failed to get single group affinity for pid %d\n", pid); + if (!GetProcessGroupAffinity(handle, &group_count, current_groups)) { + log_err("%s: failed to get single group affinity for pid %d (%d)\n", + __func__, pid, GetLastError()); + goto err; + } + if (group_count > 1) { + log_err("%s: pid %d is associated with %d process groups\n", + __func__, pid, group_count); + goto err; + } + if (!GetProcessAffinityMask(handle, &process_mask, &system_mask)) { + log_err("%s: GetProcessAffinityMask() failed for pid\n", + __func__, pid); goto err; } - GetProcessAffinityMask(handle, &process_mask, &system_mask); /* Convert group and group relative mask to full CPU mask */ online_groups = GetActiveProcessorGroupCount();