summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2021-06-08 15:08:50 -0700
committerEric Engestrom <eric@engestrom.ch>2021-06-16 08:40:20 +0200
commit61d145ba7902eea282cf1c76f910693f987f2d34 (patch)
tree8e8dce95fabb5b2d45fec35aaa95d68b055e038a
parentcd306105a11342987b712d8cc78d17c57849e8e3 (diff)
util: Zero out all of mask in util_set_thread_affinity
memset operates in bytes, and there are 8-bits in a byte. This is a very easy to miss typo. :( Fixes: 9758b1d416a1 ("util: add util_set_thread_affinity helpers including Windows support") Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11228> (cherry picked from commit a923e95b10152726a3cdf4bdbc35690425ce9bc3)
-rw-r--r--.pick_status.json2
-rw-r--r--src/util/u_thread.h4
2 files changed, 3 insertions, 3 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 69f9de36091..edf6148018e 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -652,7 +652,7 @@
"description": "util: Zero out all of mask in util_set_thread_affinity",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "9758b1d416a109f92e911d7bac6f00f9419affab"
},
diff --git a/src/util/u_thread.h b/src/util/u_thread.h
index 8366bfb6d49..a4c73cce884 100644
--- a/src/util/u_thread.h
+++ b/src/util/u_thread.h
@@ -142,7 +142,7 @@ util_set_thread_affinity(thrd_t thread,
if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) != 0)
return false;
- memset(old_mask, 0, num_mask_bits / 32);
+ memset(old_mask, 0, num_mask_bits / 8);
for (unsigned i = 0; i < num_mask_bits && i < CPU_SETSIZE; i++) {
if (CPU_ISSET(i, &cpuset))
old_mask[i / 32] |= 1u << (i % 32);
@@ -167,7 +167,7 @@ util_set_thread_affinity(thrd_t thread,
return false;
if (old_mask) {
- memset(old_mask, 0, num_mask_bits / 32);
+ memset(old_mask, 0, num_mask_bits / 8);
old_mask[0] = m;
#ifdef _WIN64