From: Maxim Levitsky <maximlevitsky@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org,
Andrew Morton <akpm@linux-foundation.org>,
Maxim Levitsky <maximlevisky@gmail.com>,
Maciej Rutecki <maciej.rutecki@gmail.com>
Subject: Re: [PATCH 3/5] MTD: blktrans: fix a race vs kthread_stop.
Date: Mon, 25 Oct 2010 03:44:54 +0200 [thread overview]
Message-ID: <1287971094.5205.11.camel@maxim-laptop> (raw)
In-Reply-To: <1287966711.5674.26.camel@macbook.infradead.org>
On Mon, 2010-10-25 at 01:31 +0100, David Woodhouse wrote:
> On Fri, 2010-10-15 at 17:20 +0200, Maxim Levitsky wrote:
> > There is small race window that could make kthread_stop hang forever.
> > I found that while hacking the IR subsystem.
> >
> > Signed-off-by: Maxim Levitsky <maximlevisky@gmail.com>
> > ---
> > drivers/mtd/mtd_blkdevs.c | 4 ++++
> > 1 files changed, 4 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
> > index 040c2d9..a919587 100644
> > --- a/drivers/mtd/mtd_blkdevs.c
> > +++ b/drivers/mtd/mtd_blkdevs.c
> > @@ -133,6 +133,10 @@ static int mtd_blktrans_thread(void *arg)
> >
> > if (!req && !(req = blk_fetch_request(rq))) {
> > set_current_state(TASK_INTERRUPTIBLE);
> > +
> > + if (kthread_should_stop())
> > + set_current_state(TASK_RUNNING);
> > +
> > spin_unlock_irq(rq->queue_lock);
> > schedule();
> > spin_lock_irq(rq->queue_lock);
>
>
> Shouldn't we add a break in there too, so it immediately breaks out of
> the loop (with the lock held)?
It doesn't matter here, as schedule() won't make task sleep, so the
thread will break at next iteration.
Best regards
Maxim Levitsky
next prev parent reply other threads:[~2010-10-25 1:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-15 15:20 [MTD] My updates [RESEND] Maxim Levitsky
2010-10-15 15:20 ` [PATCH 1/5] MTD: blktrans: Allow to unload the mtdtrans module if its block devices aren't open Maxim Levitsky
2010-10-15 15:20 ` [PATCH 2/5] MTD: blktrans: kill the BKL Maxim Levitsky
2010-10-16 5:12 ` Wolfram Sang
2010-10-16 22:46 ` Maxim Levitsky
2010-10-17 8:51 ` Artem Bityutskiy
2010-10-15 15:20 ` [PATCH 3/5] MTD: blktrans: fix a race vs kthread_stop Maxim Levitsky
2010-10-25 0:31 ` David Woodhouse
2010-10-25 1:44 ` Maxim Levitsky [this message]
2010-10-15 15:20 ` [PATCH 4/5] MTD: r852: remove useless pci powerup/down from suspend/resume routines Maxim Levitsky
2010-10-15 15:20 ` [PATCH 5/5] mtd: sm_ftl: cosmetic, use bool when possible Maxim Levitsky
2010-10-17 10:15 ` [MTD] My updates [RESEND] Artem Bityutskiy
2010-10-17 10:22 ` Artem Bityutskiy
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=1287971094.5205.11.camel@maxim-laptop \
--to=maximlevitsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=maciej.rutecki@gmail.com \
--cc=maximlevisky@gmail.com \
/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