[Mesa-stable] [PATCH 12/25] dri/i9*5: correctly calculate the amount of system memory
Ian Romanick
idr at freedesktop.org
Sat Mar 1 08:47:56 PST 2014
On 02/28/2014 04:52 PM, Emil Velikov wrote:
> On 28/02/14 17:32, Ian Romanick wrote:
>> On 02/21/2014 07:04 PM, Emil Velikov wrote:
>>> The variable name states megabytes, while we calculate the amount in
>>> kilobytes. Correct this by dividing with the correct amount.
>>>
>>> Cc: "10.0 10.1" <mesa-stable at lists.freedesktop.org>
>>> Cc: Ian Romanick <ian.d.romanick at intel.com>
>>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>>> ---
>>> src/mesa/drivers/dri/i915/intel_screen.c | 2 +-
>>> src/mesa/drivers/dri/i965/intel_screen.c | 2 +-
>>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/mesa/drivers/dri/i915/intel_screen.c
>>> b/src/mesa/drivers/dri/i915/intel_screen.c
>>> index 296df16..884fdb5 100644
>>> --- a/src/mesa/drivers/dri/i915/intel_screen.c
>>> +++ b/src/mesa/drivers/dri/i915/intel_screen.c
>>> @@ -744,7 +744,7 @@ i915_query_renderer_integer(__DRIscreen *psp, int
>>> param, unsigned int *value)
>>> * (uint64_t) system_page_size;
>>>
>>> const unsigned system_memory_megabytes =
>>> - (unsigned) (system_memory_bytes / 1024);
>>> + (unsigned) (system_memory_bytes / (1024 * 1024));
>>
>> I don't think this is correct. When I run piglit's
>> glx-query-renderer-coverage, it says
>>
>> glXQueryRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA) values:
>> 1534
>>
>> That's 1.5GiB, and that's the value I expect. I guess the variable
>> system_memory_bytes should be called system_memory_kbytes instead.
>>
>> I see you have similar code in other patches in the series. Does
>> glx-query-renderer-coverage give sensible values in those drivers?
>>
> I can only test swrast (both classic and gallium, patches 11 and 24) and
> gallium nouveau. The former gives a sensible result for my 4GiB machine.
>
> glXQueryRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA) values:
> 3957
>
>
> $ man sysconf
> PAGESIZE - _SC_PAGESIZE
> Size of a page in bytes.
> _SC_PHYS_PAGES
> The number of pages of physical memory.
>
> ... so I'm not sure how we get such a difference.
>
> Mind checking if the following gives reasonable result on your system ?
>
> printf("%ul\n", sysconf(_SC_PAGE_SIZE)*sysconf(_SC_PHYS_PAGES);
Seems right:
[idr at mumford-wire tmp]$ ./a.out ; head -1 /proc/meminfo
8085135360
MemTotal: 7895640 kB
But... your patch is correct. The reason I get 1.5GiB is the first line
not shown in the diff:
value[0] = MIN2(system_memory_megabytes, gpu_mappable_megabytes);
Guess what gpu_mappable_megabytes is? :)
This patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
I'm going to push it now so that I can pick it to 10.1 for RC3.
> -Emil
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-stable
More information about the mesa-stable
mailing list