gallium: switch drivers to the slab allocator in src/util
authorMarek Olšák <marek.olsak@amd.com>
Sun, 28 Aug 2016 09:05:14 +0000 (11:05 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 6 Sep 2016 12:24:04 +0000 (14:24 +0200)
30 files changed:
src/gallium/auxiliary/Makefile.sources
src/gallium/auxiliary/util/u_slab.c [deleted file]
src/gallium/auxiliary/util/u_slab.h [deleted file]
src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_query_hw.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/i915/i915_context.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_resource_buffer.c
src/gallium/drivers/i915/i915_resource_texture.c
src/gallium/drivers/ilo/ilo_context.c
src/gallium/drivers/ilo/ilo_context.h
src/gallium/drivers/ilo/ilo_transfer.c
src/gallium/drivers/ilo/shader/toy_compiler.c
src/gallium/drivers/ilo/shader/toy_compiler.h
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_screen.h
src/gallium/drivers/r300/r300_screen_buffer.c
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/vc4/vc4_context.c
src/gallium/drivers/vc4/vc4_context.h
src/gallium/drivers/vc4/vc4_resource.c
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_context.h
src/gallium/drivers/virgl/virgl_texture.c

index 093c45b48fe947ebd17913e4b3e1202e208fd980..f8954c904072687583d9aa50185479aa1bfbdc19 100644 (file)
@@ -284,8 +284,6 @@ C_SOURCES := \
        util/u_sampler.h \
        util/u_simple_shaders.c \
        util/u_simple_shaders.h \
-       util/u_slab.c \
-       util/u_slab.h \
        util/u_split_prim.h \
        util/u_sse.h \
        util/u_string.h \
diff --git a/src/gallium/auxiliary/util/u_slab.c b/src/gallium/auxiliary/util/u_slab.c
deleted file mode 100644 (file)
index 7e7d43b..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#include "util/u_slab.h"
-
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "util/simple_list.h"
-
-#include <stdio.h>
-
-#define UTIL_SLAB_MAGIC 0xcafe4321
-
-/* The block is either allocated memory or free space. */
-struct util_slab_block {
-   /* The header. */
-   /* The first next free block. */
-   struct util_slab_block *next_free;
-
-   intptr_t magic;
-
-   /* Memory after the last member is dedicated to the block itself.
-    * The allocated size is always larger than this structure. */
-};
-
-static struct util_slab_block *
-util_slab_get_block(struct util_slab_mempool *pool,
-                    struct util_slab_page *page, unsigned index)
-{
-   return (struct util_slab_block*)
-          ((uint8_t*)page + sizeof(struct util_slab_page) +
-           (pool->block_size * index));
-}
-
-static void util_slab_add_new_page(struct util_slab_mempool *pool)
-{
-   struct util_slab_page *page;
-   struct util_slab_block *block;
-   unsigned i;
-
-   page = MALLOC(pool->page_size);
-   insert_at_tail(&pool->list, page);
-
-   /* Mark all blocks as free. */
-   for (i = 0; i < pool->num_blocks-1; i++) {
-      block = util_slab_get_block(pool, page, i);
-      block->next_free = util_slab_get_block(pool, page, i+1);
-      block->magic = UTIL_SLAB_MAGIC;
-   }
-
-   block = util_slab_get_block(pool, page, pool->num_blocks-1);
-   block->next_free = pool->first_free;
-   block->magic = UTIL_SLAB_MAGIC;
-   pool->first_free = util_slab_get_block(pool, page, 0);
-   pool->num_pages++;
-
-#if 0
-   fprintf(stderr, "New page! Num of pages: %i\n", pool->num_pages);
-#endif
-}
-
-static void *util_slab_alloc_st(struct util_slab_mempool *pool)
-{
-   struct util_slab_block *block;
-
-   if (!pool->first_free)
-      util_slab_add_new_page(pool);
-
-   block = pool->first_free;
-   assert(block->magic == UTIL_SLAB_MAGIC);
-   pool->first_free = block->next_free;
-
-   return (uint8_t*)block + sizeof(struct util_slab_block);
-}
-
-static void util_slab_free_st(struct util_slab_mempool *pool, void *ptr)
-{
-   struct util_slab_block *block =
-         (struct util_slab_block*)
-         ((uint8_t*)ptr - sizeof(struct util_slab_block));
-
-   assert(block->magic == UTIL_SLAB_MAGIC);
-   block->next_free = pool->first_free;
-   pool->first_free = block;
-}
-
-static void *util_slab_alloc_mt(struct util_slab_mempool *pool)
-{
-   void *mem;
-
-   pipe_mutex_lock(pool->mutex);
-   mem = util_slab_alloc_st(pool);
-   pipe_mutex_unlock(pool->mutex);
-   return mem;
-}
-
-static void util_slab_free_mt(struct util_slab_mempool *pool, void *ptr)
-{
-   pipe_mutex_lock(pool->mutex);
-   util_slab_free_st(pool, ptr);
-   pipe_mutex_unlock(pool->mutex);
-}
-
-void util_slab_set_thread_safety(struct util_slab_mempool *pool,
-                                    enum util_slab_threading threading)
-{
-   pool->threading = threading;
-
-   if (threading) {
-      pool->alloc = util_slab_alloc_mt;
-      pool->free = util_slab_free_mt;
-   } else {
-      pool->alloc = util_slab_alloc_st;
-      pool->free = util_slab_free_st;
-   }
-}
-
-void util_slab_create(struct util_slab_mempool *pool,
-                      unsigned item_size,
-                      unsigned num_blocks,
-                      enum util_slab_threading threading)
-{
-   item_size = align(item_size, sizeof(intptr_t));
-
-   pool->num_pages = 0;
-   pool->num_blocks = num_blocks;
-   pool->block_size = sizeof(struct util_slab_block) + item_size;
-   pool->block_size = align(pool->block_size, sizeof(intptr_t));
-   pool->page_size = sizeof(struct util_slab_page) +
-                     num_blocks * pool->block_size;
-   pool->first_free = NULL;
-
-   make_empty_list(&pool->list);
-
-   pipe_mutex_init(pool->mutex);
-
-   util_slab_set_thread_safety(pool, threading);
-}
-
-void util_slab_destroy(struct util_slab_mempool *pool)
-{
-   struct util_slab_page *page, *temp;
-
-   if (pool->list.next) {
-      foreach_s(page, temp, &pool->list) {
-         remove_from_list(page);
-         FREE(page);
-      }
-   }
-
-   pipe_mutex_destroy(pool->mutex);
-}
diff --git a/src/gallium/auxiliary/util/u_slab.h b/src/gallium/auxiliary/util/u_slab.h
deleted file mode 100644 (file)
index 0df039b..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-/**
- * @file
- * Simple slab allocator for equally sized memory allocations.
- * util_slab_alloc and util_slab_free have time complexity in O(1).
- *
- * Good for allocations which have very low lifetime and are allocated
- * and freed very often. Use a profiler first to know if it's worth using it!
- *
- * Candidates: transfer_map
- *
- * @author Marek Olšák
- */
-
-#ifndef U_SLAB_H
-#define U_SLAB_H
-
-#include "os/os_thread.h"
-
-enum util_slab_threading {
-   UTIL_SLAB_SINGLETHREADED = FALSE,
-   UTIL_SLAB_MULTITHREADED = TRUE
-};
-
-/* The page is an array of blocks (allocations). */
-struct util_slab_page {
-   /* The header (linked-list pointers). */
-   struct util_slab_page *prev, *next;
-
-   /* Memory after the last member is dedicated to the page itself.
-    * The allocated size is always larger than this structure. */
-};
-
-struct util_slab_mempool {
-   /* Public members. */
-   void *(*alloc)(struct util_slab_mempool *pool);
-   void (*free)(struct util_slab_mempool *pool, void *ptr);
-
-   /* Private members. */
-   struct util_slab_block *first_free;
-
-   struct util_slab_page list;
-
-   unsigned block_size;
-   unsigned page_size;
-   unsigned num_blocks;
-   unsigned num_pages;
-   enum util_slab_threading threading;
-
-   pipe_mutex mutex;
-};
-
-void util_slab_create(struct util_slab_mempool *pool,
-                      unsigned item_size,
-                      unsigned num_blocks,
-                      enum util_slab_threading threading);
-
-void util_slab_destroy(struct util_slab_mempool *pool);
-
-void util_slab_set_thread_safety(struct util_slab_mempool *pool,
-                                 enum util_slab_threading threading);
-
-static inline void *
-util_slab_alloc(struct util_slab_mempool *pool)
-{
-   return pool->alloc(pool);
-}
-
-static inline void
-util_slab_free(struct util_slab_mempool *pool, void *ptr)
-{
-   pool->free(pool, ptr);
-}
-
-#endif
index ad62fd605ddce1093f7006ac0436efc494d65cd5..f8604f132ad056e0d3685d12a2eb4267144a43d1 100644 (file)
@@ -121,7 +121,7 @@ fd_context_destroy(struct pipe_context *pctx)
        if (ctx->primconvert)
                util_primconvert_destroy(ctx->primconvert);
 
-       util_slab_destroy(&ctx->transfer_pool);
+       slab_destroy(&ctx->transfer_pool);
 
        for (i = 0; i < ARRAY_SIZE(ctx->pipe); i++) {
                struct fd_vsc_pipe *pipe = &ctx->pipe[i];
@@ -265,8 +265,8 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
                ctx->batch = fd_bc_alloc_batch(&screen->batch_cache, ctx);
        }
 
-       util_slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer),
-                       16, UTIL_SLAB_SINGLETHREADED);
+       slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer),
+                       16);
 
        fd_draw_init(pctx);
        fd_resource_context_init(pctx);
