David Ford <[EMAIL PROTECTED]> writes:

> Very correct except for one thing, allocation fails and ipcs -u
> shows 4097 when the limit shows 4096.  safemode reports that
> eventually the kernel crashes.  This may be due to the test9
> 'features' and a side affect, or it may be something to keep in mind
> once we get things nailed down a bit.

Oh, yes that's a off by one error in the statistics. (I hate the
/dev/zero stuff...) There was also some incorrect double
accounting. The appended patch fixes this. Linus please apply. It
fixes obvious bugs.

Greetings
                Christoph

--- linux/ipc/shm.c.orig        Mon Sep 25 10:16:50 2000
+++ linux/ipc/shm.c     Mon Sep 25 10:28:40 2000
@@ -206,7 +206,6 @@
 /* some statistics */
 static ulong swap_attempts;
 static ulong swap_successes;
-static ulong used_segs;
 
 void __init shm_init (void)
 {
@@ -364,7 +363,9 @@
        buf->f_blocks = shm_ctlall;
        buf->f_bavail = buf->f_bfree = shm_ctlall - shm_tot;
        buf->f_files = shm_ctlmni;
-       buf->f_ffree = shm_ctlmni - used_segs;
+       shm_lockall();
+       buf->f_ffree = shm_ctlmni - shm_ids.in_use + 1;
+       shm_unlockall();
        buf->f_namelen = SHM_NAME_LEN;
        return 0;
 }
@@ -593,7 +594,6 @@
        if (doacc) {
                shm_lockall();
                shm_tot += pages;
-               used_segs++;
                shm_unlockall();
        }
        return ret;
@@ -646,7 +646,6 @@
                shm_rss -= rss;
                shm_swp -= swp;
                shm_tot -= pages;
-               used_segs--;
                shm_unlockall();
        }
 }
@@ -970,7 +969,7 @@
 
                memset(&shm_info,0,sizeof(shm_info));
                shm_lockall();
-               shm_info.used_ids = shm_ids.in_use;
+               shm_info.used_ids = shm_ids.in_use - 1; /* correct the /dev/zero hack 
+*/
                shm_info.shm_rss = shm_rss;
                shm_info.shm_tot = shm_tot;
                shm_info.shm_swp = shm_swp;

Reply via email to