lkml.org 
[lkml]   [2000]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] sysinfo fix
On Mon Aug 28, 2000 at 06:11:09PM -0700, Linus Torvalds wrote:
>
> people who want a patch into the kernel should just check whether it made
> it, and re-send if not.

<patch resend alert>

This fixes sysinfo so it is binary compatable with 2.2.x kernels (for the
0-4Gib range), while retaining compatability with earlier 2.[34].x kernels.

Please consider for inclusion,

-Erik

--
Erik B. Andersen email: andersee@debian.org
--This message was written using 73% post-consumer electrons--


--- linux-2.4.0-test6.virgin/kernel/info.c Mon Aug 23 12:15:53 1999
+++ linux/kernel/info.c Mon Aug 21 11:03:14 2000
@@ -32,6 +32,42 @@
si_meminfo(&val);
si_swapinfo(&val);

+ {
+ /* If the sum of all the available memory (i.e. ram + swap +
+ * highmem) is less then can be stored in a 32 bit unsigned long
+ * then we can be binary compatable with 2.2.x kernels. If not,
+ * well, who cares since in that case 2.2.x was broken anyways...
+ *
+ * -Erik Andersen <andersee@debian.org> */
+
+ unsigned long mem_total = val.totalram + val.totalswap;
+ if ( !(mem_total < val.totalram || mem_total < val.totalswap)) {
+ unsigned long mem_total2 = mem_total + val.totalhigh;
+ if (!(mem_total2 < mem_total || mem_total2 < val.totalhigh))
+ {
+ /* If mem_total did not overflow. Divide all memory values by
+ * mem_unit and set mem_unit=1. This leaves things compatable with
+ * 2.2.x, and also retains compatability with earlier 2.4.x
+ * kernels... */
+
+ int bitcount = 0;
+ while (val.mem_unit > 1)
+ {
+ bitcount++;
+ val.mem_unit >>= 1;
+ }
+ val.totalram <<= bitcount;
+ val.freeram <<= bitcount;
+ val.sharedram <<= bitcount;
+ val.bufferram <<= bitcount;
+ val.totalswap <<= bitcount;
+ val.freeswap <<= bitcount;
+ val.totalhigh <<= bitcount;
+ val.freehigh <<= bitcount;
+ }
+ }
+ }
+
if (copy_to_user(info, &val, sizeof(struct sysinfo)))
return -EFAULT;
return 0;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.063 / U:8.244 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site