index 037c199c245fcd90e26244a4d7caf5e4ade04d0d..e1b7b237ad3858f95ed3d55c2fe154a2960c72f5 100644 (file)
@@ -33,7 +33,7 @@
 #include "indices/u_primconvert.h"
 #include "util/u_blitter.h"
 #include "util/list.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 #include "util/u_string.h"
 
 #include "freedreno_batch.h"
@@ -121,11 +121,11 @@ struct fd_context {
        struct primconvert_context *primconvert;
 
        /* slab for pipe_transfer allocations: */
-       struct util_slab_mempool transfer_pool;
+       struct slab_mempool transfer_pool;
 
        /* slabs for fd_hw_sample and fd_hw_sample_period allocations: */
-       struct util_slab_mempool sample_pool;
-       struct util_slab_mempool sample_period_pool;
+       struct slab_mempool sample_pool;
+       struct slab_mempool sample_period_pool;
 
        /* sample-providers for hw queries: */
        const struct fd_hw_sample_provider *sample_providers[MAX_HW_SAMPLE_PROVIDERS];
index e5ef51a0b98803c693ddb57104b9536bb2884cc2..470826a94c88b7eeff3dff1f7b907098af5521c3 100644 (file)
@@ -108,10 +108,10 @@ resume_query(struct fd_batch *batch, struct fd_hw_query *hq,
        assert(idx >= 0);   /* query never would have been created otherwise */
        assert(!hq->period);
        batch->active_providers |= (1 << idx);
-       hq->period = util_slab_alloc(&batch->ctx->sample_period_pool);
+       hq->period = slab_alloc_st(&batch->ctx->sample_period_pool);
        list_inithead(&hq->period->list);
        hq->period->start = get_sample(batch, ring, hq->base.type);
-       /* NOTE: util_slab_alloc() does not zero out the buffer: */
+       /* NOTE: slab_alloc_st() does not zero out the buffer: */
        hq->period->end = NULL;
 }
 
@@ -137,7 +137,7 @@ destroy_periods(struct fd_context *ctx, struct fd_hw_query *hq)
                fd_hw_sample_reference(ctx, &period->start, NULL);
                fd_hw_sample_reference(ctx, &period->end, NULL);
                list_del(&period->list);
-               util_slab_free(&ctx->sample_period_pool, period);
+               slab_free_st(&ctx->sample_period_pool, period);
        }
 }
 
