/* Allocations are always at least 64 byte aligned, so 1 is an invalid value.
* We use it to indicate the free list is empty. */
-#define EMPTY 1
-#define EMPTY2 UINT32_MAX
+#define EMPTY UINT32_MAX
#define PAGE_SIZE 4096
}
void
-anv_free_list_push2(union anv_free_list2 *list,
- struct anv_state_table *table,
- uint32_t first, uint32_t count)
+anv_free_list_push(union anv_free_list *list,
+ struct anv_state_table *table,
+ uint32_t first, uint32_t count)
{
- union anv_free_list2 current, old, new;
+ union anv_free_list current, old, new;
uint32_t last = first;
for (uint32_t i = 1; i < count; i++, last++)
}
struct anv_state *
-anv_free_list_pop2(union anv_free_list2 *list,
- struct anv_state_table *table)
+anv_free_list_pop(union anv_free_list *list,
+ struct anv_state_table *table)
{
- union anv_free_list2 current, new, old;
+ union anv_free_list current, new, old;
current.u64 = list->u64;
- while (current.offset != EMPTY2) {
+ while (current.offset != EMPTY) {
__sync_synchronize();
new.offset = table->map[current.offset].next;
new.count = current.count + 1;
assert(util_is_power_of_two_or_zero(block_size));
pool->block_size = block_size;
- pool->back_alloc_free_list = ANV_FREE_LIST2_EMPTY;
+ pool->back_alloc_free_list = ANV_FREE_LIST_EMPTY;
for (unsigned i = 0; i < ANV_STATE_BUCKETS; i++) {
- pool->buckets[i].free_list = ANV_FREE_LIST2_EMPTY;
+ pool->buckets[i].free_list = ANV_FREE_LIST_EMPTY;
pool->buckets[i].block.next = 0;
pool->buckets[i].block.end = 0;
}
}
uint32_t block_bucket = anv_state_pool_get_bucket(block_size);
- anv_free_list_push2(&pool->buckets[block_bucket].free_list,
- &pool->table, st_idx, count);
+ anv_free_list_push(&pool->buckets[block_bucket].free_list,
+ &pool->table, st_idx, count);
}
static struct anv_state
int32_t offset;
/* Try free list first. */
- state = anv_free_list_pop2(&pool->buckets[bucket].free_list,
- &pool->table);
+ state = anv_free_list_pop(&pool->buckets[bucket].free_list,
+ &pool->table);
if (state) {
assert(state->offset >= 0);
goto done;
/* Try to grab a chunk from some larger bucket and split it up */
for (unsigned b = bucket + 1; b < ANV_STATE_BUCKETS; b++) {
- state = anv_free_list_pop2(&pool->buckets[b].free_list, &pool->table);
+ state = anv_free_list_pop(&pool->buckets[b].free_list, &pool->table);
if (state) {
unsigned chunk_size = anv_state_pool_get_bucket_size(b);
int32_t chunk_offset = state->offset;
struct anv_state *state;
uint32_t alloc_size = pool->block_size;
- state = anv_free_list_pop2(&pool->back_alloc_free_list, &pool->table);
+ state = anv_free_list_pop(&pool->back_alloc_free_list, &pool->table);
if (state) {
assert(state->offset < 0);
goto done;
if (state.offset < 0) {
assert(state.alloc_size == pool->block_size);
- anv_free_list_push2(&pool->back_alloc_free_list,
- &pool->table, state.idx, 1);
+ anv_free_list_push(&pool->back_alloc_free_list,
+ &pool->table, state.idx, 1);
} else {
- anv_free_list_push2(&pool->buckets[bucket].free_list,
- &pool->table, state.idx, 1);
+ anv_free_list_push(&pool->buckets[bucket].free_list,
+ &pool->table, state.idx, 1);
}
}
* both the block pool and the state pools. Unfortunately, in order to
* solve the ABA problem, we can't use a single uint32_t head.
*/
-union anv_free_list2 {
+union anv_free_list {
struct {
uint32_t offset;
uint64_t u64;
};
-#define ANV_FREE_LIST2_EMPTY ((union anv_free_list2) { { UINT32_MAX, 0 } })
+#define ANV_FREE_LIST_EMPTY ((union anv_free_list) { { UINT32_MAX, 0 } })
struct anv_block_state {
union {
#define ANV_STATE_NULL ((struct anv_state) { .alloc_size = 0 })
struct anv_fixed_size_state_pool {
- union anv_free_list2 free_list;
+ union anv_free_list free_list;
struct anv_block_state block;
};
uint32_t block_size;
/** Free list for "back" allocations */
- union anv_free_list2 back_alloc_free_list;
+ union anv_free_list back_alloc_free_list;
struct anv_fixed_size_state_pool buckets[ANV_STATE_BUCKETS];
};
void anv_state_table_finish(struct anv_state_table *table);
VkResult anv_state_table_add(struct anv_state_table *table, uint32_t *idx,
uint32_t count);
-void anv_free_list_push2(union anv_free_list2 *list,
- struct anv_state_table *table,
- uint32_t idx, uint32_t count);
-struct anv_state* anv_free_list_pop2(union anv_free_list2 *list,
- struct anv_state_table *table);
+void anv_free_list_push(union anv_free_list *list,
+ struct anv_state_table *table,
+ uint32_t idx, uint32_t count);
+struct anv_state* anv_free_list_pop(union anv_free_list *list,
+ struct anv_state_table *table);
static inline struct anv_state *