Bug 195863 - btrfs check of a big filesystem kills the kernel due to OOM (but btrfs userspace is not OOM killed)
Summary: btrfs check of a big filesystem kills the kernel due to OOM (but btrfs usersp...
Status: RESOLVED OBSOLETE
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-23 16:40 UTC by Marc MERLIN
Modified: 2022-10-06 17:49 UTC (History)
2 users (show)

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


Attachments

Description Marc MERLIN 2017-05-23 16:40:42 UTC
I have a 16TB filesystem on a system with 24GB of RAM.

On 4.11, btrfs check --repair, which looks like it would take userspace RAM, also seems to take a lot of kernel memory until the entire system falls over, as shown here:
https://www.spinics.net/lists/linux-btrfs/msg65720.html

On 4.8, the system falls over in a different way, but still kills the kernel in a way that btrfs check does not get killed by OOM and cannot be stopped. The machine deadlocks and needs to be rebooted uncleanly
https://www.spinics.net/lists/linux-btrfs/msg65722.html

I see 2 issues here:
1) if btrfs check truly does not take kernel memory, why is it not OOM killed when it runs out of memory?
2) if it is taking kernel memory, like it seems to given all the kernel processes it stalls and backs up, there should be some limit set so that btrfs check of a filesystem too big to fit in RAM does not kill the system.
Comment 1 Marc MERLIN 2017-05-23 17:29:15 UTC
Here is an example of a state where I ran out of RAM due to btrfs check.
I don't know how to read this to see whether I ran out of kernel reserved RAM or not, but I do see
Free swap  = 15366388kB
Total swap = 15616764kB
If btrfs check was simply malloc'ing RAM and running out, why was no swap used and why did the OOM never fire?

btrfs-transacti: page allocation stalls for 23508ms, order:0, mode:0x1400840(GFP_NOFS|__GFP_NOFAIL), nodemask=(null)
btrfs-transacti cpuset=/ mems_allowed=0
Mem-Info:
active_anon:5274313 inactive_anon:378373 isolated_anon:3590
 active_file:3711 inactive_file:3809 isolated_file:0
 unevictable:1467 dirty:5068 writeback:49189 unstable:0
 slab_reclaimable:8721 slab_unreclaimable:67310
 mapped:556943 shmem:801313 pagetables:15777 bounce:0
 free:89741 free_pcp:6 free_cma:0
Node 0 active_anon:21097252kB inactive_anon:1513492kB active_file:14844kB inactive_file:15236kB unevictable:5868kB
isolated(anon):14360kB isolated(file):0kB mapped:2227772kB dirty:20272kB writeback:196756kB shmem:3205252kB shmem_thp: 0kB
shmem_pmdmapped: 0kB anon_thp: 0kB writeback_tmp:0kB unstable:0kB pages_scanned:215184 all_unreclaimable? no
Node 0 DMA free:15880kB min:168kB low:208kB high:248kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB
unevictable:0kB writepending:0kB present:15972kB managed:15888kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:8kB
kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 3201 23768 23768 23768
Node 0 DMA32 free:116720kB min:35424kB low:44280kB high:53136kB active_anon:3161376kB inactive_anon:8kB active_file:320kB
inactive_file:332kB unevictable:0kB writepending:612kB present:3362068kB managed:3296500kB mlocked:0kB slab_reclaimable:460kB
slab_unreclaimable:668kB kernel_stack:16kB pagetables:7292kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 0 20567 20567 20567
Node 0 Normal free:226664kB min:226544kB low:283180kB high:339816kB active_anon:17935552kB inactive_anon:1513564kB
active_file:14524kB inactive_file:14904kB unevictable:5868kB writepending:216372kB present:21485568kB managed:21080208kB
mlocked:5868kB slab_reclaimable:34412kB slab_unreclaimable:268520kB kernel_stack:12480kB pagetables:55816kB bounce:0kB
free_pcp:148kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 0 0 0 0
Node 0 DMA: 0*4kB 1*8kB (U) 0*16kB 0*32kB 2*64kB (U) 1*128kB (U) 1*256kB (U) 0*512kB 1*1024kB (U) 1*2048kB (M) 3*4096kB (M) =
15880kB
Node 0 DMA32: 768*4kB (UME) 740*8kB (UME) 685*16kB (UME) 446*32kB (UME) 427*64kB (UME) 233*128kB (UME) 79*256kB (UME) 10*512kB
(UME) 0*1024kB 0*2048kB 0*4096kB = 116720kB
Node 0 Normal: 25803*4kB (UME) 11297*8kB (UME) 947*16kB (UME) 260*32kB (ME) 72*64kB (UM) 15*128kB (UM) 1*256kB (U) 0*512kB
0*1024kB 0*2048kB 0*4096kB = 223844kB
Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
858720 total pagecache pages
49221 pages in swap cache
Swap cache stats: add 62319, delete 13131, find 75/76
Free swap  = 15366388kB
Total swap = 15616764kB
6215902 pages RAM
0 pages HighMem/MovableOnly
117753 pages reserved
4096 pages cma reserved
Comment 2 David Sterba 2022-10-06 17:49:40 UTC
This is a semi-automated bugzilla cleanup, report is against an old kernel version. If the problem still happens, please open a new bug. Thanks.

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