@@ -339,13 +339,13 @@ fd_hw_create_query(struct fd_context *ctx, unsigned query_type)
 struct fd_hw_sample *
 fd_hw_sample_init(struct fd_batch *batch, uint32_t size)
 {
-       struct fd_hw_sample *samp = util_slab_alloc(&batch->ctx->sample_pool);
+       struct fd_hw_sample *samp = slab_alloc_st(&batch->ctx->sample_pool);
        pipe_reference_init(&samp->reference, 1);
        samp->size = size;
        debug_assert(util_is_power_of_two(size));
        batch->next_sample_offset = align(batch->next_sample_offset, size);
        samp->offset = batch->next_sample_offset;
-       /* NOTE: util_slab_alloc() does not zero out the buffer: */
+       /* NOTE: slab_alloc_st() does not zero out the buffer: */
        samp->prsc = NULL;
        samp->num_tiles = 0;
        samp->tile_stride = 0;
@@ -376,7 +376,7 @@ void
 __fd_hw_sample_destroy(struct fd_context *ctx, struct fd_hw_sample *samp)
 {
        pipe_resource_reference(&samp->prsc, NULL);
-       util_slab_free(&ctx->sample_pool, samp);
+       slab_free_st(&ctx->sample_pool, samp);
 }
 
 /* called from gmem code once total storage requirements are known (ie.
@@ -486,10 +486,10 @@ fd_hw_query_init(struct pipe_context *pctx)
 {
        struct fd_context *ctx = fd_context(pctx);
 
-       util_slab_create(&ctx->sample_pool, sizeof(struct fd_hw_sample),
-                       16, UTIL_SLAB_SINGLETHREADED);
-       util_slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period),
-                       16, UTIL_SLAB_SINGLETHREADED);
+       slab_create(&ctx->sample_pool, sizeof(struct fd_hw_sample),
+                       16);
+       slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period),
+                       16);
        list_inithead(&ctx->active_queries);
 }
 
@@ -498,6 +498,6 @@ fd_hw_query_fini(struct pipe_context *pctx)
 {
        struct fd_context *ctx = fd_context(pctx);
 
-       util_slab_destroy(&ctx->sample_pool);
-       util_slab_destroy(&ctx->sample_period_pool);
+       slab_destroy(&ctx->sample_pool);
+       slab_destroy(&ctx->sample_period_pool);
 }
index 2a4fd7442c8070f9a8aa47a3681b385fa6161da8..3cc6654b740c8a83b9b69b24c01291b4fe0b4197 100644 (file)
@@ -425,7 +425,7 @@ fd_resource_transfer_unmap(struct pipe_context *pctx,
                                   ptrans->box.x + ptrans->box.width);
 
        pipe_resource_reference(&ptrans->resource, NULL);
-       util_slab_free(&ctx->transfer_pool, ptrans);
+       slab_free_st(&ctx->transfer_pool, ptrans);
 
        free(trans->staging);
 }
@@ -451,11 +451,11 @@ fd_resource_transfer_map(struct pipe_context *pctx,
        DBG("prsc=%p, level=%u, usage=%x, box=%dx%d+%d,%d", prsc, level, usage,
                box->width, box->height, box->x, box->y);
 
-       ptrans = util_slab_alloc(&ctx->transfer_pool);
+       ptrans = slab_alloc_st(&ctx->transfer_pool);
        if (!ptrans)
                return NULL;
 
-       /* util_slab_alloc() doesn't zero: */
+       /* slab_alloc_st() doesn't zero: */
        trans = fd_transfer(ptrans);
        memset(trans, 0, sizeof(*trans));
 
index 82798bbb543c0d659c8436e6ac7b7d91f70348d8..f3324dbc22918e0172ba0d7096f44a8be0912147 100644 (file)
@@ -177,10 +177,10 @@ i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
    i915->base.draw_vbo = i915_draw_vbo;
 
    /* init this before draw */
-   util_slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer),
-                    16, UTIL_SLAB_SINGLETHREADED);
-   util_slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer),
-                    16, UTIL_SLAB_SINGLETHREADED);
+   slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer),
+                    16);
+   slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer),
+                    16);
 
    /* Batch stream debugging is a bit hacked up at the moment:
     */
