[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] physmem: use sysinfo on linux for physmem_total

From: Pádraig Brady
Subject: Re: [PATCH] physmem: use sysinfo on linux for physmem_total
Date: Thu, 17 Apr 2014 01:26:13 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 04/15/2014 03:49 PM, Pádraig Brady wrote:
> On 04/15/2014 03:43 PM, Natanael Copa wrote:
>> * lib/physmem.c (physmem_total): Some systems like musl libc does not
>> (yet) support _SC_PHYS_PAGES. Use the linux syscall sysinfo first and
>> fallback to sysconf with _SC_PHYS_PAGES and _SC_PAGESIZE.
> This looks good.
> I confirmed the values are the same on a
> system at least.

Actually sysinfo() returns dynamic stats too,
and thus could have more overhead.
Therefore I suggest we use sysinfo() as the fallback
if _SC_PHYS_PAGES is not available.

Also I see that one should multiply totalram * mem_unit
(note cast to double first to avoid overflow).
So handiest is to check for the mem_unit member to
conditionalize the use of sysinfo().


reply via email to

[Prev in Thread] Current Thread [Next in Thread]