From: Benjamin LaHaise <bcrl@kvack.org>
To: Kent Overstreet <kmo@daterainc.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Dave Jones <davej@redhat.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>, Christoph Lameter <cl@gentwo.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: bad page state in 3.13-rc4
Date: Thu, 19 Dec 2013 13:29:21 -0500 [thread overview]
Message-ID: <20131219182920.GG30640@kvack.org> (raw)
In-Reply-To: <20131219181134.GC25385@kmo-pixel>
On Thu, Dec 19, 2013 at 10:11:34AM -0800, Kent Overstreet wrote:
> On Thu, Dec 19, 2013 at 09:07:27AM -0800, Linus Torvalds wrote:
> > On Thu, Dec 19, 2013 at 7:53 AM, Dave Jones <davej@redhat.com> wrote:
> > >
> > > Interesting that CPU2 was doing sys_io_setup again. Different trace though.
> >
> > Well, it was once again in aio_free_ring() - double free or freeing
> > while already in use? And this time the other end of the complaint was
> > allocating a new page that definitely was still busily in use (it's
> > locked).
> >
> > And there's no sign of migration, although obviously that could have
> > happened or be in progress on another CPU and just didn't notice the
> > mess. But yes, based on the two traces, fs/aio.c:io_setup() would seem
> > to be the main point of interest.
> >
> > Have you started doing something new in trinity wrt AIO, and
> > io_setup() in particular? Or anything else different that might have
> > started triggering this?
> >
> > But we do have new AIO code, and these two in particular look suspicious:
> >
> > - new page migration logic:
> >
> > 71ad7490c1f3 rework aio migrate pages to use aio fs
> >
> > - trying to fix double frees and error cases:
> >
> > e34ecee2ae79 aio: Fix a trinity splat
> > d558023207e0 aio: prevent double free in ioctx_alloc
> > d1b9432712a2 aio: clean up aio ring in the fail path
> >
> > and some kind of double free in an error path would certainly explain
> > this (with io_setup() . And the first oops reported obviously had that
> > migration thing. So maybe those "fixes" weren't fixing things at all
> > (or just moved the error case around).
> >
> > Btw, that "rework aio migrate pages to use aio fs" looks odd. It has
> > Ben LaHaise marked as author, but no sign-off, instead "Tested-by" and
> > "Acked-by".
>
> I could certainly believe a double free, but rereading the current code
> I can't find anything, and I just manually tested all the relevant error
> paths in ioctx_alloc() and aio_setup_ring() without finding anything.
The same here. It would be very helpful to know what syscalls trinity is
issuing in the lead up to the bug.
> I don't get wtf that loop at line 350 is supposed to be for though.
> You'd think if it was doing anything important it would be doing
> something more intelligent than just breaking on error (?). But I
> haven't slept yet and maybe I'm just being dumb.
The loop at 350 is just instantiating the page cache pages for the ring
buffer with freshly zeroed pages.
> I don't understand this page migration stuff at all, and I actually
> don't think I understand the refcounting w.r.t. the page cache either.
> But looking at (say) the aio_free_ring() call at line 409 - we just did
> one put_page() in aio_setup_ring(), and then _another_ put_page() in
> aio_free_ring()... ok, one of those corresponds to the get
> get_user_pages() did, but what's the other correspond to?
The second put_page() should be dropping the page from the page cache.
Perhaps it would be better to rely on a truncate of the file to remove the
pages from the page cache. I'd hoped someone with a clue about how
migration is supposed to work would have chimed in during the review, but
nobody has stepped up with expertise in this area yet.
-ben
--
"Thought is the essence of where you are now."
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Benjamin LaHaise <bcrl@kvack.org>
To: Kent Overstreet <kmo@daterainc.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Dave Jones <davej@redhat.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>, Christoph Lameter <cl@gentwo.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: bad page state in 3.13-rc4
Date: Thu, 19 Dec 2013 13:29:21 -0500 [thread overview]
Message-ID: <20131219182920.GG30640@kvack.org> (raw)
In-Reply-To: <20131219181134.GC25385@kmo-pixel>
On Thu, Dec 19, 2013 at 10:11:34AM -0800, Kent Overstreet wrote:
> On Thu, Dec 19, 2013 at 09:07:27AM -0800, Linus Torvalds wrote:
> > On Thu, Dec 19, 2013 at 7:53 AM, Dave Jones <davej@redhat.com> wrote:
> > >
> > > Interesting that CPU2 was doing sys_io_setup again. Different trace though.
> >
> > Well, it was once again in aio_free_ring() - double free or freeing
> > while already in use? And this time the other end of the complaint was
> > allocating a new page that definitely was still busily in use (it's
> > locked).
> >
> > And there's no sign of migration, although obviously that could have
> > happened or be in progress on another CPU and just didn't notice the
> > mess. But yes, based on the two traces, fs/aio.c:io_setup() would seem
> > to be the main point of interest.
> >
> > Have you started doing something new in trinity wrt AIO, and
> > io_setup() in particular? Or anything else different that might have
> > started triggering this?
> >
> > But we do have new AIO code, and these two in particular look suspicious:
> >
> > - new page migration logic:
> >
> > 71ad7490c1f3 rework aio migrate pages to use aio fs
> >
> > - trying to fix double frees and error cases:
> >
> > e34ecee2ae79 aio: Fix a trinity splat
> > d558023207e0 aio: prevent double free in ioctx_alloc
> > d1b9432712a2 aio: clean up aio ring in the fail path
> >
> > and some kind of double free in an error path would certainly explain
> > this (with io_setup() . And the first oops reported obviously had that
> > migration thing. So maybe those "fixes" weren't fixing things at all
> > (or just moved the error case around).
> >
> > Btw, that "rework aio migrate pages to use aio fs" looks odd. It has
> > Ben LaHaise marked as author, but no sign-off, instead "Tested-by" and
> > "Acked-by".
>
> I could certainly believe a double free, but rereading the current code
> I can't find anything, and I just manually tested all the relevant error
> paths in ioctx_alloc() and aio_setup_ring() without finding anything.
The same here. It would be very helpful to know what syscalls trinity is
issuing in the lead up to the bug.
> I don't get wtf that loop at line 350 is supposed to be for though.
> You'd think if it was doing anything important it would be doing
> something more intelligent than just breaking on error (?). But I
> haven't slept yet and maybe I'm just being dumb.
The loop at 350 is just instantiating the page cache pages for the ring
buffer with freshly zeroed pages.
> I don't understand this page migration stuff at all, and I actually
> don't think I understand the refcounting w.r.t. the page cache either.
> But looking at (say) the aio_free_ring() call at line 409 - we just did
> one put_page() in aio_setup_ring(), and then _another_ put_page() in
> aio_free_ring()... ok, one of those corresponds to the get
> get_user_pages() did, but what's the other correspond to?
The second put_page() should be dropping the page from the page cache.
Perhaps it would be better to rely on a truncate of the file to remove the
pages from the page cache. I'd hoped someone with a clue about how
migration is supposed to work would have chimed in during the review, but
nobody has stepped up with expertise in this area yet.
-ben
--
"Thought is the essence of where you are now."
next prev parent reply other threads:[~2013-12-19 18:29 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 4:07 bad page state in 3.13-rc4 Dave Jones
2013-12-19 4:07 ` Dave Jones
2013-12-19 4:40 ` Linus Torvalds
2013-12-19 4:40 ` Linus Torvalds
2013-12-19 15:41 ` Christoph Lameter
2013-12-19 15:41 ` Christoph Lameter
2013-12-19 20:11 ` Mel Gorman
2013-12-19 20:11 ` Mel Gorman
2013-12-19 20:30 ` Dave Jones
2013-12-19 20:30 ` Dave Jones
2013-12-19 15:53 ` Dave Jones
2013-12-19 15:53 ` Dave Jones
2013-12-19 17:07 ` Linus Torvalds
2013-12-19 17:07 ` Linus Torvalds
2013-12-19 17:17 ` Dave Jones
2013-12-19 17:17 ` Dave Jones
2013-12-19 18:11 ` Kent Overstreet
2013-12-19 18:11 ` Kent Overstreet
2013-12-19 18:29 ` Benjamin LaHaise [this message]
2013-12-19 18:29 ` Benjamin LaHaise
2013-12-19 18:35 ` Dave Jones
2013-12-19 18:35 ` Dave Jones
2013-12-19 19:19 ` Linus Torvalds
2013-12-19 19:19 ` Linus Torvalds
2013-12-19 19:26 ` Benjamin LaHaise
2013-12-19 19:26 ` Benjamin LaHaise
2013-12-19 19:45 ` Linus Torvalds
2013-12-19 19:45 ` Linus Torvalds
2013-12-19 19:53 ` Benjamin LaHaise
2013-12-19 19:53 ` Benjamin LaHaise
2013-12-19 20:02 ` Linus Torvalds
2013-12-19 20:11 ` Linus Torvalds
2013-12-19 20:31 ` Benjamin LaHaise
2013-12-19 20:31 ` Benjamin LaHaise
2013-12-19 20:31 ` Linus Torvalds
2013-12-19 20:31 ` Linus Torvalds
2013-12-19 20:42 ` Benjamin LaHaise
2013-12-19 20:42 ` Benjamin LaHaise
2013-12-19 20:24 ` Dave Jones
2013-12-19 20:24 ` Dave Jones
2013-12-19 23:38 ` Benjamin LaHaise
2013-12-19 23:38 ` Benjamin LaHaise
2013-12-20 1:00 ` Dave Jones
2013-12-20 1:00 ` Dave Jones
2013-12-21 23:06 ` [PATCHes - aio / migrate page, please review] " Benjamin LaHaise
2013-12-21 23:06 ` Benjamin LaHaise
2013-12-22 19:09 ` Linus Torvalds
2013-12-22 19:09 ` Linus Torvalds
2013-12-22 21:30 ` Dave Jones
2013-12-22 21:30 ` Dave Jones
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=20131219182920.GG30640@kvack.org \
--to=bcrl@kvack.org \
--cc=cl@gentwo.org \
--cc=davej@redhat.com \
--cc=kmo@daterainc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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.