index 2adaee30fb90e448eb7e8ba84262fe51d4430984..ea13834c15aafc0e7dad5a97a8eb72af8193f889 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "tgsi/tgsi_scan.h"
 
-#include "util/u_slab.h"
+#include "util/slab.h"
 #include "util/u_blitter.h"
 
 
@@ -278,8 +278,8 @@ struct i915_context {
    struct i915_winsys_buffer *validation_buffers[2 + 1 + I915_TEX_UNITS];
    int num_validation_buffers;
 
-   struct util_slab_mempool transfer_pool;
-   struct util_slab_mempool texture_transfer_pool;
+   struct slab_mempool transfer_pool;
+   struct slab_mempool texture_transfer_pool;
 
    /* state for tracking flushes */
    int last_fired_vertices;
index 24c954cae34fb3fa0e1b8c01218a15ca8701aed8..2572fc40b2c553632ca25fae265715a52fbc2499 100644 (file)
@@ -70,7 +70,7 @@ i915_buffer_transfer_map(struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
    struct i915_buffer *buffer = i915_buffer(resource);
-   struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
+   struct pipe_transfer *transfer = slab_alloc_st(&i915->transfer_pool);
 
    if (!transfer)
       return NULL;
@@ -89,7 +89,7 @@ i915_buffer_transfer_unmap(struct pipe_context *pipe,
                            struct pipe_transfer *transfer)
 {
    struct i915_context *i915 = i915_context(pipe);
-   util_slab_free(&i915->transfer_pool, transfer);
+   slab_free_st(&i915->transfer_pool, transfer);
 }
 
 void
index f77bbfde18192d855f7abeed96bb2c489ee6b954..4ade04f223c022804b109ed21db9030bac3f1da7 100644 (file)
@@ -721,7 +721,7 @@ i915_texture_transfer_map(struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
    struct i915_texture *tex = i915_texture(resource);
-   struct i915_transfer *transfer = util_slab_alloc(&i915->texture_transfer_pool);
+   struct i915_transfer *transfer = slab_alloc_st(&i915->texture_transfer_pool);
    boolean use_staging_texture = FALSE;
    struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
    enum pipe_format format = resource->format;
@@ -814,7 +814,7 @@ i915_texture_transfer_unmap(struct pipe_context *pipe,
       pipe_resource_reference(&itransfer->staging_texture, NULL);
    }
 
-   util_slab_free(&i915->texture_transfer_pool, itransfer);
+   slab_free_st(&i915->texture_transfer_pool, itransfer);
 }
 
 #if 0
index 6bcd0bcb8f57a4b44c7b75c95624dcedbf8a02ab..ad9120290afd2899ad1a5b78871b9bccbeb313e0 100644 (file)
@@ -129,7 +129,7 @@ ilo_context_destroy(struct pipe_context *pipe)
    if (ilo->cp)
       ilo_cp_destroy(ilo->cp);
 
-   util_slab_destroy(&ilo->transfer_mempool);
+   slab_destroy(&ilo->transfer_mempool);
 
    FREE(ilo);
 }
@@ -151,8 +151,8 @@ ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
     * initialize first, otherwise it may not be safe to call
     * ilo_context_destroy() on errors
     */
-   util_slab_create(&ilo->transfer_mempool,
-         sizeof(struct ilo_transfer), 64, UTIL_SLAB_SINGLETHREADED);
+   slab_create(&ilo->transfer_mempool,
+         sizeof(struct ilo_transfer), 64);
 
    ilo->shader_cache = ilo_shader_cache_create();
    ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache);
