All of lore.kernel.org
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Michal Hocko <mhocko@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	Vlastimil Babka <vbabka@suse.cz>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Sangseok Lee <sangseok.lee@lge.com>
Subject: Re: [PATCH 0/4] use up highorder free pages before OOM
Date: Sat, 8 Oct 2016 00:04:25 +0900	[thread overview]
Message-ID: <20161007150425.GD3060@bbox> (raw)
In-Reply-To: <20161007091625.GB18447@dhcp22.suse.cz>

On Fri, Oct 07, 2016 at 11:16:26AM +0200, Michal Hocko wrote:
> On Fri 07-10-16 14:45:32, Minchan Kim wrote:
> > I got OOM report from production team with v4.4 kernel.
> > It has enough free memory but failed to allocate order-0 page and
> > finally encounter OOM kill.
> > I could reproduce it with my test easily. Look at below.
> > The reason is free pages(19M) of DMA32 zone are reserved for
> > HIGHORDERATOMIC and doesn't unreserved before the OOM.
> 
> Is this really reproducible?

I can reproduce in 1 hour.

> 
> [...]
> > active_anon:383949 inactive_anon:106724 isolated_anon:0
> >  active_file:15 inactive_file:44 isolated_file:0
> >  unevictable:0 dirty:0 writeback:24 unstable:0
> >  slab_reclaimable:2483 slab_unreclaimable:3326
> >  mapped:0 shmem:0 pagetables:1906 bounce:0
> >  free:6898 free_pcp:291 free_cma:0
> [...]
> > Free swap  = 8kB
> > Total swap = 255996kB
> > 524158 pages RAM
> > 0 pages HighMem/MovableOnly
> > 12658 pages reserved
> > 0 pages cma reserved
> > 0 pages hwpoisoned
> 
> From the above you can see that you are pretty much out of memory. There
> is basically no pagecache to reclaim and your anon memory is not 
> reclaimable either because the swap is basically full. It is true that 
> the high atomic reserves consume 19MB which could be reused but this 
> less than 1%, especially when you compare that to the amount of reserved
> memory.

I can show other log which reserve greater than 1%. See the DMA32 zone
free pages. It was GFP_ATOMIC allocation so it's different with I posted
but important thing is VM can reserve memory greater than 1% by the race
which was really what we want.

in:imklog: page allocation failure: order:0, mode:0x2280020(GFP_ATOMIC|__GFP_NOTRACK)
CPU: 0 PID: 476 Comm: in:imklog Tainted: G            E   4.8.0-rc7-00217-g266ef83c51e5-dirty #3135
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
 0000000000000000 ffff880077c37590 ffffffff81389033 0000000000000000
 0000000000000000 ffff880077c37618 ffffffff8117519b 0228002000000000
 ffffffffffffffff ffffffff81cedb40 0000000000000000 0000000000000040
