Timothy Arceri
25e008c639
util/u_idalloc: fix util_idalloc_sparse_alloc_range()
...
If the allocation didn't fit within the segment the loop incorrectly
freed ids of a range of different segments due to the loop redeclaring
i.
Fixes: d4085aaf56 ("util: add util_idalloc_sparse, solving the excessive virtual memory usage")
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33934 >
2025-03-08 09:17:07 +00:00
Marek Olšák
d4085aaf56
util: add util_idalloc_sparse, solving the excessive virtual memory usage
...
The code comment in the header file describes how it works.
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30106 >
2024-07-17 10:29:12 +00:00
Marek Olšák
287ed620d0
util: make util_idalloc_exists private
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30106 >
2024-07-17 10:29:12 +00:00
Juan A. Suarez Romero
a407285ff2
util: use unsigned types when performing bitshift
...
Ensure unsigned integers are used instead of signed ones when performing
left bit shifts.
This has been detected by the Undefined Behaviour Sanitizer (UBSan).
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29772 >
2024-06-21 21:07:05 +00:00
Marek Olšák
0589dfe4e2
util/idalloc: optimize foreach by tracking the greatest non-zero element
...
also add util_idalloc_foreach_no_zero_safe.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27494 >
2024-02-21 16:04:51 +00:00
Marek Olšák
716e483cfb
util/idalloc: make deleting invalid IDs a no-op
...
This happens with piglit tests if we enable ForceGLNamesReuse
for everything.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27586 >
2024-02-13 03:53:26 +00:00
Marek Olšák
b48998926c
util/idalloc: add util_idalloc_alloc_range
...
v2: fixed infinite loop (Pierre-Eric)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
730014bd81
util/idalloc: hide or remove unused public functions
...
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
02f37cb9da
util/idalloc: reserving an ID that already exists should be no-op
...
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
6ede24cf31
util/idalloc: fold the size call into init
...
It's required, otherwise idalloc would fail.
v2: renamed util_idalloc_(mt_)init param initial_num_ids (Pierre-Eric)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
995f6cbd74
util/idalloc: change num_elements to units of elements instead of bits
...
and use memset in resize().
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493 >
2021-07-09 10:05:46 +00:00
Marek Olšák
3828081c92
util: add thread-safe version of idalloc
...
For buffer IDs in u_threaded_context.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10662 >
2021-05-17 10:37:24 +00:00
Marek Olšák
72fa3372cc
util/idalloc: resize if ID is too large for reservation
...
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7031 >
2020-10-06 15:59:07 +00:00
Pierre-Eric Pelloux-Prayer
553d371933
util/idalloc: add lowest_free_idx to avoid iterating from 0
...
lowest_free_idx is a conservative estimation of the lowest index
where a free id can be found.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600 >
2020-09-10 09:07:11 +02:00
Pierre-Eric Pelloux-Prayer
e808d38299
util/idalloc: add util_idalloc_reserve
...
Can be used to mark an id as used (if it was reclaimed without using
util_idalloc_alloc).
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600 >
2020-09-10 09:07:11 +02:00
Pierre-Eric Pelloux-Prayer
87ef970ee6
mesa: move u_idalloc from gallium/aux/util to util
...
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6600 >
2020-09-10 09:07:03 +02:00