All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Alex Bligh <alex@alex.org.uk>
Cc: Konrad Wilk <konrad.wilk@oracle.com>,
	Xen Devel <xen-devel@lists.xen.org>,
	Jan Beulich <JBeulich@suse.com>,
	Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: Re: Fatal crash on xen4.2 HVM + qemu-xen dm + NFS
Date: Mon, 21 Jan 2013 16:51:13 +0000	[thread overview]
Message-ID: <1358787073.3279.257.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <F7775BEAD1475FBBDEB2B9C4@Ximines.local>

On Mon, 2013-01-21 at 16:33 +0000, Alex Bligh wrote:

> > The fact that you can reproduce so easily makes me wonder if this is
> > really the same issue. To trigger the issue you need this sequence of
> > events:
> >       * Send an RPC
> >       * RPC is encapsulated into a TCP/IP frame (or several) and sent.
> >       * Wait for an ACK response to the TCP/IP frame
> >       * Timeout.
> >       * Queue a retransmit of the TCP/IP frame(s)
> >       * Receive the ACK to the original.
> >       * Receive the reply to the RPC as well
> >       * Report success up the stack
> >       * Userspace gets success and unmaps the page
> >       * Retransmit hits the front of the queue
> >       * BOOM
> >
> > To do this you need to be pretty unlucky or retransmitting a lot (which
> > would usually imply something up with either the network or the filer).
> 
> Well, the two things we are doing different that potentially make this
> easier to replicate are:
> 
> * We are using a QCOW2 backing file, and running a VM image which
>   expands the partition, and then the filing system. This is a particularly
>   write heavy load. We're also using upstream qemu DM which I think
>   wasn't there when you lasted tested.

I've never tired to repro this with any version of qemu, we used to see
it with vhd+blktap2 and I had a PoC which showed the issue under native
too.

> * The filer we run this on is a dev filer which is performs poorly,
>   and has lots of LUNs (though I think we replicated it on another
>   filer too). Though the filer and network certainly aren't great,
>   they can run VMs just fine.

This could well be a factor I guess.

> >>  I think that would also
> >> apply to iSCSI over tcp, which would presumably suffer similarly.
> >
> > Correct, iSCSI over TCP can also have this issue.
> >
> >> Is that analysis correct?
> >
> > The important thing is zero copy vs. non-zero copy or not. IOW it is
> > only a problem if the actual userspace page, which is a mapped domU
> > page, is what gets queued up. Whether zero copy is done or not depends
> > on things like O_DIRECT and write(2) vs. sendpage(2) etc and what the
> > underlying fs implements etc. I thought NFS only did it for O_DIRECT. I
> > may be mistaken. aio is probably a factor too.
> 
> Right, and I'm pretty sure we're not using O_DIRECT as we're using
> cache=writeback (which is the default). Is there some way to make it
> copy pages?

Not as far as I know, but Trond zero-copy == O_DIRECT so if you aren't
using O_DIRECT then you aren't using zero copy -- and that agrees with
my recollection. In that case your issue is something totally unrelated.

You could try stracing the qemu-dm and see what it does.

