All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: use kvmalloc instead of kmalloc for devkmsg_user
       [not found] <CGME20210830071701epcms1p70f72ae10940bc407a3c33746d20da771@epcms1p7>
@ 2021-08-30  7:17 ` 이용택
  2021-08-31 12:42   ` Petr Mladek
  0 siblings, 1 reply; 4+ messages in thread
From: 이용택 @ 2021-08-30  7:17 UTC (permalink / raw)
  To: pmladek, senozhatsky, rostedt, john.ogness, linux-kernel
  Cc: 이용택

Size of struct devkmsg_user increased to 16784 by commit 896fbe20b4e2
("printk: use the lockless ringbuffer") so order3(32kb) is needed for
kmalloc. Under stress conditions the kernel may temporary fail to
allocate 32k with kmalloc. Use kvmalloc instead of kmalloc to aviod
this issue.

qseecomd invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=3, oom_score_adj=-1000
Call trace:
 dump_backtrace+0x0/0x34c
 dump_stack_lvl+0xd4/0x16c
 dump_header+0x5c/0x338
 out_of_memory+0x374/0x4cc
 __alloc_pages_slowpath+0xbc8/0x1130
 __alloc_pages_nodemask+0x170/0x1b0
 kmalloc_order+0x5c/0x24c
 devkmsg_open+0x1f4/0x558
 memory_open+0x94/0xf0
 chrdev_open+0x288/0x3dc
 do_dentry_open+0x2b4/0x618
 path_openat+0xce4/0xfa8
 do_filp_open+0xb0/0x164
 do_sys_openat2+0xa8/0x264
 __arm64_sys_openat+0x70/0xa0
 el0_svc_common+0xc4/0x270
 el0_svc+0x34/0x9c
 el0_sync_handler+0x88/0xf0
 el0_sync+0x1bc/0x200

 DMA32: 4521*4kB (UMEC) 1377*8kB (UMECH) 73*16kB (UM) 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 30268kB
 Normal: 2490*4kB (UMEH) 277*8kB (UMH) 27*16kB (UH) 1*32kB (H) 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12640kB

Signed-off-by: Yong-Taek Lee <ytk.lee@samsung.com>
---
 kernel/printk/printk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 142a58d124d9..8ba1602232ec 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -862,7 +862,7 @@ static int devkmsg_open(struct inode *inode, struct file *file)
                        return err;
        }

-       user = kmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);
+       user = kvmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);
        if (!user)
                return -ENOMEM;

@@ -892,7 +892,7 @@ static int devkmsg_release(struct inode *inode, struct file *file)
        ratelimit_state_exit(&user->rs);

        mutex_destroy(&user->lock);
-       kfree(user);
+       kvfree(user);
        return 0;
 }

--
2.17.1
 

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

* Re: [PATCH] printk: use kvmalloc instead of kmalloc for devkmsg_user
  2021-08-30  7:17 ` [PATCH] printk: use kvmalloc instead of kmalloc for devkmsg_user 이용택
@ 2021-08-31 12:42   ` Petr Mladek
  2021-08-31 23:02     ` Sergey Senozhatsky
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Mladek @ 2021-08-31 12:42 UTC (permalink / raw)
  To: 이용택; +Cc: senozhatsky, rostedt, john.ogness, linux-kernel

On Mon 2021-08-30 16:17:01, 이용택 wrote:
> Size of struct devkmsg_user increased to 16784 by commit 896fbe20b4e2
> ("printk: use the lockless ringbuffer") so order3(32kb) is needed for
> kmalloc. Under stress conditions the kernel may temporary fail to
> allocate 32k with kmalloc. Use kvmalloc instead of kmalloc to aviod
> this issue.
> 
> qseecomd invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=3, oom_score_adj=-1000
> Call trace:
>  dump_backtrace+0x0/0x34c
>  dump_stack_lvl+0xd4/0x16c
>  dump_header+0x5c/0x338
>  out_of_memory+0x374/0x4cc
>  __alloc_pages_slowpath+0xbc8/0x1130
>  __alloc_pages_nodemask+0x170/0x1b0
>  kmalloc_order+0x5c/0x24c
>  devkmsg_open+0x1f4/0x558
>  memory_open+0x94/0xf0
>  chrdev_open+0x288/0x3dc
>  do_dentry_open+0x2b4/0x618
>  path_openat+0xce4/0xfa8
>  do_filp_open+0xb0/0x164
>  do_sys_openat2+0xa8/0x264
>  __arm64_sys_openat+0x70/0xa0
>  el0_svc_common+0xc4/0x270
>  el0_svc+0x34/0x9c
>  el0_sync_handler+0x88/0xf0
>  el0_sync+0x1bc/0x200
> 
>  DMA32: 4521*4kB (UMEC) 1377*8kB (UMECH) 73*16kB (UM) 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 30268kB
>  Normal: 2490*4kB (UMEH) 277*8kB (UMH) 27*16kB (UH) 1*32kB (H) 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12640kB
> 
> Signed-off-by: Yong-Taek Lee <ytk.lee@samsung.com>

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

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

* Re: [PATCH] printk: use kvmalloc instead of kmalloc for devkmsg_user
  2021-08-31 12:42   ` Petr Mladek
@ 2021-08-31 23:02     ` Sergey Senozhatsky
  2021-09-07 13:23       ` Petr Mladek
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Senozhatsky @ 2021-08-31 23:02 UTC (permalink / raw)
  To: Petr Mladek
  Cc: 이용택,
	senozhatsky, rostedt, john.ogness, linux-kernel

