Re: Size of /proc/kcore on MIPS (porting help requested)
On 3/25/06, Helge Kreutzmann <kreutzm@itp.uni-hannover.de> wrote:
> Hello,
> I maintain the little utility called linuxinfo. Recently I got a bug
> report[1], that it reports wrong (negativ) memory size on some MIPS
> machines. The main method for linuxinfo to determine the memory size
> is to look at the size of /proc/kcore. If the size is known to be
> problematic (x86 highmem, non-contineous memory on ia64) than a
> different method is used. So far all MIPS machines I got reports for
> seemd to have a "properly" sized /proc/kcore.
>
> The problematic machine in question has 2 GB of RAM, but the size of
> /proc/kcore is:
> -r-------- 1 root root 6442450944 2006-03-08 17:12 /proc/kcore
>
> Is there a relation between the size of /proc/kcore and the actually
> memory size? I noticed, that
> sizeof(/proc/kcore)-2^32 = actual size
> on this machine.
>
> The kernel is fairly new, and I saw that there has been some recent
> work on /proc/kcore on MIPS[2], but I did not understand the
> implications ...
>
> Any hint appreciated (and possible tests on other MIPS machines).
Hello
I haven't tested linuxinfo, or really worked on it yet (and I haven't
got a MIPS machine with that much memory ;)), but I'd think about some
problem with the maximum long int :
This :
----------
#include <stdio.h>
int main()
{
long int old_a, a = 0 ;
printf("sizeof(long int) : %d\n", sizeof(long int)) ;
while ( a >= 0 )
{
old_a = a ;
a++ ;
if ( a < 0 ) printf("max long int : %ld (%ldMB), next one : %ld
(%ldMB)\n", old_a, old_a/(1024*1024), a, a/(1024*1024)) ;
}
return 0 ;
}
------------
outputs :
---------
sizeof(long int) : 4
max long int : 2147483647 (2047MB), next one : -2147483648 (-2048MB)
---------
But, at first glance, this should be avoided by your
----
#if (SIZEOF_LONG > 4)
#define LONGLONG long int
#define LONGSPEC "%ld"
#else
#define LONGLONG long long int
#define LONGSPEC "%lld"
#endif
----
Isn't /proc/kcore reflecting the total memory size (RAM + swap) ?
Hope this isn't stupid and this helps :)
Regards,
Guillaume
Reply to: