<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
setting overcommit_memory to 0 solved the issue of OOM panic.  After the first failure of malloc() the system rebooted.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<pre>0    -       Heuristic overcommit handling. Obvious overcommits of
                address space are refused. Used for a typical system. It
                ensures a seriously wild allocation fails while allowing
                overcommit to reduce swap usage.  root is allowed to 
                allocate slightly more memory in this mode. This is the 
                default.</pre>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Now I just need to decide if I am going to use OOM's panic and reboot or watchdog's.  With watchdog I have a repair script that runs and keeps count allowing the system 2m to recover from ENOMEM.  OOM panic will reboot on the first ENOMEM.  The issue of not
 using all available ram can be addressed via overcommit_ratio.  To use watchdog, I could keep overcommit_memory at 2 and set the ratio to 80%.  The remaining 20% is reserved for kernel memory usage.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
The sitting of 2 and the ration of 5o also explains why I was able to malloc() more when I had enabled 500M of swap.  It is 50% of (RAM+SWAP).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Is tmpfs kernel space?  I need to verify that because this system does not mount a drive as /  It uses unionfs where the software is in a ro image and the n any thing written in / ends up on a tmpfs.   Exactly like an Ubuntu livecd.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I could also disable OOM panic, set overcommit_memory to 0 and use watchdog.  If watchdog is killed for whatever reason the system will reboot since it is using /dev/watchdog.
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
  <br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Jim Kinney <jim.kinney@gmail.com><br>
<b>Sent:</b> Saturday, August 22, 2020 10:56 AM<br>
<b>To:</b> Chris Fowler <cfowler@outpostsentinel.com>; Atlanta Linux Enthusiasts <ale@ale.org><br>
<b>Subject:</b> Re: [ale] Free is not showing me correct used memory</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">When did memory over commit become safely possible? I don't have to dig often into details of memory management but sometime in kernel 2 days a major change occured. Memory was marked allocated when requested regardless of use. But a different
 request process was used to report use. The overcommit allowed unused but allocated memory to be used by another process. The change merged those two or clarified or something. Been a long time. I also vaguely recall there might have been a race condition
 in the first few iterations of the change. Something to do with a thread problem and the over commit not playing well together.<br>
<br>
<br>
<br>
<div class="x_gmail_quote">On August 22, 2020 10:30:01 AM EDT, Chris Fowler <cfowler@outpostsentinel.com> wrote:
<blockquote class="x_gmail_quote" style="margin:0pt 0pt 0pt 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div id="x_appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
When I copied that program from the web page I noticed something odd, but did not question it. 
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">memset(b, TEN_MB, 0)</span>;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
The size argument is the last one!  It should've been. As many times that I've used memset() I should have corrected it the first time.  Just me being an idiot and not second guessing someone else's program.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">memset(b, 0x0, TEN_MB);</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:"Courier New",monospace">[root@basement]# free</span>
<div><span style="font-family:"Courier New",monospace">             total       used       free     shared    buffers cached</span></div>
<div><span style="font-family:"Courier New",monospace">Mem:       1964784    1225620     739164          0       5108  24632</span></div>
<div><span style="font-family:"Courier New",monospace">-/+ buffers/cache:    1195880     768904</span></div>
<div><span style="font-family:"Courier New",monospace">Swap:       524284          0     524284</span></div>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Now I'd like to ask the stupid question of why does Linux consider memory allocated via malloc(), but not used not good enough to mark that memory as used for /proc/meminfo?  I can't mallco() anymore anyway.  This is why watchdog's active test of trying to
 allocate memory is better than its passive test of just groking /poc/memifno.<br>
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Jim Kinney <jim.kinney@gmail.com><br>
<b>Sent:</b> Friday, August 21, 2020 10:20 PM<br>
<b>To:</b> Chris Fowler <cfowler@outpostsentinel.com>; Atlanta Linux Enthusiasts <ale@ale.org><br>
<b>Subject:</b> Re: [ale] Free is not showing me correct used memory</font>
<div> </div>
</div>
<div dir="ltr">Is your ram fully functional? Memtest results are 100% perfect?<br>
<br>
Cgroups can direct oomkiller to odd locations.<br>
<br>
Strange problem.<br>
<br>
<div class="x_x_gmail_quote">On August 21, 2020 8:33:17 PM EDT, Chris Fowler via Ale <ale@ale.org> wrote:
<blockquote class="x_x_gmail_quote" style="margin:0pt 0pt 0pt 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I just enabled 500M of swap on the device, but it does not use disk.  I uses a zram device.   The kernel configured 500M of compressed ram for the use of swap.  The oom program was able to grab 134 chunks before watchdog restarted.  That's 1.3G.  Is my kernel
 config wrong?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Chris<br>
