linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc
       [not found] <CGME20220330052214epcas1p250cff6b3168a1c9c253e1fe70e68ca8b@epcas1p2.samsung.com>
@ 2022-03-30  5:25 ` Jaewon Kim
  2022-03-30  8:06   ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Jaewon Kim @ 2022-03-30  5:25 UTC (permalink / raw)
  To: minchan, ngupta, senozhatsky, akpm
  Cc: linux-mm, linux-kernel, s.suk, jaewon31.kim, Jaewon Kim

The page allocation with GFP_NOIO may fail. And zram can handle this
allocation failure. We do not need to print log for this.

Actually warn_alloc was more restricted by commit 1be334e5c088
("mm/page_alloc.c: ratelimit allocation failure warnings more
aggressively"). To catch other allocation failure, zram can use
__GFP_NOWARN.

This is what I got.

kswapd0: page allocation failure: order:0, mode:0x140000a(GFP_NOIO|__GFP_HIGHMEM|__GFP_MOVABLE), nodemask=(null)
kswapd0 cpuset=/ mems_allowed=0
Call trace:
 dump_backtrace+0x0/0x218
 show_stack+0x14/0x1c
 dump_stack+0xb8/0xf0
 warn_alloc+0x110/0x234
 __alloc_pages_nodemask+0x11c0/0x12a0
 zs_malloc+0x1ac/0x50c
 zram_bvec_rw+0x1a4/0x6a8
 zram_make_request+0x23c/0x328
 generic_make_request+0xe4/0x270
 submit_bio+0x64/0x2a8
 __swap_writepage+0x3a8/0x404
 swap_writepage+0x40/0x4c
 shrink_page_list.llvm.15153564514306699876+0xffc/0x13a0
 shrink_inactive_list+0x2dc/0x710
 shrink_node_memcg+0x394/0x940
 shrink_node+0x194/0x380

Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
---
 drivers/block/zram/zram_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e9474b02012d..c22201da25bb 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1405,6 +1405,7 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
 		atomic64_inc(&zram->stats.writestall);
 		handle = zs_malloc(zram->mem_pool, comp_len,
 				GFP_NOIO | __GFP_HIGHMEM |
+				__GFP_NOWARN |
 				__GFP_MOVABLE);
 		if (handle)
 			goto compress_again;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc
  2022-03-30  5:25 ` [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc Jaewon Kim
@ 2022-03-30  8:06   ` Michal Hocko
  2022-03-30  8:41     ` Sergey Senozhatsky
  2022-03-30  8:49     ` Michal Hocko
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Hocko @ 2022-03-30  8:06 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: minchan, ngupta, senozhatsky, akpm, linux-mm, linux-kernel,
	s.suk, jaewon31.kim

On Wed 30-03-22 14:25:02, Jaewon Kim wrote:
> The page allocation with GFP_NOIO may fail. And zram can handle this
> allocation failure. We do not need to print log for this.

GFP_NOIO doesn't have any special meaning wrt to failures. zram
allocates from the memory reclaim context which is a bad design IMHO.
The failure you are seeing indicates that PF_MEMALLOC context (memory
reclaim) which is allow to dip into memory reserves without any limit
cannot find any memory! This is really bad and it is good to learn about
that.

Your description doesn't really explain why we should be ignoring that
situation. Is the memory allocation failure gracefully recoverable?

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc
  2022-03-30  8:06   ` Michal Hocko
@ 2022-03-30  8:41     ` Sergey Senozhatsky
  2022-03-30  8:49     ` Michal Hocko
  1 sibling, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2022-03-30  8:41 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Jaewon Kim, minchan, ngupta, senozhatsky, akpm, linux-mm,
	linux-kernel, s.suk, jaewon31.kim

On (22/03/30 10:06), Michal Hocko wrote:
> On Wed 30-03-22 14:25:02, Jaewon Kim wrote:
> > The page allocation with GFP_NOIO may fail. And zram can handle this
> > allocation failure. We do not need to print log for this.
> 
> GFP_NOIO doesn't have any special meaning wrt to failures. zram
> allocates from the memory reclaim context which is a bad design IMHO.

Agreed.

> Is the memory allocation failure gracefully recoverable?

No, it's not. I agree that we want to see that allocation warning
in the logs.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc
  2022-03-30  8:06   ` Michal Hocko
  2022-03-30  8:41     ` Sergey Senozhatsky
@ 2022-03-30  8:49     ` Michal Hocko
  2022-03-30  9:11       ` Jaewon Kim
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2022-03-30  8:49 UTC (permalink / raw)
  To: Jaewon Kim
  Cc: minchan, ngupta, senozhatsky, akpm, linux-mm, linux-kernel,
	s.suk, jaewon31.kim

On Wed 30-03-22 10:06:18, Michal Hocko wrote:
> On Wed 30-03-22 14:25:02, Jaewon Kim wrote:
> > The page allocation with GFP_NOIO may fail. And zram can handle this
> > allocation failure. We do not need to print log for this.
> 
> GFP_NOIO doesn't have any special meaning wrt to failures. zram
> allocates from the memory reclaim context which is a bad design IMHO.

Btw. I forgot to mention that GFP_NOIO doesn't have any different
meaning than GFP_KERNEL from this (PF_MEMALLOC) allocation context
because this request will never perform a reclaim.
-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc
  2022-03-30  8:49     ` Michal Hocko
@ 2022-03-30  9:11       ` Jaewon Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Jaewon Kim @ 2022-03-30  9:11 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Jaewon Kim, minchan, ngupta, senozhatsky, Andrew Morton,
	linux-mm, linux-kernel, s.suk

2022년 3월 30일 (수) 오후 5:49, Michal Hocko <mhocko@suse.com>님이 작성:
>
> On Wed 30-03-22 10:06:18, Michal Hocko wrote:
> > On Wed 30-03-22 14:25:02, Jaewon Kim wrote:
> > > The page allocation with GFP_NOIO may fail. And zram can handle this
> > > allocation failure. We do not need to print log for this.
> >
> > GFP_NOIO doesn't have any special meaning wrt to failures. zram
> > allocates from the memory reclaim context which is a bad design IMHO.
>
> Btw. I forgot to mention that GFP_NOIO doesn't have any different
> meaning than GFP_KERNEL from this (PF_MEMALLOC) allocation context
> because this request will never perform a reclaim.

Thank you for reply

Yes it was kswapd with PF_MEMALLOC, but I thought this zs_malloc could
fail on direct reclaim context.

I think zram is gracefully handling this ENOMEM situation, it actually
accounts the failed count as zram stats.
The failed page will be tried to swap out again later.

Yes I need to look into more about this memory shortage.
But I thought there were too many ALLOC_HADER requests in a short
time, and I want to see other
allocation failure logs like one with GFP_ATOMIC instead of this
zs_malloc failure log.

> --
> Michal Hocko
> SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-30  9:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220330052214epcas1p250cff6b3168a1c9c253e1fe70e68ca8b@epcas1p2.samsung.com>
2022-03-30  5:25 ` [PATCH] zram_drv: add __GFP_NOWARN flag on call to zs_malloc Jaewon Kim
2022-03-30  8:06   ` Michal Hocko
2022-03-30  8:41     ` Sergey Senozhatsky
2022-03-30  8:49     ` Michal Hocko
2022-03-30  9:11       ` Jaewon Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).