index 1610358ecd3ffb27615c08a5dcc7bd7d516cdbc2..25d338ade18251db1fd592bac21e27835aa90223 100644 (file)
@@ -29,7 +29,7 @@
 #define ILO_CONTEXT_H
 
 #include "pipe/p_context.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 
 #include "ilo_common.h"
 #include "ilo_cp.h"
@@ -50,7 +50,7 @@ struct ilo_context {
    struct intel_winsys *winsys;
    struct ilo_dev *dev;
 
-   struct util_slab_mempool transfer_mempool;
+   struct slab_mempool transfer_mempool;
 
    struct ilo_cp *cp;
 
index d243e38fbe2e2eccb63e9e41142daef98282280b..87607ebe80dfeb0ef7a933d790a8ee80b8d2bbe5 100644 (file)
@@ -1184,7 +1184,7 @@ ilo_transfer_unmap(struct pipe_context *pipe,
 
    pipe_resource_reference(&xfer->base.resource, NULL);
 
-   util_slab_free(&ilo->transfer_mempool, xfer);
+   slab_free_st(&ilo->transfer_mempool, xfer);
 }
 
 static void *
@@ -1200,7 +1200,7 @@ ilo_transfer_map(struct pipe_context *pipe,
    void *ptr;
 
    /* note that xfer is not zero'd */
-   xfer = util_slab_alloc(&ilo->transfer_mempool);
+   xfer = slab_alloc_st(&ilo->transfer_mempool);
    if (!xfer) {
       *transfer = NULL;
       return NULL;
@@ -1226,7 +1226,7 @@ ilo_transfer_map(struct pipe_context *pipe,
 
    if (!ptr) {
       pipe_resource_reference(&xfer->base.resource, NULL);
-      util_slab_free(&ilo->transfer_mempool, xfer);
+      slab_free_st(&ilo->transfer_mempool, xfer);
       *transfer = NULL;
       return NULL;
    }
index 99f1ad1505ff0b23d4f1bc6d079ace98485656e6..4651c836b901e3f10dee5175d433bda3f8171671 100644 (file)
@@ -491,9 +491,9 @@ toy_compiler_cleanup(struct toy_compiler *tc)
    struct toy_inst *inst, *next;
 
    LIST_FOR_EACH_ENTRY_SAFE(inst, next, &tc->instructions, list)
-      util_slab_free(&tc->mempool, inst);
+      slab_free_st(&tc->mempool, inst);
 
-   util_slab_destroy(&tc->mempool);
+   slab_destroy(&tc->mempool);
 }
 
 /**
@@ -543,8 +543,8 @@ toy_compiler_init(struct toy_compiler *tc, const struct ilo_dev *dev)
 
    tc_init_inst_templ(tc);
 
-   util_slab_create(&tc->mempool, sizeof(struct toy_inst),
-         64, UTIL_SLAB_SINGLETHREADED);
+   slab_create(&tc->mempool, sizeof(struct toy_inst),
+         64);
 
    list_inithead(&tc->instructions);
    /* instructions are added to the tail */
index d9b56174bafb6094fafdf4fb48d4cc27f0ad6489..71f9deaa726f17fb31520d8b9643014431cbd692 100644 (file)
@@ -29,7 +29,7 @@
 #define TOY_COMPILER_H
 
 #include "genhw/genhw.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 
 #include "ilo_common.h"
 #include "toy_compiler_reg.h"
@@ -153,7 +153,7 @@ struct toy_compiler {
    const struct ilo_dev *dev;
 
    struct toy_inst templ;
-   struct util_slab_mempool mempool;
+   struct slab_mempool mempool;
    struct list_head instructions;
    struct list_head *iter, *iter_next;
 
@@ -209,7 +209,7 @@ tc_duplicate_inst(struct toy_compiler *tc, const struct toy_inst *inst)
 {
    struct toy_inst *new_inst;
 
-   new_inst = util_slab_alloc(&tc->mempool);
+   new_inst = slab_alloc_st(&tc->mempool);
    if (!new_inst)
       return NULL;
 
@@ -236,7 +236,7 @@ static inline void
 tc_discard_inst(struct toy_compiler *tc, struct toy_inst *inst)
 {
    list_del(&inst->list);
-   util_slab_free(&tc->mempool, inst);
+   slab_free_st(&tc->mempool, inst);
 }
 
 /**
index d100a9df55b9bd7a15e140222ea88278d462a94b..24d07f0b86505ed4c9de76a15b9e724620d1e726 100644 (file)
@@ -100,7 +100,7 @@ static void r300_destroy_context(struct pipe_context* context)
     rc_destroy_regalloc_state(&r300->fs_regalloc_state);
 
     /* XXX: No way to tell if this was initialized or not? */
-    util_slab_destroy(&r300->pool_transfers);
+    slab_destroy(&r300->pool_transfers);
 
     /* Free the structs allocated in r300_setup_atoms() */
     if (r300->aa_state.state) {
@@ -377,9 +377,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300->context.destroy = r300_destroy_context;
 
-    util_slab_create(&r300->pool_transfers,
-                     sizeof(struct pipe_transfer), 64,
-                     UTIL_SLAB_SINGLETHREADED);
+    slab_create(&r300->pool_transfers,
+                     sizeof(struct pipe_transfer), 64);
 
     r300->ctx = rws->ctx_create(rws);
     if (!r300->ctx)
index a4783f396e136d17f0132b00b6cac3a40b127421..592479a05a969ea29aa48d208b6b7d33b1ce9332 100644 (file)
@@ -596,7 +596,7 @@ struct r300_context {
     unsigned nr_vertex_buffers;
     struct u_upload_mgr *uploader;
 
-    struct util_slab_mempool pool_transfers;
+    struct slab_mempool pool_transfers;
 
     /* Stat counter. */
     uint64_t flush_counter;
index e15c3c7de0cb3ddb377554978f3a864610b97542..5cd5a4005c316265c4b76cf5a752602967b6b126 100644 (file)
@@ -27,7 +27,7 @@
 #include "r300_chipset.h"
 #include "radeon/radeon_winsys.h"
 #include "pipe/p_screen.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 #include "os/os_thread.h"
 #include <stdio.h>
 
index 069e9fdc6b0717ecad73c6d38ff51a4443936212..4747058286e9ca58284288ea5e4fe7e0ac4e0cea 100644 (file)
@@ -77,7 +77,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
     struct pipe_transfer *transfer;
     uint8_t *map;
 
-    transfer = util_slab_alloc(&r300->pool_transfers);
+    transfer = slab_alloc_st(&r300->pool_transfers);
     transfer->resource = resource;
     transfer->level = level;
     transfer->usage = usage;
@@ -129,7 +129,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
     map = rws->buffer_map(rbuf->buf, r300->cs, usage);
 
     if (!map) {
-        util_slab_free(&r300->pool_transfers, transfer);
+        slab_free_st(&r300->pool_transfers, transfer);
         return NULL;
     }
 
@@ -142,7 +142,7 @@ static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
 {
     struct r300_context *r300 = r300_context(pipe);
 
-    util_slab_free(&r300->pool_transfers, transfer);
+    slab_free_st(&r300->pool_transfers, transfer);
 }
 
 static const struct u_resource_vtbl r300_buffer_vtbl =
index 6a55de1fe29617ef57d844a7bc7729c5b40974a6..a600793e3e6dbdaaf4170a408a410ddea8e34b9c 100644 (file)
@@ -283,7 +283,7 @@ static void *r600_buffer_get_transfer(struct pipe_context *ctx,
                                      unsigned offset)
 {
        struct r600_common_context *rctx = (struct r600_common_context*)ctx;
-       struct r600_transfer *transfer = util_slab_alloc(&rctx->pool_transfers);
+       struct r600_transfer *transfer = slab_alloc_st(&rctx->pool_transfers);
 
        transfer->transfer.resource = resource;
        transfer->transfer.level = level;
@@ -468,7 +468,7 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
        if (rtransfer->staging)
                r600_resource_reference(&rtransfer->staging, NULL);
 
-       util_slab_free(&rctx->pool_transfers, transfer);
+       slab_free_st(&rctx->pool_transfers, transfer);
 }
 
 void r600_buffer_subdata(struct pipe_context *ctx,
index 825e4e98658e4dad2410baeea8882f281e9f2690..6d7cc1b5d3cade3b6dc63f7042ae2d82bbb4f795 100644 (file)
@@ -431,9 +431,8 @@ bool r600_common_context_init(struct r600_common_context *rctx,
                              struct r600_common_screen *rscreen,
                              unsigned context_flags)
 {
-       util_slab_create(&rctx->pool_transfers,
-                        sizeof(struct r600_transfer), 64,
-                        UTIL_SLAB_SINGLETHREADED);
+       slab_create(&rctx->pool_transfers,
+                        sizeof(struct r600_transfer), 64);
 
        rctx->screen = rscreen;
        rctx->ws = rscreen->ws;
@@ -533,7 +532,7 @@ void r600_common_context_cleanup(struct r600_common_context *rctx)
                u_upload_destroy(rctx->uploader);
        }
 
-       util_slab_destroy(&rctx->pool_transfers);
+       slab_destroy(&rctx->pool_transfers);
 
        if (rctx->allocator_zeroed_memory) {
                u_suballocator_destroy(rctx->allocator_zeroed_memory);
index aa40a54f43dabd68516819394e023225b5ee182c..d9f22e49889a1da5695a5b649e527765288c3190 100644 (file)
@@ -39,7 +39,7 @@
 #include "util/u_blitter.h"
 #include "util/list.h"
 #include "util/u_range.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 #include "util/u_suballoc.h"
 #include "util/u_transfer.h"
 
@@ -527,7 +527,7 @@ struct r600_common_context {
 
        struct u_upload_mgr             *uploader;
        struct u_suballocator           *allocator_zeroed_memory;
-       struct util_slab_mempool        pool_transfers;
+       struct slab_mempool     pool_transfers;
 
        /* Current unaccounted memory usage. */
        uint64_t                        vram;
index eeadea0b1db3db03396e4805fbfd2e0b115dff99..a85554a43dd1fe08d96e7a19289f8be96bb7d6d4 100644 (file)
@@ -200,7 +200,7 @@ vc4_context_destroy(struct pipe_context *pctx)
         if (vc4->uploader)
                 u_upload_destroy(vc4->uploader);
 
-        util_slab_destroy(&vc4->transfer_pool);
+        slab_destroy(&vc4->transfer_pool);
 
         pipe_surface_reference(&vc4->framebuffer.cbufs[0], NULL);
         pipe_surface_reference(&vc4->framebuffer.zsbuf, NULL);
@@ -246,8 +246,8 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 
         vc4->fd = screen->fd;
 
-        util_slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
-                         16, UTIL_SLAB_SINGLETHREADED);
+        slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
+                         16);
         vc4->blitter = util_blitter_create(pctx);
         if (!vc4->blitter)
                 goto fail;
index 63a1dfbb15a52dcd1cf58a5384ee4ef410c348e2..ce2c6d4e68e1e85b5074b359dceefa2ea508d46c 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 
 #define __user
 #include "vc4_drm.h"
@@ -238,7 +238,7 @@ struct vc4_context {
         bool msaa;
        /** @} */
 
-        struct util_slab_mempool transfer_pool;
+        struct slab_mempool transfer_pool;
         struct blitter_context *blitter;
 
         /** bitfield of VC4_DIRTY_* */
index 398aa8181df0d399ae7ac43c0c3966554d4cd469..0d4bb6477d6f5f74f288121927bacb0268b55479 100644 (file)
@@ -121,7 +121,7 @@ vc4_resource_transfer_unmap(struct pipe_context *pctx,
         }
 
         pipe_resource_reference(&ptrans->resource, NULL);
-        util_slab_free(&vc4->transfer_pool, ptrans);
+        slab_free_st(&vc4->transfer_pool, ptrans);
 }
 
 static struct pipe_resource *
@@ -194,13 +194,13 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
         if (usage & PIPE_TRANSFER_WRITE)
                 rsc->writes++;
 
-        trans = util_slab_alloc(&vc4->transfer_pool);
+        trans = slab_alloc_st(&vc4->transfer_pool);
         if (!trans)
                 return NULL;
 
         /* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */
 
-        /* util_slab_alloc() doesn't zero: */
+        /* slab_alloc_st() doesn't zero: */
         memset(trans, 0, sizeof(*trans));
         ptrans = &trans->base;
 
index 153df8dd0c93a7fbc7715c9dff54bdae85782c6d..de997962845b3d7e6bebaafc3f46ab3cc55418bd 100644 (file)
@@ -62,7 +62,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
    if (doflushwait)
       ctx->flush(ctx, NULL, 0);
 
-   trans = util_slab_alloc(&vctx->texture_transfer_pool);
+   trans = slab_alloc_st(&vctx->texture_transfer_pool);
    if (!trans)
       return NULL;
 
@@ -114,7 +114,7 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
       }
    }
 
-   util_slab_free(&vctx->texture_transfer_pool, trans);
+   slab_free_st(&vctx->texture_transfer_pool, trans);
 }
 
 static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
index 1bd7f3b6b52584f53001b26d49e27c2b22b59c08..a6c059759865096f1fd49f2b9a76d68f26ae21c6 100644 (file)
@@ -32,7 +32,7 @@
 #include "util/u_format.h"
 #include "util/u_transfer.h"
 #include "util/u_helpers.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 #include "util/u_upload_mgr.h"
 #include "util/u_blitter.h"
 #include "tgsi/tgsi_text.h"
@@ -862,7 +862,7 @@ virgl_context_destroy( struct pipe_context *ctx )
       u_upload_destroy(vctx->uploader);
    util_primconvert_destroy(vctx->primconvert);
 
-   util_slab_destroy(&vctx->texture_transfer_pool);
+   slab_destroy(&vctx->texture_transfer_pool);
    FREE(vctx);
 }
 
@@ -943,8 +943,8 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
    virgl_init_so_functions(vctx);
 
    list_inithead(&vctx->to_flush_bufs);
-   util_slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer),
-                    16, UTIL_SLAB_SINGLETHREADED);
+   slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer),
+                    16);
 
    vctx->primconvert = util_primconvert_create(&vctx->base, rs->caps.caps.v1.prim_mask);
    vctx->uploader = u_upload_create(&vctx->base, 1024 * 1024,
index adb8adef33c98fff9678ba8be472ecdaa2bf680f..3b9901f7e11b6dfcc4f7834cc545f424874f7976 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
 #include "util/list.h"
 
 struct pipe_screen;
@@ -56,7 +56,7 @@ struct virgl_context {
 
    struct pipe_framebuffer_state framebuffer;
 
-   struct util_slab_mempool texture_transfer_pool;
+   struct slab_mempool texture_transfer_pool;
 
    struct pipe_index_buffer index_buffer;
    struct u_upload_mgr *uploader;
index 64b6744462d98764f60e70374273faeefff37b0c..24bbc3ce60b0b91598553818aaf95da0bd96d2a6 100644 (file)
@@ -145,7 +145,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
    if (doflushwait)
       ctx->flush(ctx, NULL, 0);
 
-   trans = util_slab_alloc(&vctx->texture_transfer_pool);
+   trans = slab_alloc_st(&vctx->texture_transfer_pool);
    if (!trans)
       return NULL;
 
@@ -235,7 +235,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
    if (trans->resolve_tmp)
       pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL);
 
-   util_slab_free(&vctx->texture_transfer_pool, trans);
+   slab_free_st(&vctx->texture_transfer_pool, trans);
 }