* [PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_wi_schedule
@ 2017-05-31 7:53 Jia-Ju Bai
0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2017-05-31 7:53 UTC (permalink / raw)
To: oleg.drokin, andreas.dilger, jsimmons, gregkh, bobijam.xu, dmitry.eremin
Cc: lustre-devel, devel, linux-kernel, Jia-Ju Bai
The driver may sleep under a spin lock, and the function call path is:
cfs_wi_schedule (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 | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c
index dbc2a9b..30d28cd 100644
--- a/drivers/staging/lustre/lnet/libcfs/workitem.c
+++ b/drivers/staging/lustre/lnet/libcfs/workitem.c
@@ -179,12 +179,12 @@ struct cfs_wi_sched {
{
LASSERT(!in_interrupt()); /* because we use plain spinlock */
LASSERT(!sched->ws_stopping);
+ if (!wi->wi_scheduled)
+ LASSERT(list_empty(&wi->wi_list));
spin_lock(&sched->ws_lock);
if (!wi->wi_scheduled) {
- LASSERT(list_empty(&wi->wi_list));
-
wi->wi_scheduled = 1;
sched->ws_nscheduled++;
if (!wi->wi_running) {
@@ -195,8 +195,8 @@ struct cfs_wi_sched {
}
}
- LASSERT(!list_empty(&wi->wi_list));
spin_unlock(&sched->ws_lock);
+ LASSERT(!list_empty(&wi->wi_list));
}
EXPORT_SYMBOL(cfs_wi_schedule);
--
1.7.9.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-31 7:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 7:53 [PATCH] libcfs: Fix a sleep-in-atomic bug in cfs_wi_schedule Jia-Ju Bai
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.