[Mesa-dev] [PATCH 1/2] util/disk_cache: support caches for multiple architectures

Timothy Arceri tarceri at itsqueeze.com
Fri Mar 3 01:38:06 UTC 2017



On 03/03/17 00:16, Grazvydas Ignotas wrote:
> On Thu, Mar 2, 2017 at 8:36 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
>>
>>
>> On 02/03/17 17:17, Ilia Mirkin wrote:
>>>
>>> On Thu, Mar 2, 2017 at 1:08 AM, Timothy Arceri <tarceri at itsqueeze.com>
>>> wrote:
>>>>
>>>> Previously we were deleting the entire cache if a user switched
>>>> between 32 and 64 bit applications.
>>>> ---
>>>>  src/util/disk_cache.c | 21 +++++++++++++++++++++
>>>>  1 file changed, 21 insertions(+)
>>>>
>>>> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
>>>> index 3abdec4..1a91c69 100644
>>>> --- a/src/util/disk_cache.c
>>>> +++ b/src/util/disk_cache.c
>>>> @@ -40,20 +40,32 @@
>>>>  #include "zlib.h"
>>>>
>>>>  #include "util/crc32.h"
>>>>  #include "util/u_atomic.h"
>>>>  #include "util/mesa-sha1.h"
>>>>  #include "util/ralloc.h"
>>>>  #include "main/errors.h"
>>>>
>>>>  #include "disk_cache.h"
>>>>
>>>> +#if defined(__x86_64__)
>>>> +#if defined(__ILP32__)
>>>> +#define CACHE_ARCH "x32"
>>>> +#else
>>>> +#define CACHE_ARCH "x86_64"
>>>> +#endif
>>>> +#elif defined(__i386__)
>>>> +#define CACHE_ARCH "i386"
>>>> +#else
>>>> +#define CACHE_ARCH "unknown_arch"
>>>> +#endif
>>>
>>>
>>> This seems incomplete.
>>
>>
>> It's complete enough for what we currently support. Maybe could add powerpc
>> but wouldn't be hard to add if someone was worried about that.
>
> ARM is also a potential user with vc4, so the above ifdef tree can
> become quite nasty quick.

I'm not sure it would be so bad. I'll add everything for completeness 
and resend and if others disagree we can try your way.

>
> You could use (char *)getauxval(AT_PLATFORM) I think, it's Linux
> specific and requires recent enough glibc version (4 years old or so),
> but that should cover majority of cache users IMO.
>
> I'd suggest something like:
> const char *arch = NULL;
> #ifdef HAVE_GETAUXVAL
>    arch = (const char *)getauxval(AT_PLATFORM);
> #endif
> if (!arch)
>    arch = (sizeof(void *) == 8) ? "64" : "32";
>
> This misses x32 but I don't think we should care, mesa was crashing on
> x32 for years until recently (and still is crashing in some
> configurations according to a recent report).
>
> GraÅžvydas
>


More information about the mesa-dev mailing list