答复: [PATCH] ipc: prevent lockup on alloc_msg and free_msg

From: Li,Rongqing
Date: Thu Mar 07 2019 - 21:03:59 EST




> -----邮件原件-----
> 发件人: linux-kernel-owner@xxxxxxxxxxxxxxx
> [mailto:linux-kernel-owner@xxxxxxxxxxxxxxx] 代表 Andrew Morton
> 发送时间: 2019年3月8日 2:10
> 收件人: Li,Rongqing <lirongqing@xxxxxxxxx>
> 抄送: linux-kernel@xxxxxxxxxxxxxxx; Davidlohr Bueso <dbueso@xxxxxxx>;
> Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>; Manfred Spraul
> <manfred@xxxxxxxxxxxxxxxx>; Arnd Bergmann <arnd@xxxxxxxx>
> 主题: Re: [PATCH] ipc: prevent lockup on alloc_msg and free_msg
>
> On Thu, 7 Mar 2019 16:10:22 +0800 Li RongQing <lirongqing@xxxxxxxxx>
> wrote:
>
> > From: Li Rongqing <lirongqing@xxxxxxxxx>
> >
> > msgctl10 of ltp triggers the following lockup When CONFIG_KASAN is
> > enabled on large memory SMP systems, the pages initialization can take
> > a long time, if msgctl10 requests a huge block memory, and it will
> > block rcu scheduler, so release cpu actively.
> >
> > ...
> >
> > Signed-off-by: Zhang Yu <zhangyu31@xxxxxxxxx>
> > Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>
>
> This signoff ordering somewhat implies that Zhang Yu was the author.
> But you added "From: Li Rongqing", so you will be recorded as the patch's
> author. Is this correct?
>
Thanks for your review.
I will revert this order

> > --- a/ipc/msgutil.c
> > +++ b/ipc/msgutil.c
> > @@ -18,6 +18,7 @@
> > #include <linux/utsname.h>
> > #include <linux/proc_ns.h>
> > #include <linux/uaccess.h>
> > +#include <linux/sched.h>
> >
> > #include "util.h"
> >
> > @@ -72,6 +73,7 @@ static struct msg_msg *alloc_msg(size_t len)
> > seg->next = NULL;
> > pseg = &seg->next;
> > len -= alen;
> > + cond_resched();
> > }
>
> This looks OK.
>
> > return msg;
> > @@ -178,5 +180,6 @@ void free_msg(struct msg_msg *msg)
> > struct msg_msgseg *tmp = seg->next;
> > kfree(seg);
> > seg = tmp;
> > + cond_resched();
> > }
>
> This does not. mqueue_evict_inode() (at least) calls free_msg() from under
> spin_lock().


I will try to fix it by moving the free_msg() out of spinlock , thanks

-RongQing