anv/allocator: Move the alignment assert for the pointer free list

Previously we asserted every time you tried to pack a pointer and a counter
together.  However, this wasn't really correct.  In the case where you try
to grab the last element of the list, the "next elemnet" value you get may
be bogus if someonoe else got there first.  This was leading to assertion
failures even though the allocator would safely fall through to the failure
case below.
This commit is contained in:
Jason Ekstrand 2016-03-07 21:22:46 -08:00
parent 8c2b9d1529
commit 3d4f2b0927

View file

@ -200,7 +200,6 @@ anv_free_list_push(union anv_free_list *list, void *map, int32_t offset)
#define PFL_COUNT(x) ((uintptr_t)(x) & 0xfff)
#define PFL_PTR(x) ((void *)((uintptr_t)(x) & ~0xfff))
#define PFL_PACK(ptr, count) ({ \
assert(((uintptr_t)(ptr) & 0xfff) == 0); \
(void *)((uintptr_t)(ptr) | (uintptr_t)((count) & 0xfff)); \
})
@ -230,6 +229,12 @@ anv_ptr_free_list_push(void **list, void *elem)
void *old, *current;
void **next_ptr = elem;
/* The pointer-based free list requires that the pointer be
* page-aligned. This is because we use the bottom 12 bits of the
* pointer to store a counter to solve the ABA concurrency problem.
*/
assert(((uintptr_t)elem & 0xfff) == 0);
old = *list;
do {
current = old;