Module: Mesa Branch: staging/20.0 Commit: 5ef9dccff3fda298af89218009e5a3553c296200 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5ef9dccff3fda298af89218009e5a3553c296200
Author: D Scott Phillips <[email protected]> Date: Fri Apr 17 10:28:06 2020 -0700 util/sparse_array: don't stomp head's counter on pop operations By temporarily storing the new_head by a uint32_t, we wipe out the counter section of the head pointer. Fixes: e4f01eca ("util: Add a free list structure for use with util_sparse_array") Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Rafael Antognolli <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4612> (cherry picked from commit dc3a17997b479f91f36b2421e9c41c11a025de47) --- .pick_status.json | 2 +- src/util/sparse_array.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index aeeb689ca4f..c35b0a1cfc4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -805,7 +805,7 @@ "description": "util/sparse_array: don't stomp head's counter on pop operations", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "e4f01eca3b3cd1701f21cacbb8d29fe688ba42bb" }, diff --git a/src/util/sparse_array.c b/src/util/sparse_array.c index 06816401309..39420473420 100644 --- a/src/util/sparse_array.c +++ b/src/util/sparse_array.c @@ -249,7 +249,7 @@ util_sparse_array_free_list_pop_idx(struct util_sparse_array_free_list *fl) uint32_t head_idx = current_head; /* Index is the bottom 32 bits */ void *head_elem = util_sparse_array_get(fl->arr, head_idx); uint32_t *head_next = (uint32_t *)((char *)head_elem + fl->next_offset); - uint32_t new_head = free_list_head(current_head, *head_next); + uint64_t new_head = free_list_head(current_head, *head_next); uint64_t old_head = p_atomic_cmpxchg(&fl->head, current_head, new_head); if (old_head == current_head) return head_idx; @@ -270,7 +270,7 @@ util_sparse_array_free_list_pop_elem(struct util_sparse_array_free_list *fl) uint32_t head_idx = current_head; /* Index is the bottom 32 bits */ void *head_elem = util_sparse_array_get(fl->arr, head_idx); uint32_t *head_next = (uint32_t *)((char *)head_elem + fl->next_offset); - uint32_t new_head = free_list_head(current_head, *head_next); + uint64_t new_head = free_list_head(current_head, *head_next); uint64_t old_head = p_atomic_cmpxchg(&fl->head, current_head, new_head); if (old_head == current_head) return head_elem; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
