Package: swapspace
Version: 1.10-4

# mount -oremount,size=2000G /dev/shm
# cp -a /usr /dev/shm/usr

If you do the two commands above swapspace will NOT allocate more swapfiles and the system will OOM.

They make the limit on the size of a tmpfs unreasonably high, then fill
it up with far too much data.

The problem appears to be that the memory usage is recorded in the item "Shmem" and this isn't in your calculations. If I add it in (as in the
attached patch) the system survives.

This is with the patch ...

# cat /proc/meminfo
MemTotal:        1026156 kB
MemFree:           22804 kB
Buffers:           19852 kB
Cached:           866908 kB  <-- Not actually freeable.
SwapCached:         5636 kB
Active:           107544 kB
Inactive:         817916 kB
Active(anon):      34136 kB
Inactive(anon):   712684 kB
Active(file):      73408 kB
Inactive(file):   105232 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:        134996 kB
HighFree:           2452 kB
LowTotal:         891160 kB
LowFree:           20352 kB
SwapTotal:       1299780 kB
SwapFree:         512740 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:         33064 kB
Mapped:            19664 kB
Shmem:            708120 kB  <-- 'cause it's used by this.
Slab:              39124 kB
SReclaimable:      16056 kB
SUnreclaim:        23068 kB
KernelStack:        1464 kB
PageTables:         1404 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1812856 kB
Committed_AS:    1697188 kB
VmallocTotal:     122880 kB
VmallocUsed:       15760 kB
VmallocChunk:      97884 kB
HardwareCorrupted:     0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       4096 kB
DirectMap4k:       20472 kB
DirectMap4M:      884736 kB
#

--
Rob.                          (Robert de Bath <robert$ @ debath.co.uk>)
                                             <http://www.debath.co.uk/>
diff -urd ../old/./swapspace-1.10/src/memory.c ./swapspace-1.10/src/memory.c
--- ../old/./swapspace-1.10/src/memory.c        2006-07-25 03:28:25.000000000 
+0100
+++ ./swapspace-1.10/src/memory.c       2012-10-21 20:04:12.730266259 +0100
@@ -209,7 +209,8 @@
            Writeback,
            SwapCached,
            SwapTotal,
-           SwapFree;
+           SwapFree,
+           Shmem;
 };
 
 
@@ -240,6 +241,7 @@
       else if (strcmp(inf->entry+4, "Free")==0)   st->SwapFree = inf->value;
       else if (strcmp(inf->entry+4, "Cached")==0) st->SwapCached = inf->value;
     }
+    if (strcmp(inf->entry,"Shmem")==0)            st->Shmem = inf->value;
     break;
   case 'W':
     if (strcmp(inf->entry,"Writeback")==0)        st->Writeback = inf->value;
@@ -310,7 +312,7 @@
 /// How much cache space can we expect the system to free up?
 static inline memsize_t cache_free(const struct memstate *st)
 {
-  const memsize_t cache = st->Cached - (st->Dirty + st->Writeback);
+  const memsize_t cache = st->Cached - (st->Dirty + st->Writeback + st->Shmem);
   return (cache > 0) ? (cache/100)*cache_elasticity : 0;
 }
 

Reply via email to