Call Trace:
 [<ffffffff81389033>] dump_stack+0x63/0x90
 [<ffffffff8117519b>] warn_alloc_failed+0xdb/0x130
 [<ffffffff81175746>] __alloc_pages_nodemask+0x4d6/0xdb0
 [<ffffffff8120c149>] ? bdev_write_page+0xa9/0xd0
 [<ffffffff811a97b3>] ? __page_check_address+0xd3/0x130
 [<ffffffff811ba4ea>] ? deactivate_slab+0x12a/0x3e0
 [<ffffffff811b9549>] new_slab+0x339/0x490
 [<ffffffff811bad37>] ___slab_alloc.constprop.74+0x367/0x480
 [<ffffffff814601ad>] ? alloc_indirect.isra.14+0x1d/0x50
 [<ffffffff8109d0c2>] ? default_wake_function+0x12/0x20
 [<ffffffff811bae70>] __slab_alloc.constprop.73+0x20/0x40
 [<ffffffff811bb034>] __kmalloc+0x1a4/0x1e0
 [<ffffffff814601ad>] alloc_indirect.isra.14+0x1d/0x50
 [<ffffffff81460434>] virtqueue_add_sgs+0x1c4/0x470
 [<ffffffff81365075>] ? __bt_get.isra.8+0xe5/0x1c0
 [<ffffffff8150973e>] __virtblk_add_req+0xae/0x1f0
 [<ffffffff810b37d0>] ? wake_atomic_t_function+0x60/0x60
 [<ffffffff810337b9>] ? sched_clock+0x9/0x10
 [<ffffffff81360afb>] ? __blk_mq_alloc_request+0x10b/0x230
 [<ffffffff8135e293>] ? blk_rq_map_sg+0x213/0x550
 [<ffffffff81509a1d>] virtio_queue_rq+0x12d/0x290
 [<ffffffff813629c9>] __blk_mq_run_hw_queue+0x239/0x370
 [<ffffffff8136276f>] blk_mq_run_hw_queue+0x8f/0xb0
 [<ffffffff8136397c>] blk_mq_insert_requests+0x18c/0x1a0
 [<ffffffff81364865>] blk_mq_flush_plug_list+0x125/0x140
 [<ffffffff813596a7>] blk_flush_plug_list+0xc7/0x220
 [<ffffffff81359bec>] blk_finish_plug+0x2c/0x40
 [<ffffffff8117b836>] __do_page_cache_readahead+0x196/0x230
 [<ffffffffa00006ba>] ? zram_free_page+0x3a/0xb0 [zram]
 [<ffffffff8116f928>] filemap_fault+0x448/0x4f0
 [<ffffffff8119e9e4>] ? alloc_set_pte+0xe4/0x350
 [<ffffffff8125fa16>] ext4_filemap_fault+0x36/0x50
 [<ffffffff8119be35>] __do_fault+0x75/0x140
 [<ffffffff8119f6cd>] handle_mm_fault+0x84d/0xbe0
 [<ffffffff812483e4>] ? kmsg_read+0x44/0x60
 [<ffffffff8106029d>] __do_page_fault+0x1dd/0x4d0
 [<ffffffff81060653>] trace_do_page_fault+0x43/0x130
 [<ffffffff81059bda>] do_async_page_fault+0x1a/0xa0
 [<ffffffff8179dcb8>] async_page_fault+0x28/0x30
Mem-Info:
active_anon:363826 inactive_anon:121283 isolated_anon:32
 active_file:65 inactive_file:152 isolated_file:0
 unevictable:0 dirty:0 writeback:46 unstable:0
 slab_reclaimable:2778 slab_unreclaimable:3070
 mapped:112 shmem:0 pagetables:1822 bounce:0
 free:9469 free_pcp:231 free_cma:0
Node 0 active_anon:1455304kB inactive_anon:485132kB active_file:260kB inactive_file:608kB unevictable:0kB isolated(anon):128kB isolated(file):0kB mapped:448kB dirty:0kB writeback:184kB shmem:0kB writeback_tmp:0kB unstable:0kB pages_scanned:13641 all_unreclaimable? no
DMA free:7748kB min:44kB low:56kB high:68kB active_anon:7944kB inactive_anon:104kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15908kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:108kB kernel_stack:0kB pagetables:4kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 1952 1952 1952
DMA32 free:30128kB min:5628kB low:7624kB high:9620kB active_anon:1447360kB inactive_anon:485028kB active_file:260kB inactive_file:608kB unevictable:0kB writepending:184kB present:2080640kB managed:2030132kB mlocked:0kB slab_reclaimable:11112kB slab_unreclaimable:12172kB kernel_stack:2400kB pagetables:7284kB bounce:0kB free_pcp:924kB local_pcp:72kB free_cma:0kB
lowmem_reserve[]: 0 0 0 0
DMA: 7*4kB (UE) 3*8kB (UH) 1*16kB (M) 0*32kB 2*64kB (U) 1*128kB (M) 1*256kB (U) 0*512kB 1*1024kB (U) 1*2048kB (U) 1*4096kB (H) = 7748kB
DMA32: 10*4kB (H) 3*8kB (H) 47*16kB (H) 38*32kB (H) 5*64kB (H) 1*128kB (H) 2*256kB (H) 3*512kB (H) 3*1024kB (H) 3*2048kB (H) 4*4096kB (H) = 30128kB
2775 total pagecache pages
2536 pages in swap cache
Swap cache stats: add 206786828, delete 206784292, find 7323106/106686077
Free swap  = 108744kB
Total swap = 255996kB
524158 pages RAM
0 pages HighMem/MovableOnly
12648 pages reserved
0 pages cma reserved
0 pages hwpoisoned

> 
> So while I do agree that potential issues - misaccounting and others you
> are addressing in the follow up patch - are good to fix but I believe that
> draining last 19M is not something that would reliably get you over the
> edge. Your workload (93% of memory sitting on anon LRU with swap full)
> simply doesn't fit into the amount of memory you have available.

