[Mesa-dev] [PATCH 1/5] util/disk_cache: seed rand

Nicolai Hähnle nhaehnle at gmail.com
Mon Mar 20 13:11:13 UTC 2017


On 14.03.2017 03:08, Timothy Arceri wrote:
> Otherwise we will always remove old cache entries from the same dirs.

Seeding the global RNG from within a driver is a no-no as others pointed 
out. I'd suggest you extract the xorshift128plus generator from 
r600_test_dma.c into a common utility and use that instead.

Cheers,
Nicolai

> ---
>  src/util/disk_cache.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index 2a1024a..dc65d52 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -402,20 +402,22 @@ disk_cache_create(const char *gpu_name, const char *timestamp)
>     cache->max_size = max_size;
>
>     /* A limit of 32 jobs was choosen as observations of Deus Ex start-up times
>      * showed that we reached at most 11 jobs on an Intel i5-6400 CPU at 2.70GHz
>      * (a fairly modist desktop CPU). 1 thread was choosen because we don't
>      * really care about getting things to disk quickly just that it's not
>      * blocking other tasks.
>      */
>     util_queue_init(&cache->cache_queue, "disk_cache", 32, 1);
>
> +   srand(time(NULL));
> +
>     ralloc_free(local);
>
>     return cache;
>
>   fail:
>     if (fd != -1)
>        close(fd);
>     if (cache)
>        ralloc_free(cache);
>     ralloc_free(local);
>



More information about the mesa-dev mailing list