On (21/08/31 14:42), Petr Mladek wrote:
> On Mon 2021-08-30 16:17:01, 이용택 wrote:
> > Size of struct devkmsg_user increased to 16784 by commit 896fbe20b4e2
> > ("printk: use the lockless ringbuffer") so order3(32kb) is needed for
> > kmalloc. Under stress conditions the kernel may temporary fail to
> > allocate 32k with kmalloc. Use kvmalloc instead of kmalloc to aviod
> > this issue.
> > 
> > qseecomd invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=3, oom_score_adj=-1000
> > Call trace:
> >  dump_backtrace+0x0/0x34c
> >  dump_stack_lvl+0xd4/0x16c
> >  dump_header+0x5c/0x338
> >  out_of_memory+0x374/0x4cc
> >  __alloc_pages_slowpath+0xbc8/0x1130
> >  __alloc_pages_nodemask+0x170/0x1b0
> >  kmalloc_order+0x5c/0x24c
> >  devkmsg_open+0x1f4/0x558
> >  memory_open+0x94/0xf0
> >  chrdev_open+0x288/0x3dc
> >  do_dentry_open+0x2b4/0x618
> >  path_openat+0xce4/0xfa8
> >  do_filp_open+0xb0/0x164
> >  do_sys_openat2+0xa8/0x264
> >  __arm64_sys_openat+0x70/0xa0
> >  el0_svc_common+0xc4/0x270
> >  el0_svc+0x34/0x9c
> >  el0_sync_handler+0x88/0xf0
> >  el0_sync+0x1bc/0x200
> > 
> >  DMA32: 4521*4kB (UMEC) 1377*8kB (UMECH) 73*16kB (UM) 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 30268kB
> >  Normal: 2490*4kB (UMEH) 277*8kB (UMH) 27*16kB (UH) 1*32kB (H) 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12640kB
> > 
> > Signed-off-by: Yong-Taek Lee <ytk.lee@samsung.com>
> 
> Reviewed-by: Petr Mladek <pmladek@suse.com>

Acked-by: Sergey Senozhatsky <senozhatsky@chromium.org>

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

* Re: [PATCH] printk: use kvmalloc instead of kmalloc for devkmsg_user
  2021-08-31 23:02     ` Sergey Senozhatsky
@ 2021-09-07 13:23       ` Petr Mladek
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Mladek @ 2021-09-07 13:23 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: 이용택, rostedt, john.ogness, linux-kernel

On Wed 2021-09-01 08:02:09, Sergey Senozhatsky wrote:
> On (21/08/31 14:42), Petr Mladek wrote:
> > On Mon 2021-08-30 16:17:01, 이용택 wrote:
> > > Size of struct devkmsg_user increased to 16784 by commit 896fbe20b4e2
> > > ("printk: use the lockless ringbuffer") so order3(32kb) is needed for
> > > kmalloc. Under stress conditions the kernel may temporary fail to
> > > allocate 32k with kmalloc. Use kvmalloc instead of kmalloc to aviod
> > > this issue.
> > > 
> > > qseecomd invoked oom-killer: gfp_mask=0x40cc0(GFP_KERNEL|__GFP_COMP), order=3, oom_score_adj=-1000
> > > Call trace:
> > >  dump_backtrace+0x0/0x34c
> > >  dump_stack_lvl+0xd4/0x16c
> > >  dump_header+0x5c/0x338
> > >  out_of_memory+0x374/0x4cc
> > >  __alloc_pages_slowpath+0xbc8/0x1130
> > >  __alloc_pages_nodemask+0x170/0x1b0
> > >  kmalloc_order+0x5c/0x24c
> > >  devkmsg_open+0x1f4/0x558
> > >  memory_open+0x94/0xf0
> > >  chrdev_open+0x288/0x3dc
> > >  do_dentry_open+0x2b4/0x618
> > >  path_openat+0xce4/0xfa8
> > >  do_filp_open+0xb0/0x164
> > >  do_sys_openat2+0xa8/0x264
> > >  __arm64_sys_openat+0x70/0xa0
> > >  el0_svc_common+0xc4/0x270
> > >  el0_svc+0x34/0x9c
> > >  el0_sync_handler+0x88/0xf0
> > >  el0_sync+0x1bc/0x200
> > > 
> > >  DMA32: 4521*4kB (UMEC) 1377*8kB (UMECH) 73*16kB (UM) 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 30268kB
> > >  Normal: 2490*4kB (UMEH) 277*8kB (UMH) 27*16kB (UH) 1*32kB (H) 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12640kB
> > > 
> > > Signed-off-by: Yong-Taek Lee <ytk.lee@samsung.com>
> > 
> > Reviewed-by: Petr Mladek <pmladek@suse.com>
> 
> Acked-by: Sergey Senozhatsky <senozhatsky@chromium.org>

The patch has been comitted into printk/linux.git, branch for-5.16.

Best Regards,
Petr

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

end of thread, other threads:[~2021-09-07 13:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210830071701epcms1p70f72ae10940bc407a3c33746d20da771@epcms1p7>
2021-08-30  7:17 ` [PATCH] printk: use kvmalloc instead of kmalloc for devkmsg_user 이용택
2021-08-31 12:42   ` Petr Mladek
2021-08-31 23:02     ` Sergey Senozhatsky
2021-09-07 13:23       ` Petr Mladek

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.