What happens if the workload fit into additional 19M memory?
I admit my testing aimed for proving the problem but with this patchset,
there is no OOM killing with many free pages and the number of OOM was
reduced highly. It is definitely better than old.

Please don't ignore 1% memory in embedded system. 20M memory in 2G system,
If we can use those for zram, it is 60~80M memory via compression.
You should know how many engineers try to reduce 1M of their driver to
cost down of the product, seriously.

> -- 
> Michal Hocko
> SUSE Labs

WARNING: multiple messages have this Message-ID (diff)
From: Minchan Kim <minchan@kernel.org>
To: Michal Hocko <mhocko@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	Vlastimil Babka <vbabka@suse.cz>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Sangseok Lee <sangseok.lee@lge.com>
Subject: Re: [PATCH 0/4] use up highorder free pages before OOM
Date: Sat, 8 Oct 2016 00:04:25 +0900	[thread overview]
Message-ID: <20161007150425.GD3060@bbox> (raw)
In-Reply-To: <20161007091625.GB18447@dhcp22.suse.cz>

On Fri, Oct 07, 2016 at 11:16:26AM +0200, Michal Hocko wrote:
> On Fri 07-10-16 14:45:32, Minchan Kim wrote:
> > I got OOM report from production team with v4.4 kernel.
> > It has enough free memory but failed to allocate order-0 page and
> > finally encounter OOM kill.
> > I could reproduce it with my test easily. Look at below.
> > The reason is free pages(19M) of DMA32 zone are reserved for
> > HIGHORDERATOMIC and doesn't unreserved before the OOM.
> 
> Is this really reproducible?

I can reproduce in 1 hour.

> 
> [...]
> > active_anon:383949 inactive_anon:106724 isolated_anon:0
> >  active_file:15 inactive_file:44 isolated_file:0
> >  unevictable:0 dirty:0 writeback:24 unstable:0
> >  slab_reclaimable:2483 slab_unreclaimable:3326
> >  mapped:0 shmem:0 pagetables:1906 bounce:0
> >  free:6898 free_pcp:291 free_cma:0
> [...]
> > Free swap  = 8kB
> > Total swap = 255996kB
> > 524158 pages RAM
> > 0 pages HighMem/MovableOnly
> > 12658 pages reserved
> > 0 pages cma reserved
> > 0 pages hwpoisoned
> 
> From the above you can see that you are pretty much out of memory. There
> is basically no pagecache to reclaim and your anon memory is not 
> reclaimable either because the swap is basically full. It is true that 
> the high atomic reserves consume 19MB which could be reused but this 
> less than 1%, especially when you compare that to the amount of reserved
> memory.

I can show other log which reserve greater than 1%. See the DMA32 zone
free pages. It was GFP_ATOMIC allocation so it's different with I posted
but important thing is VM can reserve memory greater than 1% by the race
which was really what we want.

in:imklog: page allocation failure: order:0, mode:0x2280020(GFP_ATOMIC|__GFP_NOTRACK)
CPU: 0 PID: 476 Comm: in:imklog Tainted: G            E   4.8.0-rc7-00217-g266ef83c51e5-dirty #3135
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
 0000000000000000 ffff880077c37590 ffffffff81389033 0000000000000000
 0000000000000000 ffff880077c37618 ffffffff8117519b 0228002000000000
 ffffffffffffffff ffffffff81cedb40 0000000000000000 0000000000000040
