From: Oleg Drokin <oleg.drokin@intel.com>
To: Jia-Ju Bai <baijiaju1990@163.com>
Cc: <andreas.dilger@intel.com>, <jsimmons@infradead.org>,
<gregkh@linuxfoundation.org>, <bobijam.xu@intel.com>,
<dmitry.eremin@intel.com>, <lustre-devel@lists.lustre.org>,
<devel@driverdev.osuosl.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] libcfs: Fix a sleep-in-atomic bug in cfs_wi_exit
Date: Wed, 31 May 2017 09:39:51 -0400 [thread overview]
Message-ID: <440F74B1-2F94-4C08-A9F9-EDF039BE6565@intel.com> (raw)
In-Reply-To: <1496217641-17002-1-git-send-email-baijiaju1990@163.com>
Hello!
On May 31, 2017, at 4:00 AM, Jia-Ju Bai wrote:
> The driver may sleep under a spin lock, and the function call path is:
> cfs_wi_exit (acquire the lock by spin_lock)
> LASSERT
> lbug_with_loc
> libcfs_debug_dumplog
> schedule and kthread_run --> may sleep
>
> To fix it, all "LASSERT" is placed out of the spin_lock and spin_unlock.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
> ---
> drivers/staging/lustre/lnet/libcfs/workitem.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c
> index dbc2a9b..928d06d 100644
> --- a/drivers/staging/lustre/lnet/libcfs/workitem.c
> +++ b/drivers/staging/lustre/lnet/libcfs/workitem.c
> @@ -111,22 +111,23 @@ struct cfs_wi_sched {
> {
> LASSERT(!in_interrupt()); /* because we use plain spinlock */
> LASSERT(!sched->ws_stopping);
> + LASSERT(wi->wi_running);
> + if (wi->wi_scheduled) {
> + LASSERT(!list_empty(&wi->wi_list));
> + LASSERT(sched->ws_nscheduled > 0);
> + }
Similarly here and in all other patches about LASSERT calls under spinlocks() from you,
just think of them as a panic() call, no operations are expected to continue
after it triggers.
Thanks.
>
> spin_lock(&sched->ws_lock);
>
> - LASSERT(wi->wi_running);
> if (wi->wi_scheduled) { /* cancel pending schedules */
> - LASSERT(!list_empty(&wi->wi_list));
> list_del_init(&wi->wi_list);
> -
> - LASSERT(sched->ws_nscheduled > 0);
> sched->ws_nscheduled--;
> }
>
> - LASSERT(list_empty(&wi->wi_list));
> -
> wi->wi_scheduled = 1; /* LBUG future schedule attempts */
> spin_unlock(&sched->ws_lock);
> +
> + LASSERT(list_empty(&wi->wi_list));
> }
> EXPORT_SYMBOL(cfs_wi_exit);
>
> --
> 1.7.9.5
>
next prev parent reply other threads:[~2017-05-31 13:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 8:00 Jia-Ju Bai
2017-05-31 13:39 ` Oleg Drokin [this message]
2017-06-03 8:50 ` Greg KH
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=440F74B1-2F94-4C08-A9F9-EDF039BE6565@intel.com \
--to=oleg.drokin@intel.com \
--cc=andreas.dilger@intel.com \
--cc=baijiaju1990@163.com \
--cc=bobijam.xu@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=dmitry.eremin@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®