Bug 74771 - Slab cache is nearly not freed if the system gets out of physical memory
Summary: Slab cache is nearly not freed if the system gets out of physical memory
Status: NEW
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Other (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Andrew Morton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-24 18:16 UTC by sworddragon2
Modified: 2020-02-03 11:58 UTC (History)
1 user (show)

See Also:
Kernel Version: 3.13.9
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description sworddragon2 2014-04-24 18:16:19 UTC
I'm noticing if the physical memory goes empty so that the system if forced to swap only a few MiB from the slab will be freed while SReclaimable can still contain a few hundred MiB.

Here is the status of my system before doing a memory intensive operation:

root@ubuntu:~# sysctl -a | grep 'vm\.swappiness'
vm.swappiness = 0
root@ubuntu:~# cat /proc/meminfo | grep -E '(MemTotal|MemFree|SwapTotal|SwapFree|SReclaimable|SUnreclaim):'
MemTotal:       16434012 kB
MemFree:        14976456 kB
SwapTotal:      16776188 kB
SwapFree:       16776188 kB
SReclaimable:     266476 kB
SUnreclaim:        58296 kB


On doing a memory intensive operation (like scaling an image with GIMP that needs more than 16 GiB) the status looks this:

root@ubuntu:~# cat /proc/meminfo | grep -E '(MemTotal|MemFree|SwapTotal|SwapFree|SReclaimable|SUnreclaim):'
MemTotal:       16434012 kB
MemFree:          155424 kB
SwapTotal:      16776188 kB
SwapFree:       14834100 kB
SReclaimable:     228020 kB
SUnreclaim:        58168 kB


As this shows the system suffers of a lack of physical memory and has already swapped nearly 2 GiB. But there are still over 200 MiB in the slab cache that could be freed to reduce the swapping.
Comment 1 Vincent Lefevre 2020-02-03 11:58:34 UTC
I have the same issue with 4.19 under Debian/stable:

Linux joooj 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64 GNU/Linux

With "sync; echo 3 > /proc/sys/vm/drop_caches", I could slightly decrease the Slab values from

Slab:             307464 kB
SReclaimable:     232808 kB
SUnreclaim:        74656 kB

to

Slab:             285440 kB
SReclaimable:     211832 kB
SUnreclaim:        73608 kB

but though I have 303908 KB available according to "free", I can't allocate 200 MB:

joooj:~> memhog 200M
................zsh: killed     memhog 200M

In the kernel logs:

[...]
Feb 03 12:48:31 joooj kernel: Mem-Info:
Feb 03 12:48:31 joooj kernel: active_anon:13436 inactive_anon:13539 isolated_anon:0
                               active_file:10 inactive_file:10 isolated_file:0
                               unevictable:2400 dirty:0 writeback:5 unstable:0
                               slab_reclaimable:52958 slab_unreclaimable:18448
                               mapped:1083 shmem:8 pagetables:1239 bounce:0
                               free:1052 free_pcp:0 free_cma:0
[...]
Feb 03 12:48:31 joooj kernel: Out of memory: Kill process 18345 (memhog) score 182 or sacrifice child
Feb 03 12:48:31 joooj kernel: Killed process 18345 (memhog) total-vm:207148kB, anon-rss:92052kB, file-rss:1372kB, shmem-rss:0kB
Feb 03 12:48:31 joooj kernel: oom_reaper: reaped process 18345 (memhog), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

Note You need to log in before you can comment on or make changes to this bug.