Call Trace:
 [<ffffffff81389033>] dump_stack+0x63/0x90
 [<ffffffff8117519b>] warn_alloc_failed+0xdb/0x130
 [<ffffffff81175746>] __alloc_pages_nodemask+0x4d6/0xdb0
 [<ffffffff8120c149>] ? bdev_write_page+0xa9/0xd0
 [<ffffffff811a97b3>] ? __page_check_address+0xd3/0x130
 [<ffffffff811ba4ea>] ? deactivate_slab+0x12a/0x3e0
 [<ffffffff811b9549>] new_slab+0x339/0x490
 [<ffffffff811bad37>] ___slab_alloc.constprop.74+0x367/0x480
 [<ffffffff814601ad>] ? alloc_indirect.isra.14+0x1d/0x50
 [<ffffffff8109d0c2>] ? default_wake_function+0x12/0x20
 [<ffffffff811bae70>] __slab_alloc.constprop.73+0x20/0x40
 [<ffffffff811bb034>] __kmalloc+0x1a4/0x1e0
 [<ffffffff814601ad>] alloc_indirect.isra.14+0x1d/0x50
 [<ffffffff81460434>] virtqueue_add_sgs+0x1c4/0x470
 [<ffffffff81365075>] ? __bt_get.isra.8+0xe5/0x1c0
 [<ffffffff8150973e>] __virtblk_add_req+0xae/0x1f0
 [<ffffffff810b37d0>] ? wake_atomic_t_function+0x60/0x60
 [<ffffffff810337b9>] ? sched_clock+0x9/0x10
 [<ffffffff81360afb>] ? __blk_mq_alloc_request+0x10b/0x230
 [<ffffffff8135e293>] ? blk_rq_map_sg+0x213/0x550
 [<ffffffff81509a1d>] virtio_queue_rq+0x12d/0x290
 [<ffffffff813629c9>] __blk_mq_run_hw_queue+0x239/0x370
 [<ffffffff8136276f>] blk_mq_run_hw_queue+0x8f/0xb0
 [<ffffffff8136397c>] blk_mq_insert_requests+0x18c/0x1a0
 [<ffffffff81364865>] blk_mq_flush_plug_list+0x125/0x140
 [<ffffffff813596a7>] blk_flush_plug_list+0xc7/0x220
 [<ffffffff81359bec>] blk_finish_plug+0x2c/0x40
 [<ffffffff8117b836>] __do_page_cache_readahead+0x196/0x230
 [<ffffffffa00006ba>] ? zram_free_page+0x3a/0xb0 [zram]
 [<ffffffff8116f928>] filemap_fault+0x448/0x4f0
 [<ffffffff8119e9e4>] ? alloc_set_pte+0xe4/0x350
 [<ffffffff8125fa16>] ext4_filemap_fault+0x36/0x50
 [<ffffffff8119be35>] __do_fault+0x75/0x140
 [<ffffffff8119f6cd>] handle_mm_fault+0x84d/0xbe0
 [<ffffffff812483e4>] ? kmsg_read+0x44/0x60
 [<ffffffff8106029d>] __do_page_fault+0x1dd/0x4d0
 [<ffffffff81060653>] trace_do_page_fault+0x43/0x130
 [<ffffffff81059bda>] do_async_page_fault+0x1a/0xa0
 [<ffffffff8179dcb8>] async_page_fault+0x28/0x30
Mem-Info:
active_anon:363826 inactive_anon:121283 isolated_anon:32
 active_file:65 inactive_file:152 isolated_file:0
 unevictable:0 dirty:0 writeback:46 unstable:0
 slab_reclaimable:2778 slab_unreclaimable:3070
 mapped:112 shmem:0 pagetables:1822 bounce:0
 free:9469 free_pcp:231 free_cma:0
Node 0 active_anon:1455304kB inactive_anon:485132kB active_file:260kB inactive_file:608kB unevictable:0kB isolated(anon):128kB isolated(file):0kB mapped:448kB dirty:0kB writeback:184kB shmem:0kB writeback_tmp:0kB unstable:0kB pages_scanned:13641 all_unreclaimable? no
DMA free:7748kB min:44kB low:56kB high:68kB active_anon:7944kB inactive_anon:104kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15908kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:108kB kernel_stack:0kB pagetables:4kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 1952 1952 1952
DMA32 free:30128kB min:5628kB low:7624kB high:9620kB active_anon:1447360kB inactive_anon:485028kB active_file:260kB inactive_file:608kB unevictable:0kB writepending:184kB present:2080640kB managed:2030132kB mlocked:0kB slab_reclaimable:11112kB slab_unreclaimable:12172kB kernel_stack:2400kB pagetables:7284kB bounce:0kB free_pcp:924kB local_pcp:72kB free_cma:0kB
lowmem_reserve[]: 0 0 0 0
DMA: 7*4kB (UE) 3*8kB (UH) 1*16kB (M) 0*32kB 2*64kB (U) 1*128kB (M) 1*256kB (U) 0*512kB 1*1024kB (U) 1*2048kB (U) 1*4096kB (H) = 7748kB
DMA32: 10*4kB (H) 3*8kB (H) 47*16kB (H) 38*32kB (H) 5*64kB (H) 1*128kB (H) 2*256kB (H) 3*512kB (H) 3*1024kB (H) 3*2048kB (H) 4*4096kB (H) = 30128kB
2775 total pagecache pages
2536 pages in swap cache
Swap cache stats: add 206786828, delete 206784292, find 7323106/106686077
Free swap  = 108744kB
Total swap = 255996kB
524158 pages RAM
0 pages HighMem/MovableOnly
12648 pages reserved
0 pages cma reserved
0 pages hwpoisoned

