Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1653910 > unrolled thread
| Started by | Jia-Ju Bai <baijiaju1990@163.com> |
|---|---|
| First post | 2017-05-31 09:30 +0200 |
| Last post | 2017-05-31 10:40 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] bcache: Fix a sleep-in-atomic bug Jia-Ju Bai <baijiaju1990@163.com> - 2017-05-31 09:30 +0200
Re: [PATCH] bcache: Fix a sleep-in-atomic bug Kent Overstreet <kent.overstreet@gmail.com> - 2017-05-31 10:00 +0200
Re: [PATCH] bcache: Fix a sleep-in-atomic bug Jia-Ju Bai <baijiaju1990@163.com> - 2017-05-31 10:40 +0200
| From | Jia-Ju Bai <baijiaju1990@163.com> |
|---|---|
| Date | 2017-05-31 09:30 +0200 |
| Subject | [PATCH] bcache: Fix a sleep-in-atomic bug |
| Message-ID | <tN6eS-1Kf-17@gated-at.bofh.it> |
The driver may sleep under a spin lock, and the function call path is:
journal_wait_for_write (acquire the lock by spin_lock)
closure_sync
schedule --> may sleep
To fix it, the lock is released before "closure_sync", and the lock is
acquired again after this function.
Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
drivers/md/bcache/journal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 1198e53..ad47c36 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -724,6 +724,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
btree_flush_write(c);
}
+ spin_unlock(&c->journal.lock);
closure_sync(&cl);
spin_lock(&c->journal.lock);
wait = true;
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Kent Overstreet <kent.overstreet@gmail.com> |
|---|---|
| Date | 2017-05-31 10:00 +0200 |
| Message-ID | <tN6HU-1Tw-19@gated-at.bofh.it> |
| In reply to | #1653910 |
On Wed, May 31, 2017 at 03:23:40PM +0800, Jia-Ju Bai wrote: > The driver may sleep under a spin lock, and the function call path is: > journal_wait_for_write (acquire the lock by spin_lock) > closure_sync > schedule --> may sleep This patch is incorrect, you've introduced a double unlock. Did you actually observe a sleep in atomic? > > To fix it, the lock is released before "closure_sync", and the lock is > acquired again after this function. > > Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com> > --- > drivers/md/bcache/journal.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c > index 1198e53..ad47c36 100644 > --- a/drivers/md/bcache/journal.c > +++ b/drivers/md/bcache/journal.c > @@ -724,6 +724,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, > btree_flush_write(c); > } > > + spin_unlock(&c->journal.lock); > closure_sync(&cl); > spin_lock(&c->journal.lock); > wait = true; > -- > 1.7.9.5 > >
[toc] | [prev] | [next] | [standalone]
| From | Jia-Ju Bai <baijiaju1990@163.com> |
|---|---|
| Date | 2017-05-31 10:40 +0200 |
| Message-ID | <tN7kC-2mN-9@gated-at.bofh.it> |
| In reply to | #1653910 |
On 05/31/2017 03:23 PM, Jia-Ju Bai wrote: > The driver may sleep under a spin lock, and the function call path is: > journal_wait_for_write (acquire the lock by spin_lock) > closure_sync > schedule --> may sleep > > To fix it, the lock is released before "closure_sync", and the lock is > acquired again after this function. > > Signed-off-by: Jia-Ju Bai<baijiaju1990@163.com> > --- > drivers/md/bcache/journal.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c > index 1198e53..ad47c36 100644 > --- a/drivers/md/bcache/journal.c > +++ b/drivers/md/bcache/journal.c > @@ -724,6 +724,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, > btree_flush_write(c); > } > > + spin_unlock(&c->journal.lock); > closure_sync(&cl); > spin_lock(&c->journal.lock); > wait = true; Sorry, my patch is not correct, and it will cause double unlock. Please ignore my patch. Jia-Ju Bai
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web