> I'm wondering whether what's happening is that when the disk grows
> (or there's a backing file in place) some sort of different I/O is
> done by qemu. Perhaps irrespective of write cache setting, it does some
> form of zero copy I/O when there's a backing file in place.

I doubt that, but I don't really know anything about qdisk.

I'd be much more inclined to suspect a bug in the xen_qdisk backend's
handling of disks resizes, if that's what you are doing.

> > FWIW blktap2 always copies for pretty much this reason, I seem to recall
> > the maintainer saying the perf hit wasn't noticeable.
> 
> I'm afraid I find the various blk* combinations a bit of an impenetrable
> maze. Is it possible (if only for testing purposes) to use blktap2
> with HVM domU and qcow2 disks with backing files? I had thought the
> alternatives were qdisk and tap?

tap == blktap2. I don't know if it supports qcow or not but I don't
think xl exposes it if it does.

You could try with a test .vhd or .raw file though.

> And a late comment on  your previous email:
> 
> >> Surely before Xen removes the grant on the page, unmapping it from dom0's
> >> memory, it should check to see if there are any existing references
> >> to the page and if there are, given the kernel its own COW copy, rather
> >> than unmap it totally which is going to lead to problems.
> >
> > Unfortunately each page only has one reference count, so you cannot
> > distinguish between references from this particular NFS write from other
> > references (other writes, the ref held by the process itself, etc).
> 
> Sure, I understand that. But I wasn't suggesting the tcp layer triggered
> this (in which case it would need to get back to the NFS write). I
> think Trond said you were arranging for sendpage() to provide a callback.
> I'm not suggesting that.
> 
> What I was (possibly naively) suggesting, is that the single reference
> count to the page should be zero by the time the xen grant stuff is
> about to remove the mapping,

Unfortunately it won't be zero. There will be at least one reference
from the page being part of the process, which won't be dropped until
the process dies.

BTW I'm talking about the dom0 kernels page reference count. Xen's page
reference count is irrelevant here.

>  else it's in use somewhere in the domain
> into which it's mapped. The xen grant stuff can't know whether that's
> for NFS, or iSCSI or whatever. But it does know some other bit of the
> kernel is going to use that page, and when it's finished with it will
> decrement the reference count and presumably free the page up. So if
> it finds a page like this, surely the right thing to do is to leave
> a copy of it in dom0, which is no longer associated with the domU
> page; it will then get freed when the tcp stack (or whatever is using
> it) decrements the reference count later. I don't know if that makes
> any sense.

The whole point is that there is no such reference count which drops to
zero under these circumstances, that's why my series "skb paged fragment
destructors" adds one.

I suggest you google up previous discussions on the netdev list about
this issue -- all these sorts of ideas were discussed back then.

Ian.

  reply	other threads:[~2013-01-21 16:51 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 14:54 Fatal crash on xen4.2 HVM + qemu-xen dm + NFS Alex Bligh
2012-12-17 10:10 ` Jan Beulich
2012-12-17 17:09   ` Alex Bligh
2013-01-16 10:56   ` Alex Bligh
2013-01-16 14:34     ` Stefano Stabellini
2013-01-16 15:06       ` Alex Bligh
2013-01-16 16:00         ` Alex Bligh
2013-01-16 16:27         ` Stefano Stabellini
2013-01-16 17:13           ` Alex Bligh
2013-01-16 17:33             ` Stefano Stabellini
2013-01-16 17:39               ` Stefano Stabellini
2013-01-16 18:14                 ` Alex Bligh
2013-01-16 18:49                   ` Stefano Stabellini
2013-01-16 19:00                     ` Stefano Stabellini
2013-01-17  7:58                       ` Alex Bligh
2013-01-16 18:12               ` Alex Bligh
2013-01-21 15:15               ` Alex Bligh
2013-01-21 15:23                 ` Ian Campbell
2013-01-21 15:35                   ` Alex Bligh
2013-01-21 15:50                     ` Ian Campbell
2013-01-21 16:33                       ` Alex Bligh
2013-01-21 16:51                         ` Ian Campbell [this message]
2013-01-21 17:06                           ` Alex Bligh
2013-01-21 17:29                             ` Ian Campbell
2013-01-21 17:31                           ` Alex Bligh
2013-01-21 17:32                             ` Ian Campbell
2013-01-21 18:14                               ` Alex Bligh
2013-01-22 10:05                                 ` Ian Campbell
2013-01-22 13:02                                   ` Alex Bligh
2013-01-22 13:13                                     ` Ian Campbell
2013-01-21 20:37                           ` Alex Bligh
2013-01-22 10:07                             ` Ian Campbell
2013-01-22 13:01                               ` Alex Bligh
2013-01-22 13:14                                 ` Ian Campbell
2013-01-22 13:18                                   ` Alex Bligh
2013-01-22 10:13                             ` Ian Campbell
2013-01-22 12:59                               ` Alex Bligh
2013-01-22 15:46                                 ` Stefano Stabellini
2013-01-22 15:42                             ` Stefano Stabellini
2013-01-22 16:09                               ` Stefano Stabellini
2013-01-22 20:31                                 ` Alex Bligh
2013-01-23 11:52                                   ` Stefano Stabellini
2013-01-23 15:19                                     ` Alex Bligh
2013-01-23 16:29                                       ` Stefano Stabellini
2013-01-25 11:28                                         ` Alex Bligh
2013-02-05 15:40                                           ` Alex Bligh
2013-02-22 17:28                                             ` Alex Bligh
2013-02-22 17:41                                               ` Konrad Rzeszutek Wilk
2013-02-22 18:00                                                 ` Stefano Stabellini
2013-02-22 19:53                                                 ` Alex Bligh
2013-03-06 11:50                                                   ` Alex Bligh
2013-03-07  1:01                                                     ` Konrad Rzeszutek Wilk
2013-03-07  4:15                                                       ` Stefano Stabellini
2013-03-07 10:47                                                         ` [PATCH] QEMU(upstream): Disable xen's use of O_DIRECT by default as it results in crashes Alex Bligh
2013-03-08  3:18                                                           ` Stefano Stabellini
2013-03-08  9:25                                                             ` [PATCHv2] " Alex Bligh
2013-03-08  9:26                                                             ` [PATCH] " Alex Bligh
2013-03-08 10:17                                                             ` George Dunlap
2013-03-08 10:27                                                               ` Alex Bligh
2013-03-08 10:35                                                                 ` George Dunlap
2013-03-08 10:50                                                                   ` Alex Bligh
2013-03-08 11:18                                                                     ` George Dunlap
2013-03-08 11:40                                                                       ` [PATCHv3] " Alex Bligh
2013-03-08 12:54                                                                         ` George Dunlap
2013-03-11 14:02                                                                           ` Alex Bligh
2013-03-11 14:42                                                                             ` George Dunlap
2013-03-11 17:48                                                                               ` Konrad Rzeszutek Wilk
2013-03-11 17:55                                                                                 ` Ian Jackson
2013-03-14 17:06                                                                                   ` Alex Bligh
2013-03-14 18:26                                                                                     ` Ian Jackson
2013-03-12 12:08                                                                               ` Ian Campbell
2013-03-14 18:37                                                                         ` Stefano Stabellini
2013-03-14 19:30                                                                           ` Ian Jackson
2013-03-14 19:56                                                                             ` Alex Bligh
2013-03-15  9:28                                                                             ` Ian Campbell
2013-03-15 10:43                                                                               ` Stefano Stabellini
2013-03-15 11:21                                                                                 ` Ian Jackson
2013-03-15 11:28                                                                                   ` Stefano Stabellini
2013-03-15 11:37                                                                                     ` Ian Jackson
2013-03-15 11:43                                                                                       ` Stefano Stabellini
2013-03-15 12:43                                                                                         ` Alex Bligh
2013-03-15 12:50                                                                                           ` Ian Campbell
2013-03-15 18:31                                                                                         ` Ian Jackson
2013-03-18 10:29                                                                                         ` Alex Bligh
2013-03-18 11:47                                                                                           ` Stefano Stabellini
2013-03-18 12:21                                                                                             ` Alex Bligh
2013-03-08 11:41                                                                       ` [PATCH] " Alex Bligh
2013-03-08 10:28                                                               ` George Dunlap
2013-03-08 10:45                                                                 ` Alex Bligh
2013-03-07 10:51                                                         ` Fatal crash on xen4.2 HVM + qemu-xen dm + NFS Alex Bligh
2013-03-07  8:16                                                       ` Alex Bligh

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=1358787073.3279.257.camel@zakaz.uk.xensource.com \
    --to=ian.campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=alex@alex.org.uk \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xen.org \
    /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.