linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] ipmi: use vzalloc instead of kmalloc for user creation
@ 2020-04-17  5:01 Feng Tang
  2020-04-18  2:00 ` Corey Minyard
  0 siblings, 1 reply; 3+ messages in thread
From: Feng Tang @ 2020-04-17  5:01 UTC (permalink / raw)
  To: Corey Minyard, Arnd Bergmann, Greg Kroah-Hartman,
	openipmi-developer, linux-kernel
  Cc: Feng Tang

We met mulitple times of failure of staring bmc-watchdog,
due to the runtime memory allocation failure of order 4.

     bmc-watchdog: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0-1
     CPU: 1 PID: 2571 Comm: bmc-watchdog Not tainted 5.5.0-00045-g7d6bb61d6188c #1
     Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.00.01.0015.110720180833 11/07/2018
     Call Trace:
      dump_stack+0x66/0x8b
      warn_alloc+0xfe/0x160
      __alloc_pages_slowpath+0xd3e/0xd80
      __alloc_pages_nodemask+0x2f0/0x340
      kmalloc_order+0x18/0x70
      kmalloc_order_trace+0x1d/0xb0
      ipmi_create_user+0x55/0x2c0 [ipmi_msghandler]
      ipmi_open+0x72/0x110 [ipmi_devintf]
      chrdev_open+0xcb/0x1e0
      do_dentry_open+0x1ce/0x380
      path_openat+0x305/0x14f0
      do_filp_open+0x9b/0x110
      do_sys_open+0x1bd/0x250
      do_syscall_64+0x5b/0x1f0
      entry_SYSCALL_64_after_hwframe+0x44/0xa9

Using vzalloc/vfree for creating ipmi_user heals the
problem.

Signed-off-by: Feng Tang <feng.tang@intel.com>
---
 drivers/char/ipmi/ipmi_msghandler.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index c48d8f0..96f1573 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1153,7 +1153,7 @@ static void free_user_work(struct work_struct *work)
 					      remove_work);
 
 	cleanup_srcu_struct(&user->release_barrier);
-	kfree(user);
+	vfree(user);
 }
 
 int ipmi_create_user(unsigned int          if_num,
@@ -1185,7 +1185,7 @@ int ipmi_create_user(unsigned int          if_num,
 	if (rv)
 		return rv;
 
-	new_user = kmalloc(sizeof(*new_user), GFP_KERNEL);
+	new_user = vzalloc(sizeof(*new_user));
 	if (!new_user)
 		return -ENOMEM;
 
@@ -1232,7 +1232,7 @@ int ipmi_create_user(unsigned int          if_num,
 
 out_kfree:
 	srcu_read_unlock(&ipmi_interfaces_srcu, index);
-	kfree(new_user);
+	vfree(new_user);
 	return rv;
 }
 EXPORT_SYMBOL(ipmi_create_user);
-- 
2.7.4


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

* Re: [PATCH RFC] ipmi: use vzalloc instead of kmalloc for user creation
  2020-04-17  5:01 [PATCH RFC] ipmi: use vzalloc instead of kmalloc for user creation Feng Tang
@ 2020-04-18  2:00 ` Corey Minyard
  2020-04-18  2:26   ` Feng Tang
  0 siblings, 1 reply; 3+ messages in thread
From: Corey Minyard @ 2020-04-18  2:00 UTC (permalink / raw)
  To: Feng Tang
  Cc: Arnd Bergmann, Greg Kroah-Hartman, openipmi-developer, linux-kernel

On Fri, Apr 17, 2020 at 01:01:29PM +0800, Feng Tang wrote:
> We met mulitple times of failure of staring bmc-watchdog,
> due to the runtime memory allocation failure of order 4.

I'm beginning to think that using srcu was a bad idea.  It made things
cleaner and easier, but it eats tons of memory.  Sigh.

Applied, at least for a fix for now.

Thanks,

-corey

> 
>      bmc-watchdog: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0-1
>      CPU: 1 PID: 2571 Comm: bmc-watchdog Not tainted 5.5.0-00045-g7d6bb61d6188c #1
>      Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.00.01.0015.110720180833 11/07/2018
>      Call Trace:
>       dump_stack+0x66/0x8b
>       warn_alloc+0xfe/0x160
>       __alloc_pages_slowpath+0xd3e/0xd80
>       __alloc_pages_nodemask+0x2f0/0x340
>       kmalloc_order+0x18/0x70
>       kmalloc_order_trace+0x1d/0xb0
>       ipmi_create_user+0x55/0x2c0 [ipmi_msghandler]
>       ipmi_open+0x72/0x110 [ipmi_devintf]
>       chrdev_open+0xcb/0x1e0
>       do_dentry_open+0x1ce/0x380
>       path_openat+0x305/0x14f0
>       do_filp_open+0x9b/0x110
>       do_sys_open+0x1bd/0x250
>       do_syscall_64+0x5b/0x1f0
>       entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> Using vzalloc/vfree for creating ipmi_user heals the
> problem.
> 
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
>  drivers/char/ipmi/ipmi_msghandler.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index c48d8f0..96f1573 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -1153,7 +1153,7 @@ static void free_user_work(struct work_struct *work)
>  					      remove_work);
>  
>  	cleanup_srcu_struct(&user->release_barrier);
> -	kfree(user);
> +	vfree(user);
>  }
>  
>  int ipmi_create_user(unsigned int          if_num,
> @@ -1185,7 +1185,7 @@ int ipmi_create_user(unsigned int          if_num,
>  	if (rv)
>  		return rv;
>  
> -	new_user = kmalloc(sizeof(*new_user), GFP_KERNEL);
> +	new_user = vzalloc(sizeof(*new_user));
>  	if (!new_user)
>  		return -ENOMEM;
>  
> @@ -1232,7 +1232,7 @@ int ipmi_create_user(unsigned int          if_num,
>  
>  out_kfree:
>  	srcu_read_unlock(&ipmi_interfaces_srcu, index);
> -	kfree(new_user);
> +	vfree(new_user);
>  	return rv;
>  }
>  EXPORT_SYMBOL(ipmi_create_user);
> -- 
> 2.7.4
> 

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

* Re: [PATCH RFC] ipmi: use vzalloc instead of kmalloc for user creation
  2020-04-18  2:00 ` Corey Minyard
