From: Bruce Cran Date: Fri, 18 Jan 2013 13:13:13 +0000 (+0000) Subject: Windows: fix off-by-one error in fio_cpu_set and add affinity error messages. X-Git-Tag: fio-2.0.14~117 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3cf1ff44af1a1cc17354ce495647448e1e4924e2 Windows: fix off-by-one error in fio_cpu_set and add affinity error messages. Signed-off-by: Jens Axboe --- diff --git a/os/os-windows.h b/os/os-windows.h index 0b199c52..6862226a 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -182,7 +182,12 @@ static inline int fio_setaffinity(int pid, os_cpu_mask_t cpumask) h = OpenThread(THREAD_QUERY_INFORMATION | THREAD_SET_INFORMATION, TRUE, pid); if (h != NULL) { bSuccess = SetThreadAffinityMask(h, cpumask); + if (!bSuccess) + log_err("fio_setaffinity failed: failed to set thread affinity (pid %d, mask %.16llx)\n", pid, cpumask); + CloseHandle(h); + } else { + log_err("fio_setaffinity failed: failed to get handle for pid %d\n", pid); } return (bSuccess)? 0 : -1; @@ -209,7 +214,7 @@ static inline void fio_cpu_clear(os_cpu_mask_t *mask, int cpu) static inline void fio_cpu_set(os_cpu_mask_t *mask, int cpu) { - *mask |= 1 << (cpu-1); + *mask |= 1 << cpu; } static inline int fio_cpuset_init(os_cpu_mask_t *mask)