Re: struct sysinfo mem_unit field

From: David Weinehall (tao@acc.umu.se)
Date: Wed Mar 08 2000 - 17:12:00 EST


On Tue, 7 Mar 2000, Pete Wyckoff wrote:

> I'd like a nice way to get info on freeram, sharedram, etc. from
> userspace. The sysinfo() system call fits the bill nicer than grepping
> through /proc/meminfo, but I'm scared away by how much it's been
> changing across different kernel versions. Anything before 2.3.16
> (incl 2.2 and earlier) has:
>
> struct sysinfo {
> long uptime; /* Seconds since boot */
> unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
> unsigned long totalram; /* Total usable main memory size */
> unsigned long freeram; /* Available memory size */
> unsigned long sharedram; /* Amount of shared memory */
> unsigned long bufferram; /* Memory used by buffers */
> unsigned long totalswap; /* Total swap space size */
> unsigned long freeswap; /* swap space still available */
> unsigned short procs; /* Number of current processes */
> char _f[22]; /* Pads structure to 64 bytes */
> };
>
> and units of memory items were bytes. A few fields were added/removed in
> 2.3.16 and .17, then the big change happened in 2.3.23 and is with us
> today:
>
> struct sysinfo {
> long uptime; /* Seconds since boot */
> unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
> unsigned long totalram; /* Total usable main memory size */
> unsigned long freeram; /* Available memory size */
> unsigned long sharedram; /* Amount of shared memory */
> unsigned long bufferram; /* Memory used by buffers */
> unsigned long totalswap; /* Total swap space size */
> unsigned long freeswap; /* swap space still available */
> unsigned short procs; /* Number of current processes */
> unsigned long totalhigh; /* Total high memory size */
> unsigned long freehigh; /* Available high memory size */
> unsigned int mem_unit; /* Memory unit size in bytes */
> char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
> };

Hmmmm. Considering that we sooner or later will change the max # of
processes, it seems very stupid to use a short for procs. Or?!

/David Weinehall
  _ _
 // David Weinehall <tao@acc.umu.se> /> Northern lights wander \\
// Project MCA Linux hacker // Dance across the winter sky //
\> http://www.acc.umu.se/~tao/ </ Full colour fire </

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:14 EST