@ 2020-04-18  2:26   ` Feng Tang
  0 siblings, 0 replies; 3+ messages in thread
From: Feng Tang @ 2020-04-18  2:26 UTC (permalink / raw)
  To: Corey Minyard
  Cc: Arnd Bergmann, Greg Kroah-Hartman, openipmi-developer, linux-kernel

Hi Corey,

On Fri, Apr 17, 2020 at 09:00:06PM -0500, Corey Minyard wrote:
> On Fri, Apr 17, 2020 at 01:01:29PM +0800, Feng Tang wrote:
> > We met mulitple times of failure of staring bmc-watchdog,
> > due to the runtime memory allocation failure of order 4.
> 
> I'm beginning to think that using srcu was a bad idea.  It made things
> cleaner and easier, but it eats tons of memory.  Sigh.

Yes, I was aslo surprised when I first knew the scru_struct is
so big. I thought we may use kmem_cache to dynamically allocate
it, though there are only a few places in kernel.

> Applied, at least for a fix for now.
 
Thanks! It will save us a lot of troubles :)

- Feng

> Thanks,
> 
> -corey
> 
> > 
> >      bmc-watchdog: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0-1
> >      CPU: 1 PID: 2571 Comm: bmc-watchdog Not tainted 5.5.0-00045-g7d6bb61d6188c #1
> >      Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.00.01.0015.110720180833 11/07/2018
> >      Call Trace:
> >       dump_stack+0x66/0x8b
> >       warn_alloc+0xfe/0x160
> >       __alloc_pages_slowpath+0xd3e/0xd80
> >       __alloc_pages_nodemask+0x2f0/0x340
> >       kmalloc_order+0x18/0x70
> >       kmalloc_order_trace+0x1d/0xb0
> >       ipmi_create_user+0x55/0x2c0 [ipmi_msghandler]
> >       ipmi_open+0x72/0x110 [ipmi_devintf]
> >       chrdev_open+0xcb/0x1e0
> >       do_dentry_open+0x1ce/0x380
> >       path_openat+0x305/0x14f0
> >       do_filp_open+0x9b/0x110
> >       do_sys_open+0x1bd/0x250
> >       do_syscall_64+0x5b/0x1f0
> >       entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > 
> > Using vzalloc/vfree for creating ipmi_user heals the
> > problem.
> > 
> > Signed-off-by: Feng Tang <feng.tang@intel.com>
> > ---
> >  drivers/char/ipmi/ipmi_msghandler.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> > index c48d8f0..96f1573 100644
> > --- a/drivers/char/ipmi/ipmi_msghandler.c
> > +++ b/drivers/char/ipmi/ipmi_msghandler.c
> > @@ -1153,7 +1153,7 @@ static void free_user_work(struct work_struct *work)
> >  					      remove_work);
> >  
> >  	cleanup_srcu_struct(&user->release_barrier);
> > -	kfree(user);
> > +	vfree(user);
> >  }
> >  
> >  int ipmi_create_user(unsigned int          if_num,
> > @@ -1185,7 +1185,7 @@ int ipmi_create_user(unsigned int          if_num,
> >  	if (rv)
> >  		return rv;
> >  
> > -	new_user = kmalloc(sizeof(*new_user), GFP_KERNEL);
> > +	new_user = vzalloc(sizeof(*new_user));
> >  	if (!new_user)
> >  		return -ENOMEM;
> >  
> > @@ -1232,7 +1232,7 @@ int ipmi_create_user(unsigned int          if_num,
> >  
> >  out_kfree:
> >  	srcu_read_unlock(&ipmi_interfaces_srcu, index);
> > -	kfree(new_user);
> > +	vfree(new_user);
> >  	return rv;
> >  }
> >  EXPORT_SYMBOL(ipmi_create_user);
> > -- 
> > 2.7.4
> > 

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

end of thread, other threads:[~2020-04-18  2:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17  5:01 [PATCH RFC] ipmi: use vzalloc instead of kmalloc for user creation Feng Tang
2020-04-18  2:00 ` Corey Minyard
2020-04-18  2:26   ` Feng Tang

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).