summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2020-01-05 20:25:36 -0800
committerBart Van Assche <bvanassche@acm.org>2020-01-06 13:39:59 -0800
commit2f56f0a0ba604cc6f3f4628927824cbc45938801 (patch)
tree650426443da4334a22b2a072bff5720b44a2c667 /os
parenta19579545153e46b8bc13b9d59c4aa6f1e2af2ed (diff)
downloadfio-2f56f0a0ba604cc6f3f4628927824cbc45938801.tar.gz
fio-2f56f0a0ba604cc6f3f4628927824cbc45938801.tar.bz2
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 <bvanassche@acm.org>
Diffstat (limited to 'os')
-rw-r--r--os/windows/cpu-affinity.c21
1 files changed, 15 insertions, 6 deletions
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();