[Mesa-dev] [PATCH] anv: change BLOCK_POOL_MEMFD_SIZE to exactly 2GB

Eero Tamminen eero.t.tamminen at intel.com
Tue Mar 7 15:53:16 UTC 2017


Hi,

On 07.03.2017 17:08, Jason Ekstrand wrote:
> Interesting... This must only affect android for some weird reason
> because 32-bit builds have been working on regular Linux for some time now.

There are couple of issues...

 From "ftruncate" manual page:
        int ftruncate(int fd, off_t length);
...
        The original Linux truncate() and ftruncate() system calls were 
not designed to handle large file offsets.  Consequently, Linux 2.4 
added truncate64() and ftruncate64() system calls that handle large 
files.  However, these details can be ignored by applications using 
glibc, whose wrapper functions  transparently  employ the more recent 
system calls where they are available.

        On some 32-bit architectures, the calling signature for these 
system calls differ, for the reasons described in syscall(2).


And from "ftello" manual page:
        On some architectures, both off_t and long are 32-bit types, but 
defining _FILE_OFFSET_BITS with the value 64 (before including any 
header files) will turn off_t into a 64-bit type.


Not sure which one Android libc/build hits.


	- Eero

> Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
>
>
> On March 7, 2017 1:18:25 AM Tapani Pälli <tapani.palli at intel.com> wrote:
>
>> This is what comment above definition says and change fixes issue with
>> 32bit build where BLOCK_POOL_MEMFD_SIZE is used as ftruncate parameter
>> and constant currently gets converted from 4294967296 to 0.
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>>  src/intel/vulkan/anv_private.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/intel/vulkan/anv_private.h
>> b/src/intel/vulkan/anv_private.h
>> index c73196a..86b20c4 100644
>> --- a/src/intel/vulkan/anv_private.h
>> +++ b/src/intel/vulkan/anv_private.h
>> @@ -386,7 +386,7 @@ struct anv_block_pool {
>>  };
>>
>>  /* Block pools are backed by a fixed-size 2GB memfd */
>> -#define BLOCK_POOL_MEMFD_SIZE (1ull << 32)
>> +#define BLOCK_POOL_MEMFD_SIZE (1ul << 31)
>>
>>  /* The center of the block pool is also the middle of the memfd.
>> This may
>>   * change in the future if we decide differently for some reason.
>> --
>> 2.9.3
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list