From: Andrew Morton <akpm@linux-foundation.org>
To: Hillf Danton <dhillf@gmail.com>
Cc: Kent Overstreet <koverstreet@google.com>,
Valdis.Kletnieks@vt.edu, bcrl@kvack.org, zab@zabbo.net,
linux-kernel@vger.kernel.org, linux-aio@kvack.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/3] aio-use-cancellation-list-lazily-fix
Date: Fri, 25 Jan 2013 15:12:51 -0800 [thread overview]
Message-ID: <20130125151251.0c90bf4b.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAJd=RBAhW7GXUYhem=j2OJtLA9Ru98rLvbU9bJ9iQJm2=CCwog@mail.gmail.com>
On Fri, 25 Jan 2013 21:30:32 +0800
Hillf Danton <dhillf@gmail.com> wrote:
> On Fri, Jan 25, 2013 at 5:43 AM, Kent Overstreet <koverstreet@google.com> wrote:
> > The cancellation changes were fubar - we can't cancel a kiocb if it
> > doesn't actually have a cancellation callback.
> >
> > The use of xchg() in aio_complete() was right - there we're marking the
> > kiocb as completed - but we need to use cmpxchg() in kiocb_cancel() - a
> > lock isn't sufficient since we're synchronizing with aio_complete()
> > which isn't taking any locks.
> >
> > static int kiocb_cancel(struct kioctx *ctx, struct kiocb *kiocb,
> > struct io_event *res)
> > {
> > - kiocb_cancel_fn *cancel;
> > + kiocb_cancel_fn *old, *cancel;
> > int ret = -EINVAL;
> >
> > - cancel = xchg(&kiocb->ki_cancel, KIOCB_CANCELLED);
> > - if (!cancel || cancel == KIOCB_CANCELLED)
> > - return ret;
> > + /*
> > + * Don't want to set kiocb->ki_cancel = KIOCB_CANCELLED unless it
> > + * actually has a cancel function, hence the cmpxchg()
> > + */
> > +
> > + cancel = ACCESS_ONCE(kiocb->ki_cancel);
> > + do {
> > + if (!cancel || cancel == KIOCB_CANCELLED)
> > + return ret;
> > +
> > + BUG();
>
> Hmm, what is trapped?
>
> > + old = cancel;
> > + cancel = cmpxchg(&kiocb->ki_cancel, old, KIOCB_CANCELLED);
> > + } while (cancel != old);
erk, I missed that. What earthly sense is there in putting a BUG() in
that place.
I think I'll delete it and pretend I never saw it :(
--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Hillf Danton <dhillf@gmail.com>
Cc: Kent Overstreet <koverstreet@google.com>,
Valdis.Kletnieks@vt.edu, bcrl@kvack.org, zab@zabbo.net,
linux-kernel@vger.kernel.org, linux-aio@kvack.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/3] aio-use-cancellation-list-lazily-fix
Date: Fri, 25 Jan 2013 15:12:51 -0800 [thread overview]
Message-ID: <20130125151251.0c90bf4b.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAJd=RBAhW7GXUYhem=j2OJtLA9Ru98rLvbU9bJ9iQJm2=CCwog@mail.gmail.com>
On Fri, 25 Jan 2013 21:30:32 +0800
Hillf Danton <dhillf@gmail.com> wrote:
> On Fri, Jan 25, 2013 at 5:43 AM, Kent Overstreet <koverstreet@google.com> wrote:
> > The cancellation changes were fubar - we can't cancel a kiocb if it
> > doesn't actually have a cancellation callback.
> >
> > The use of xchg() in aio_complete() was right - there we're marking the
> > kiocb as completed - but we need to use cmpxchg() in kiocb_cancel() - a
> > lock isn't sufficient since we're synchronizing with aio_complete()
> > which isn't taking any locks.
> >
> > static int kiocb_cancel(struct kioctx *ctx, struct kiocb *kiocb,
> > struct io_event *res)
> > {
> > - kiocb_cancel_fn *cancel;
> > + kiocb_cancel_fn *old, *cancel;
> > int ret = -EINVAL;
> >
> > - cancel = xchg(&kiocb->ki_cancel, KIOCB_CANCELLED);
> > - if (!cancel || cancel == KIOCB_CANCELLED)
> > - return ret;
> > + /*
> > + * Don't want to set kiocb->ki_cancel = KIOCB_CANCELLED unless it
> > + * actually has a cancel function, hence the cmpxchg()
> > + */
> > +
> > + cancel = ACCESS_ONCE(kiocb->ki_cancel);
> > + do {
> > + if (!cancel || cancel == KIOCB_CANCELLED)
> > + return ret;
> > +
> > + BUG();
>
> Hmm, what is trapped?
>
> > + old = cancel;
> > + cancel = cmpxchg(&kiocb->ki_cancel, old, KIOCB_CANCELLED);
> > + } while (cancel != old);
erk, I missed that. What earthly sense is there in putting a BUG() in
that place.
I think I'll delete it and pretend I never saw it :(
next prev parent reply other threads:[~2013-01-25 23:12 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-21 13:24 next-20130117 - kernel BUG with aio Valdis Kletnieks
2013-01-22 13:43 ` Hillf Danton
2013-01-22 21:28 ` Valdis.Kletnieks
2013-01-23 12:10 ` Hillf Danton
2013-01-24 17:22 ` Valdis.Kletnieks
2013-01-24 21:18 ` Kent Overstreet
2013-01-24 21:27 ` Andrew Morton
2013-01-24 21:27 ` Andrew Morton
2013-01-24 21:39 ` Kent Overstreet
2013-01-24 21:39 ` Kent Overstreet
2013-01-24 22:25 ` Zach Brown
2013-01-24 22:25 ` Zach Brown
2013-01-24 22:47 ` Jeff Moyer
2013-01-24 22:47 ` Jeff Moyer
2013-01-24 23:03 ` Kent Overstreet
2013-01-24 22:13 ` Kent Overstreet
2013-01-29 13:41 ` Jan Kara
2013-01-29 13:41 ` Jan Kara
2013-01-24 21:43 ` [PATCH 1/3] aio: Fix a null pointer deref in batch_complete_aio Kent Overstreet
2013-01-24 21:43 ` Kent Overstreet
2013-01-25 13:15 ` Hillf Danton
2013-01-25 13:15 ` Hillf Danton
2013-01-24 21:43 ` [PATCH 2/3] aio-kill-ki_retry-fix-fix Kent Overstreet
2013-01-24 21:43 ` Kent Overstreet
2013-01-24 21:43 ` [PATCH 3/3] aio-use-cancellation-list-lazily-fix Kent Overstreet
2013-01-24 21:43 ` Kent Overstreet
2013-01-25 13:30 ` Hillf Danton
2013-01-25 13:30 ` Hillf Danton
2013-01-25 23:12 ` Andrew Morton [this message]
2013-01-25 23:12 ` Andrew Morton
2013-01-28 17:37 ` Kent Overstreet
2013-01-28 17:37 ` Kent Overstreet
2013-01-31 21:59 ` next-20130117 - kernel BUG with aio Andrew Morton
2013-02-01 0:37 ` Kent Overstreet
2013-02-05 15:53 ` Valdis.Kletnieks
2013-02-05 17:20 ` Kent Overstreet
2013-02-05 17:48 ` Valdis.Kletnieks
2013-02-06 17:15 ` Valdis.Kletnieks
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=20130125151251.0c90bf4b.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Valdis.Kletnieks@vt.edu \
--cc=bcrl@kvack.org \
--cc=dhillf@gmail.com \
--cc=koverstreet@google.com \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zab@zabbo.net \
/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 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.