summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2016-08-22 14:19:50 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-10-18 15:24:26 -0400
commit641444188f18dbf56dda980e31f1b404dbb6f166 (patch)
treee94e53459dae58168873362e6348e56121c1b8f6 /drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
parentcd452a6ed4cad388909b0372f04a0482609acb90 (diff)
gpu: nvgpu: bitmap allocator optimization
Add an optimization to the bitmap allocator for handling sequences of allocations. A common pattern of allocs from the priv_cmdbuf is to do many allocs and then many frees. In such cases it makes sense to store the last allocation offset and start searching for the next alloc from there. For such a pattern we know that the previous bits are already allocated so it doesn't make sense to search them unless we have to. Obviously, if there's no space found ahead of the precious alloc's block then we fall back to the remaining space. In random allocation patterns this optimization should not have any negative affects. It merely shifts the start point for searching for allocs but assuming each bit has an equal probability of being free the start location does not matter. Bug 1799159 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1205958 (cherry picked from commit 759c583962d6d57cb8cb073ccdbfcfc6db4c1e18) Change-Id: I267ef6fa155ff15d6ebfc76dc1abafd9aa1f44df Reviewed-on: http://git-master/r/1227923 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h b/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
index 053a6425..a686b704 100644
--- a/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
+++ b/drivers/gpu/nvgpu/gk20a/bitmap_allocator_priv.h
@@ -31,6 +31,15 @@ struct gk20a_bitmap_allocator {
31 u64 num_bits; /* Number of allocatable bits. */ 31 u64 num_bits; /* Number of allocatable bits. */
32 u64 bit_offs; /* Offset of bitmap. */ 32 u64 bit_offs; /* Offset of bitmap. */
33 33
34 /*
35 * Optimization for making repeated allocations faster. Keep track of
36 * the next bit after the most recent allocation. This is where the next
37 * search will start from. This should make allocation faster in cases
38 * where lots of allocations get made one after another. It shouldn't
39 * have a negative impact on the case where the allocator is fragmented.
40 */
41 u64 next_blk;
42
34 unsigned long *bitmap; /* The actual bitmap! */ 43 unsigned long *bitmap; /* The actual bitmap! */
35 struct rb_root allocs; /* Tree of outstanding allocations. */ 44 struct rb_root allocs; /* Tree of outstanding allocations. */
36 45