summaryrefslogtreecommitdiffstats
path: root/src/util/ralloc.c
Commit message (Collapse)AuthorAgeFilesLines
* ralloc: don't leave out the alignment factorGrazvydas Ignotas2017-03-061-1/+3
| | | | | | | | | | | | | | | Experimentation shows that without alignment factor gcc and clang choose a factor of 16 even on IA-32, which doesn't match what malloc() uses (8). The problem is it makes gcc assume the pointer is 16 byte aligned, so with -O3 it starts using aligned SSE instructions that later fault, so always specify a suitable alignment factor. Cc: Jonas Pfeil <[email protected]> Fixes: cd2b55e5 "ralloc: Make sure ralloc() allocations match malloc()'s alignment." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100049 Signed-off-by: Grazvydas Ignotas <[email protected]> Tested by: Mike Lothian <[email protected]> Tested by: Jonas Pfeil <[email protected]>
* ralloc: Make sure ralloc() allocations match malloc()'s alignment.Jonas Pfeil2017-03-021-1/+12
| | | | | | | | | | | | | | | | | | | The header of ralloc needs to be aligned, because the compiler assumes that malloc returns will be aligned to 8/16 bytes depending on the platform, leading to degraded performance or alignment faults with ralloc. Fixes SIGBUS on Raspberry Pi at high optimization levels. This patch is not perfect for MSVC, as maybe in the future the alignment for the most demanding data type might change to more than 8. v2: Commit message reword/typo fix, and add a bigger explanation in the code (by anholt) Signed-off-by: Jonas Pfeil <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Cc: [email protected]
* ralloc: Delete autofree handling.Kenneth Graunke2017-02-271-18/+0
| | | | | | | | | | | | | There was exactly one user of this, and I just removed it. It also accessed an implicit global context, with no locking. This meant that it was only safe if all callers of ralloc_autofree_context() held the same lock...which is a pretty terrible thing for a utility library to impose. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* ralloc: add a linear allocator as a child node of rallocMarek Olšák2016-10-311-0/+353
| | | | | | | v2: remove goto, cosmetic changes Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]>
* ralloc: remove memset from ralloc_sizeMarek Olšák2016-10-311-15/+11
| | | | | | | only do it in rzalloc_size as it was supposed to be Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]>
* ralloc: don't memset ralloc_header, clear it manuallyMarek Olšák2016-10-311-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | time GALLIUM_NOOP=1 ./run shaders/private/alien_isolation/ >/dev/null Before (2 takes): real 0m8.734s 0m8.773s user 0m34.232s 0m34.348s sys 0m0.084s 0m0.056s After (2 takes): real 0m8.448s 0m8.463s user 0m33.104s 0m33.160s sys 0m0.088s 0m0.076s Average change in "real" time spent: -3.4% calloc should only do 2 things compared to malloc: - check for overflow of "n * size" - call memset I'm not sure if that explains the difference. v2: clear "parent" and "next" in the caller of add_child. Reviewed-by: Edward O'Callaghan <[email protected]> (v1) Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* util/ralloc: Remove double zero'ing of rzalloc buffersJordan Justen2016-05-101-9/+12
| | | | | | | | | | | | | | | | | | | | | | Juha-Pekka found this back in May 2015: <[email protected]> From the discussion, obviously it would be preferable to make ralloc_size no longer return zeroed memory, but Juha-Pekka found that it would break Mesa. In <[email protected]>, Juha-Pekka mentioned that patches exist to fix i965 when ralloc_size is fixed to not zero memory, but the patches have not made their way to mesa-dev yet. For now, let's stop doing the double zeroing of rzalloc buffers. v2: * Move ralloc_size code to rzalloc_size, and add a comment as suggested by Ken. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* ralloc: Fix ralloc_adopt() to the old context's last child's parent.Kenneth Graunke2015-12-181-0/+1
| | | | | | | | | | | I was cleverly using one iteration to obtain a pointer to the last item in ralloc's singly list child list, while also setting parents. Unfortunately, I forgot to set the parent on that last item. Cc: "11.1 11.0 10.6" <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* ralloc: Set *start in ralloc_vasprintf_rewrite_tail() if str is NULL.Matt Turner2015-11-121-0/+1
| | | | | | | We were leaving it undefined, even though we were writing a string to *str. Reviewed-by: Kenneth Graunke <[email protected]>
* util: use strnlen() in strndup() implementationsSamuel Iglesias Gonsalvez2015-09-301-4/+1
| | | | | | | | | If the string being copied is not NULL-terminated the result of strlen() is undefined. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Neil Roberts <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* ralloc: Implement a new ralloc_adopt() API.Kenneth Graunke2015-04-021-0/+26
| | | | | | | | | | | | | | | | | | | | | ralloc_adopt() reparents all children from one context to another. Conceptually, ralloc_adopt(new_ctx, old_ctx) behaves like this pseudocode: foreach child of old_ctx: ralloc_steal(new_ctx, child) However, ralloc provides no way to iterate over a memory context's children, and ralloc_adopt does this task more efficiently anyway. One potential use of this is to implement a memory-sweeper pass: first, steal all of a context's memory to a temporary context. Then, walk over anything that should be kept, and ralloc_steal it back to the original context. Finally, free the temporary context. This works when the context is something that can't be freed (i.e. an important structure). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util: Move ralloc to a new src/util directory.Kenneth Graunke2014-08-041-0/+492
For a long time, we've wanted a place to put utility code which isn't directly tied to Mesa or Gallium internals. This patch creates a new src/util directory for exactly that purpose, and builds the contents as libmesautil.la. ralloc seemed like a good first candidate. These days, it's directly used by mesa/main, i965, i915, and r300g, so keeping it in src/glsl didn't make much sense. Signed-off-by: Kenneth Graunke <[email protected]> v2 (Jason Ekstrand): More realloc uses and some scons fixes Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Marek Olšák <[email protected]>