Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1653939 > unrolled thread
| Started by | Jia-Ju Bai <baijiaju1990@163.com> |
|---|---|
| First post | 2017-05-31 10:00 +0200 |
| Last post | 2017-06-03 16:10 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH V2] libcfs: Fix a sleep-in-atomic bug in cfs_wi_exit Jia-Ju Bai <baijiaju1990@163.com> - 2017-05-31 10:00 +0200
Re: [PATCH V2] libcfs: Fix a sleep-in-atomic bug in cfs_wi_exit Oleg Drokin <oleg.drokin@intel.com> - 2017-05-31 15:50 +0200
Re: [PATCH V2] libcfs: Fix a sleep-in-atomic bug in cfs_wi_exit Greg KH <gregkh@linuxfoundation.org> - 2017-06-03 16:10 +0200
| From | Jia-Ju Bai <baijiaju1990@163.com> |
|---|---|
| Date | 2017-05-31 10:00 +0200 |
| Subject | [PATCH V2] libcfs: Fix a sleep-in-atomic bug in cfs_wi_exit |
| Message-ID | <tN6HU-1Tw-11@gated-at.bofh.it> |
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);
+ }
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
[toc] | [next] | [standalone]
| From | Oleg Drokin <oleg.drokin@intel.com> |
|---|---|
| Date | 2017-05-31 15:50 +0200 |
| Message-ID | <tNcaC-5tQ-31@gated-at.bofh.it> |
| In reply to | #1653939 |
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
>
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-06-03 16:10 +0200 |
| Message-ID | <tOhUC-81i-25@gated-at.bofh.it> |
| In reply to | #1653939 |
On Wed, May 31, 2017 at 04:00:41PM +0800, 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(-) What changed from v1? You have to always tell us that. Please redo all of these, if they are still valid patches, and send them as a patch series, so I know what order they should be applied in. thanks, greg k-h
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web