> 
> So while I do agree that potential issues - misaccounting and others you
> are addressing in the follow up patch - are good to fix but I believe that
> draining last 19M is not something that would reliably get you over the
> edge. Your workload (93% of memory sitting on anon LRU with swap full)
> simply doesn't fit into the amount of memory you have available.

What happens if the workload fit into additional 19M memory?
I admit my testing aimed for proving the problem but with this patchset,
there is no OOM killing with many free pages and the number of OOM was
reduced highly. It is definitely better than old.

Please don't ignore 1% memory in embedded system. 20M memory in 2G system,
If we can use those for zram, it is 60~80M memory via compression.
You should know how many engineers try to reduce 1M of their driver to
cost down of the product, seriously.

> -- 
> Michal Hocko
> SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-10-07 15:45 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07  5:45 [PATCH 0/4] use up highorder free pages before OOM Minchan Kim
2016-10-07  5:45 ` Minchan Kim
2016-10-07  5:45 ` [PATCH 1/4] mm: adjust reserved highatomic count Minchan Kim
2016-10-07  5:45   ` Minchan Kim
2016-10-07 12:30   ` Vlastimil Babka
2016-10-07 12:30     ` Vlastimil Babka
2016-10-07 14:29     ` Minchan Kim
2016-10-07 14:29       ` Minchan Kim
2016-10-10  6:57       ` Vlastimil Babka
2016-10-10  6:57         ` Vlastimil Babka
2016-10-11  4:19         ` Minchan Kim
2016-10-11  4:19           ` Minchan Kim
2016-10-11  9:40           ` Vlastimil Babka
2016-10-11  9:40             ` Vlastimil Babka
2016-10-12  5:36           ` Mel Gorman
2016-10-12  5:36             ` Mel Gorman
2016-10-07  5:45 ` [PATCH 2/4] mm: prevent double decrease of nr_reserved_highatomic Minchan Kim
2016-10-07  5:45   ` Minchan Kim
2016-10-07 12:44   ` Vlastimil Babka
2016-10-07 12:44     ` Vlastimil Babka
2016-10-07 14:30     ` Minchan Kim
2016-10-07 14:30       ` Minchan Kim
2016-10-12  5:36   ` Mel Gorman
2016-10-12  5:36     ` Mel Gorman
2016-10-07  5:45 ` [PATCH 3/4] mm: unreserve highatomic free pages fully before OOM Minchan Kim
2016-10-07  5:45   ` Minchan Kim
2016-10-07  9:09   ` Michal Hocko
2016-10-07  9:09     ` Michal Hocko
2016-10-07 14:43     ` Minchan Kim
2016-10-07 14:43       ` Minchan Kim
2016-10-10  7:41       ` Michal Hocko
2016-10-10  7:41         ` Michal Hocko
2016-10-11  5:01         ` Minchan Kim
2016-10-11  5:01           ` Minchan Kim
2016-10-11  6:50           ` Michal Hocko
2016-10-11  6:50             ` Michal Hocko
2016-10-11  7:09             ` Minchan Kim
2016-10-11  7:09               ` Minchan Kim
2016-10-11  7:26               ` Michal Hocko
2016-10-11  7:26                 ` Michal Hocko
2016-10-11  7:37                 ` Minchan Kim
2016-10-11  7:37                   ` Minchan Kim
2016-10-11  8:01                   ` Michal Hocko
2016-10-11  8:01                     ` Michal Hocko
2016-10-07  5:45 ` [PATCH 4/4] mm: skip to reserve pageblock crossed zone boundary for HIGHATOMIC Minchan Kim
2016-10-07  5:45   ` Minchan Kim
2016-10-07  9:16 ` [PATCH 0/4] use up highorder free pages before OOM Michal Hocko
2016-10-07  9:16   ` Michal Hocko
2016-10-07 15:04   ` Minchan Kim [this message]
2016-10-07 15:04     ` Minchan Kim
2016-10-10  7:47     ` Michal Hocko
2016-10-10  7:47       ` Michal Hocko
2016-10-11  5:06       ` Minchan Kim
2016-10-11  5:06         ` Minchan Kim
2016-10-11  6:53         ` Michal Hocko
2016-10-11  6:53           ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161007150425.GD3060@bbox \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@kernel.org \
    --cc=sangseok.lee@lge.com \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.