</div>
<div id="x_x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Ale <ale-bounces@ale.org> on behalf of Chris Fowler via Ale <ale@ale.org><br>
<b>Sent:</b> Friday, August 21, 2020 8:16 PM<br>
<b>To:</b> ALE <ale@ale.org><br>
<b>Subject:</b> [ale] Free is not showing me correct used memory</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I've ran into an issue on a device which runs out of memory, but it refuses to panic on OOM.  This creates a DOS affect.  No SSH to the device, but I am still able to ping it. After reboot messages in syslog show the device has ran out of memory.  Kernel is
 2.,6.38 and system is 32bit.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I followed instructions on the URL below to test OOM panic.  I compiled an ran the program to test.  On a system with kernel 5.6.0 the OOM panics and system is restarted.  It works, but on the problem device it is as if the OOM is not fully aware. free, /proc/meminfo,
 vmstat, etc do not show memory usage skyrocketing as it does on the other system.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Free on the problem device before I run the program:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<span style="font-family:"Courier New",monospace">[root@basement]# free</span>
<div><span style="font-family:"Courier New",monospace">             total       used       free     shared    buffers cached</span></div>
<div><span style="font-family:"Courier New",monospace">Mem:       1964728     235380    1729348          0      12064  55388</span></div>
<div><span style="font-family:"Courier New",monospace">-/+ buffers/cache:     167928    1796800</span></div>
<div><span style="font-family:"Courier New",monospace">Swap:            0          0          0</span></div>
<br>
Now, I run it and it is able to allocate 82 chunks at 10M each before malloc() failed:<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<span style="font-family:"Courier New",monospace">[root@basement]#  oom</span><br>
<div><span style="font-family:"Courier New",monospace">Allocated 82 chunks.</span></div>
<div><span style="font-family:"Courier New",monospace">Sleeping 60(s) before exiting.</span></div>
<div><br>
</div>
<div>In another xterm I'll run free while oom is waiting to exit.  Once it exits, all that memory is freed. No change.<br>
</div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace">[root@basement]# free</span>
<div><span style="font-family:"Courier New",monospace">             total       used       free     shared    buffers cached</span></div>
<div><span style="font-family:"Courier New",monospace">Mem:       1964728     236380    1728348          0      12112  55388</span></div>
<div><span style="font-family:"Courier New",monospace">-/+ buffers/cache:     168880    1795848</span></div>
<div><span style="font-family:"Courier New",monospace">Swap:            0          0          0</span></div>
</div>
<div><br>
</div>
<div>If I run oom in another window it will only grab 2 chunks before failure.  Also, watchdog is configured to restart if it can't allocate 20M of memory.  Watchdog will restart the device because it is unable to grab it.</div>
<div><br>
</div>
The system itself has 2G of RAM.  <br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
If that program was able to allocate 82x10 820M of RAM why did that not show up as used memory?  Now, I'm curious as to why Iw as only able to allocate 830M if there is 1.7GB free? 
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Below is grep 'MEM' config:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<span style="font-family:"Courier New",monospace"># CONFIG_CGROUP_MEM_RES_CTLR is not set</span>
<div><span style="font-family:"Courier New",monospace">CONFIG_SHMEM=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_NO_BOOTMEM=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_MEMTEST is not set</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_NOHIGHMEM is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_HIGHMEM4G=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_HIGHMEM64G is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_HIGHMEM=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_ARCH_FLATMEM_ENABLE=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_ARCH_SPARSEMEM_ENABLE=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_ARCH_SELECT_MEMORY_MODEL=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_SELECT_MEMORY_MODEL=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_FLATMEM_MANUAL=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_SPARSEMEM_MANUAL is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_FLATMEM=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_FLAT_NODE_MEM_MAP=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_SPARSEMEM_STATIC=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_HAVE_MEMBLOCK=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_MEMORY_FAILURE is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_BLK_DEV_UMEM is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_INPUT_FF_MEMLESS=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_DEVKMEM=y</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_FIX_EARLYCON_MEM=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_HW_RANDOM_TIMERIOMEM is not set</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_MEMSTICK is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_FIRMWARE_MEMMAP=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_DEBUG_KMEMLEAK is not set</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_DEBUG_HIGHMEM is not set</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_DEBUG_MEMORY_INIT is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_HAVE_ARCH_KMEMCHECK=y</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_STRICT_DEVMEM is not set</span></div>
<div><span style="font-family:"Courier New",monospace">CONFIG_ASYNC_MEMCPY=y</span></div>
<span style="font-family:"Courier New",monospace">CONFIG_HAS_IOMEM=y</span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Also:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<span style="font-family:"Courier New",monospace">CONFIG_VMSPLIT_3G=y                                                              </span>
<div><span style="font-family:"Courier New",monospace"># CONFIG_VMSPLIT_3G_OPT is not set                                              
</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_VMSPLIT_2G is not set                                                  
</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_VMSPLIT_2G_OPT is not set                                              
</span></div>
<div><span style="font-family:"Courier New",monospace"># CONFIG_VMSPLIT_1G is not set                                                  
</span></div>
<span style="font-family:"Courier New",monospace">CONFIG_PAGE_OFFSET=0xC0000000  </span>    
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
-- <br>
"no government by experts in which the masses do not have the chance to inform the experts as to their needs can be anything but an oligarchy managed in the interests of the few.” - John Dewey</div>
</body>
</html>