Windows: fix off-by-one error in fio_cpu_set and add affinity error messages.
[fio.git] / os / os-windows.h
index 0b199c5213cff429b576d90293310864b90ee8ef..6862226a4a949486427f759780de85eb33145511 100644 (file)
@@ -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)