Re: [kvm] Re: [RFC PATCH 00/17] virtual-bus
On Thu, 2009-04-02 at 13:18 -0500, Anthony Liguori wrote: > Avi Kivity wrote: > > Anthony Liguori wrote: > >>> I don't think we even need that to end this debate. I'm convinced > >>> we have a bug somewhere. Even disabling TX mitigation, I see a ping > >>> latency of around 300ns whereas it's only 50ns on the host. This > >>> defies logic so I'm now looking to isolate why that is. > >> > >> I'm down to 90us. Obviously, s/ns/us/g above. The exec.c changes > >> were the big winner... I hate qemu sometimes. > > Anyway, if we're able to send this many packets, I suspect we'll be able > to also handle much higher throughputs without TX mitigation so that's > what I'm going to look at now. Anthony, Any news on this? I'm anxious to see virtio-net performance on par with the virtual-bus results. Thanks, Alex -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: Anthony Liguori wrote: What we need is: 1) Lockless MMIO/PIO dispatch (there should be two IO registration interfaces, a new lockless one and the legacy one) Not sure exactly how much this is needed, since when there is no contention, locks are almost free (there's the atomic and cacheline bounce, but no syscall). There should be no contention but I strongly suspect there is more often than we think. The IO thread can potentially hold the lock for a very long period of time. Take into consideration things like qcow2 metadata read/write, VNC server updates, etc.. For any long operations, we should drop the lock (of course we need some kind of read/write lock or rcu to avoid hotunplug or reconfiguration). 2) A virtio-net thread that's independent of the IO thread. Yes -- that saves us all the select() prologue (calculating new timeout) and the select() itself. In an ideal world, we could do the submission via io_submit in the VCPU context, not worry about the copy latency (because we're zero copy). Then our packet transmission latency is consistently low because the path is consistent and lockless. This is why dropping the lock is so important, it's not enough to usually have low latency. We need to try and have latency as low as possible as often as possible. Regards, Anthony Liguori -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: What we need is: 1) Lockless MMIO/PIO dispatch (there should be two IO registration interfaces, a new lockless one and the legacy one) Not sure exactly how much this is needed, since when there is no contention, locks are almost free (there's the atomic and cacheline bounce, but no syscall). For any long operations, we should drop the lock (of course we need some kind of read/write lock or rcu to avoid hotunplug or reconfiguration). 2) A virtio-net thread that's independent of the IO thread. Yes -- that saves us all the select() prologue (calculating new timeout) and the select() itself. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Rusty Russell wrote: On Thursday 02 April 2009 02:40:29 Anthony Liguori wrote: Rusty Russell wrote: As you point out, 350-450 is possible, which is still bad, and it's at least partially caused by the exit to userspace and two system calls. If virtio_net had a backend in the kernel, we'd be able to compare numbers properly. I doubt the userspace exit is the problem. On a modern system, it takes about 1us to do a light-weight exit and about 2us to do a heavy-weight exit. A transition to userspace is only about ~150ns, the bulk of the additional heavy-weight exit cost is from vcpu_put() within KVM. Just to inject some facts, servicing a ping via tap (ie host->guest then guest->host response) takes 26 system calls from one qemu thread, 7 from another (see strace below). Judging by those futex calls, multiple context switches, too. N.B. we're not optimized for latency today. With the right infrastructure in userspace, I'm confident we could get this down. What we need is: 1) Lockless MMIO/PIO dispatch (there should be two IO registration interfaces, a new lockless one and the legacy one) 2) A virtio-net thread that's independent of the IO thread. It would be interesting to count the number of syscalls required in the lguest path since that should be a lot closer to optimal. Regards, Anthony Liguori -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: You don't gain simplicity by adding things. But you are failing to account for the fact that we still have to add something for PCI if we go with something like the in-kernel model. Its nice for the userspace side because a) it was already in qemu, and b) we need it for proper guest support. But we don't presumably have it for this new thing, so something has to be created (unless this support is somehow already there and I don't know it?) No, a virtio server in the kernel would know nothing about PCI. Userspace would handle the PCI interface and configure the kernel. That way we can reuse the kernel part for lguest and s390. Optimization: Most of PCI (in our context) deals with configuration. So removing it doesn't optimize anything, unless you're counting hotplugs-per-second or something. Most, but not all ;) (Sorry, you left the window open on that one). What about IRQ routing? That's already in the kernel. What if I want to coalesce interrupts to minimize injection overhead? How do I do that in PCI? It has nothing to do with PCI. It has to do with the device/guest protocol. And virtio already does that (badly, in the case of network tx). How do I route those interrupts in an arbitrarily nested fashion, say, to a guest userspace? That's a guest problem. kvm delivers an interrupt; if the guest knows how to service it in userspace, great. What about scale? What if Herbet decides to implement a 2048 ring MQ device ;) Theres no great way to do that in x86 with PCI, yet I can do it in vbus. (And yes, I know, this is ridiculous..just wanting to get you thinking) I don't see why you can't do 2048 (or even 2049) rings with PCI. You'd point some config space address at a 'ring descriptor table' and that's it. There is be no problem supporting an in-kernel host virtio endpoint with the existing guest/host ABI. Nothing in the ABI assumes the host endpoint is in userspace. Nothing in the implementation requires us to move any of the PCI stuff into the kernel. Well, thats not really true. If the device is a PCI device, there is *some* stuff that has to go into the kernel. Not an ICH model or anything, but at least an ability to interact with userspace for config-space changes, etc. Config space changes go to userspace anyway. You'd need an interface to let userspace configure the kernel, but that's true for every device in the kernel. And you don't want to let the guest configure the kernel directly, you want userspace to be able to keep control of things. To avoid reiterating, please be specific about these advantages. We are both reading the same thread, right? Using different languages? Last time we measured, hypercall overhead was the same as pio overhead. Both vmx and svm decode pio completely (except for string pio ...) Not on my woodcrests last time I looked, but I'll check again. On woodcrests too. See vmx.c:handle_io(). True, PCI interrupts suck. But this was fixed with MSI. Why fix it again? As I stated, I don't like the constraints in place even by MSI (though that is definately a step in the right direction). Which constraints? With vbus I can have a device that has an arbitrary number of shm regions (limited by memory, of course), So you can with PCI. each with an arbitrarily routed signal path that is limited by a u64, even on x86. There are still only 224 vectors per vcpu. Each region can be signaled bidirectionally and masked with a simple local memory write. They can be declared on the fly, allowing for the easy expression of things like nested devices or or other dynamic resources. The can be routed across various topologies, such as IRQs or posix signals, even across multiple hops in a single path. How do I do that in PCI? Not what this nesting means. If I understand the rest, I think you can do it. What does masking an interrupt look like? It's a protocol between the device and the guest. PCI doesn't specify it. So you can use a bit in shared memory if you like. Again, for the nested case? What's that? Interrupt acknowledgment cycles? Standard for the platform. Again it's outside the scope of PCI. One of my primary design objectives with vbus was to a) reduce the signaling as much as possible, and b) reduce the cost of signaling. That is why I do things like use explicit hypercalls, aggregated interrupts, bidir napi to mitigate signaling, the shm_signal::pending mitigation, and avoiding going to userspace by running in the kernel. All of these things together help to form what I envision would be a maximum performance transport. Not all of these tricks are interdependent (for instance, the bidir + full-duplex threading that I do can be done in userspace too, as discussed). They are just the collective design elements that I think we need to make a guest perform very close to
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: 2) the vbus-proxy and kvm-guest patch go away 3) the kvm-host patch changes to work with coordination from the userspace-pci emulation for things like MSI routing 4) qemu will know to create some MSI shim 1:1 with whatever it instantiates on the bus (and can communicate changes Don't userstand. What's this MSI shim? Well, if the device model was an object in vbus down in the kernel, yet PCI emulation was up in qemu, presumably we would want something to handle things like PCI config-cycles up in userspace. Like, for instance, if the guest re-routes the MSI. The shim/proxy would handle the config-cycle, and then turn around and do an ioctl to the kernel to configure the change with the in-kernel device model (or the irq infrastructure, as required). Right, this is how it should work. All the gunk in userspace. But, TBH, I haven't really looked into whats actually required to make this work yet. I am just spitballing to try to find a compromise. One thing I thought of trying to get this generic is to use file descriptors as irq handles. So: - userspace exposes a PCI device (same as today) - guest configures its PCI IRQ (using MSI if it supports it) - userspace handles this by calling KVM_IRQ_FD which converts the irq to a file descriptor - userspace passes this fd to the kernel, or another userspace process - end user triggers guest irqs by writing to this fd We could do the same with hypercalls: - guest and host userspace negotiate hypercall use through PCI config space - userspace passes an fd to the kernel - whenever the guest issues an hypercall, the kernel writes the arguments to the fd - other end (in kernel or userspace) processes the hypercall No, you are confusing the front-end and back-end again ;) The back-end remains, and holds the device models as before. This is the "vbus core". Today the front-end interacts with the hypervisor to render "vbus" specific devices. The proposal is to eliminate the front-end, and have the back end render the objects on the bus as PCI devices to the guest. I am not sure if I can make it work, yet. It needs more thought. It seems to me this already exists, it's the qemu device model. The host kernel doesn't need any knowledge of how the devices are connected, even if it does implement some of them. . I don't think you've yet set down what its advantages are. Being pure and clean doesn't count, unless you rip out PCI from all existing installed hardware and from Windows. You are being overly dramatic. No one has ever said we are talking about ripping something out. In fact, I've explicitly stated that PCI can coexist peacefully.Having more than one bus in a system is certainly not without precedent (PCI, scsi, usb, etc). Rather, PCI is PCI, and will always be. PCI was designed as a software-to-hardware interface. It works well for its intention. When we do full emulation of guests, we still do PCI so that all that software that was designed to work software-to-hardware still continue to work, even though technically its now software-to-software. When we do PV, on the other hand, we no longer need to pretend it is software-to-hardware. We can continue to use an interface designed for software-to-hardware if we choose, or we can use something else such as an interface designed specifically for software-to-software. As I have stated, PCI was designed with hardware constraints in mind. What if I don't want to be governed by those constraints? I'd agree with all this if I actually saw a constraint in PCI. But I don't. What if I don't want an interrupt per device (I don't)? Don't. Though I thing you do, even multiple interrupts per device. What do I need BARs for (I don't)? Don't use them. Is a PCI PIO address relevant to me (no, hypercalls are more direct)? Etc. Its crap I dont need. So use hypercalls. All I really need is a way to a) discover and enumerate devices, preferably dynamically (hotswap), and b) a way to communicate with those devices. I think you are overstating the the importance that PCI plays in (a), and are overstating the complexity associated with doing an alternative. Given that we have PCI, why would we do an alternative? It works, it works with Windows, the nasty stuff is in userspace. Why expend effort on an alternative? Instead make it go faster. I think you are understating the level of hackiness required to continue to support PCI as we move to new paradigms, like in-kernel models. The kernel need know nothing about PCI, so I don't see how you work this out. And I think I have already stated that I can establish a higher degree of flexibility, and arguably, performance for (b). You've stated it, but failed to provide arguments for it. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a m
Re: [RFC PATCH 00/17] virtual-bus
Rusty Russell wrote: On Thursday 02 April 2009 02:40:29 Anthony Liguori wrote: Rusty Russell wrote: As you point out, 350-450 is possible, which is still bad, and it's at least partially caused by the exit to userspace and two system calls. If virtio_net had a backend in the kernel, we'd be able to compare numbers properly. I doubt the userspace exit is the problem. On a modern system, it takes about 1us to do a light-weight exit and about 2us to do a heavy-weight exit. A transition to userspace is only about ~150ns, the bulk of the additional heavy-weight exit cost is from vcpu_put() within KVM. Just to inject some facts, servicing a ping via tap (ie host->guest then guest->host response) takes 26 system calls from one qemu thread, 7 from another (see strace below). Judging by those futex calls, multiple context switches, too. Interesting stuff. Even if amortized over half a ring's worth of packets, that's quite a lot. Two threads are involved (we complete on the iothread, since we don't know which vcpu will end up processing the interrupt, if any). Pid 10260: 12:37:40.245785 select(17, [4 6 8 14 16], [], [], {0, 996000}) = 1 (in [6], left {0, 992000}) <0.003995> Should switch to epoll with its lower wait costs. Unfortunately the relative timeout requires reading the clock. 12:37:40.250226 read(6, "\0\0\0\0\0\0\0\0\0\0RT\0\0224V*\211\24\210`\304\10\0E\0"..., 69632) = 108 <0.51> 12:37:40.250462 write(1, "tap read: 108 bytes\n", 20) = 20 <0.000197> I hope this is your addition. 12:37:40.250800 ioctl(7, 0x4008ae61, 0x7fff8cafb3a0) = 0 <0.000223> 12:37:40.251149 read(6, 0x115c6ac, 69632) = -1 EAGAIN (Resource temporarily unavailable) <0.19> This wouldn't be necessary with io_getevents(). 12:37:40.251292 write(1, "tap read: -1 bytes\n", 19) = 19 <0.85> ... 12:37:40.251488 clock_gettime(CLOCK_MONOTONIC, {1554, 633304282}) = 0 <0.20> 12:37:40.251604 clock_gettime(CLOCK_MONOTONIC, {1554, 633413793}) = 0 <0.19> Great. 12:37:40.251717 futex(0xb81360, 0x81 /* FUTEX_??? */, 1) = 1 <0.001222> 12:37:40.253037 select(17, [4 6 8 14 16], [], [], {1, 0}) = 1 (in [16], left {1, 0}) <0.26> 12:37:40.253196 read(16, "\16\0\0\0\0\0\0\0\376\377\377\377\0\0\0\0\0\0\0\0\0\0\0"..., 128) = 128 <0.22> 12:37:40.253324 rt_sigaction(SIGALRM, NULL, {0x406d50, ~[KILL STOP RTMIN RT_1], SA_RESTORER, 0x7f1a842430f0}, 8) = 0 <0.18> 12:37:40.253477 write(5, "\0", 1) = 1 <0.22> The write is to wake someone up. Who? 12:37:40.253585 read(16, 0x7fff8cb09440, 128) = -1 EAGAIN (Resource temporarily unavailable) <0.20> Clearing up signalfd... 12:37:40.253687 clock_gettime(CLOCK_MONOTONIC, {1554, 635496181}) = 0 <0.19> 12:37:40.253798 writev(6, [{"\0\0\0\0\0\0\0\0\0\0", 10}, {"*\211\24\210`\304rt\0\0224v\10\0e\0\0t\255\262\...@\1g"..., 98}], 2) = 108 <0.62> 12:37:40.253993 ioctl(7, 0x4008ae61, 0x7fff8caff460) = 0 <0.000161> Injecting the interrupt. 12:37:40.254263 clock_gettime(CLOCK_MONOTONIC, {1554, 636077540}) = 0 <0.19> 12:37:40.254380 futex(0xb81360, 0x81 /* FUTEX_??? */, 1) = 1 <0.000394> 12:37:40.254861 select(17, [4 6 8 14 16], [], [], {1, 0}) = 1 (in [4], left {1, 0}) <0.22> 12:37:40.255001 read(4, "\0", 512) = 1 <0.21> Great, the write() was to wake ourselves up. 12:37:40.255109 read(4, 0x7fff8cb092d0, 512) = -1 EAGAIN (Resource temporarily unavailable) <0.18> 12:37:40.255211 clock_gettime(CLOCK_MONOTONIC, {1554, 637020677}) = 0 <0.19> 12:37:40.255314 clock_gettime(CLOCK_MONOTONIC, {1554, 637123483}) = 0 <0.19> 12:37:40.255416 timer_gettime(0, {it_interval={0, 0}, it_value={0, 0}}) = 0 <0.18> 12:37:40.255524 timer_settime(0, 0, {it_interval={0, 0}, it_value={0, 1400}}, NULL) = 0 <0.21> 12:37:40.255635 clock_gettime(CLOCK_MONOTONIC, {1554, 637443915}) = 0 <0.19> 12:37:40.255739 clock_gettime(CLOCK_MONOTONIC, {1554, 637547001}) = 0 <0.18> 12:37:40.255847 select(17, [4 6 8 14 16], [], [], {1, 0}) = 1 (in [16], left {0, 988000}) <0.014303> This is the vcpu thread: Pid 10262: 12:37:40.252531 clock_gettime(CLOCK_MONOTONIC, {1554, 634339051}) = 0 <0.18> 12:37:40.252631 timer_gettime(0, {it_interval={0, 0}, it_value={0, 17549811}}) = 0 <0.21> 12:37:40.252750 timer_settime(0, 0, {it_interval={0, 0}, it_value={0, 25}}, NULL) = 0 <0.24> 12:37:40.252868 ioctl(11, 0xae80, 0)= 0 <0.001171> 12:37:40.254128 futex(0xb81360, 0x80 /* FUTEX_??? */, 2) = 0 <0.000270> 12:37:40.254490 ioctl(7, 0x4008ae61, 0x4134bee0) = 0 <0.19> 12:37:40.254598 futex(0xb81360, 0x81 /* FUTEX_??? */, 1) = 0 <0.17> 12:37:40.254693 ioctl(11, 0xae80 Looks like the interrupt from the iothread was injected and delivered before the iothread could give up the mutex, so we needed to wait here. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from t
Re: [RFC PATCH 00/17] virtual-bus
On Thursday 02 April 2009 02:40:29 Anthony Liguori wrote: > Rusty Russell wrote: > > As you point out, 350-450 is possible, which is still bad, and it's at least > > partially caused by the exit to userspace and two system calls. If > > virtio_net > > had a backend in the kernel, we'd be able to compare numbers properly. > > I doubt the userspace exit is the problem. On a modern system, it takes > about 1us to do a light-weight exit and about 2us to do a heavy-weight > exit. A transition to userspace is only about ~150ns, the bulk of the > additional heavy-weight exit cost is from vcpu_put() within KVM. Just to inject some facts, servicing a ping via tap (ie host->guest then guest->host response) takes 26 system calls from one qemu thread, 7 from another (see strace below). Judging by those futex calls, multiple context switches, too. > If you were to switch to another kernel thread, and I'm pretty sure you > have to, you're going to still see about a 2us exit cost. He switches to another thread, too, but with the right infrastructure (ie. skb data destructors) we could skip this as well. (It'd be interesting to see how virtual-bus performed on a single cpu host). Cheers, Rusty. Pid 10260: 12:37:40.245785 select(17, [4 6 8 14 16], [], [], {0, 996000}) = 1 (in [6], left {0, 992000}) <0.003995> 12:37:40.250226 read(6, "\0\0\0\0\0\0\0\0\0\0RT\0\0224V*\211\24\210`\304\10\0E\0"..., 69632) = 108 <0.51> 12:37:40.250462 write(1, "tap read: 108 bytes\n", 20) = 20 <0.000197> 12:37:40.250800 ioctl(7, 0x4008ae61, 0x7fff8cafb3a0) = 0 <0.000223> 12:37:40.251149 read(6, 0x115c6ac, 69632) = -1 EAGAIN (Resource temporarily unavailable) <0.19> 12:37:40.251292 write(1, "tap read: -1 bytes\n", 19) = 19 <0.85> 12:37:40.251488 clock_gettime(CLOCK_MONOTONIC, {1554, 633304282}) = 0 <0.20> 12:37:40.251604 clock_gettime(CLOCK_MONOTONIC, {1554, 633413793}) = 0 <0.19> 12:37:40.251717 futex(0xb81360, 0x81 /* FUTEX_??? */, 1) = 1 <0.001222> 12:37:40.253037 select(17, [4 6 8 14 16], [], [], {1, 0}) = 1 (in [16], left {1, 0}) <0.26> 12:37:40.253196 read(16, "\16\0\0\0\0\0\0\0\376\377\377\377\0\0\0\0\0\0\0\0\0\0\0"..., 128) = 128 <0.22> 12:37:40.253324 rt_sigaction(SIGALRM, NULL, {0x406d50, ~[KILL STOP RTMIN RT_1], SA_RESTORER, 0x7f1a842430f0}, 8) = 0 <0.18> 12:37:40.253477 write(5, "\0", 1) = 1 <0.22> 12:37:40.253585 read(16, 0x7fff8cb09440, 128) = -1 EAGAIN (Resource temporarily unavailable) <0.20> 12:37:40.253687 clock_gettime(CLOCK_MONOTONIC, {1554, 635496181}) = 0 <0.19> 12:37:40.253798 writev(6, [{"\0\0\0\0\0\0\0\0\0\0", 10}, {"*\211\24\210`\304rt\0\0224v\10\0e\0\0t\255\262\...@\1g"..., 98}], 2) = 108 <0.62> 12:37:40.253993 ioctl(7, 0x4008ae61, 0x7fff8caff460) = 0 <0.000161> 12:37:40.254263 clock_gettime(CLOCK_MONOTONIC, {1554, 636077540}) = 0 <0.19> 12:37:40.254380 futex(0xb81360, 0x81 /* FUTEX_??? */, 1) = 1 <0.000394> 12:37:40.254861 select(17, [4 6 8 14 16], [], [], {1, 0}) = 1 (in [4], left {1, 0}) <0.22> 12:37:40.255001 read(4, "\0", 512) = 1 <0.21> 12:37:40.255109 read(4, 0x7fff8cb092d0, 512) = -1 EAGAIN (Resource temporarily unavailable) <0.18> 12:37:40.255211 clock_gettime(CLOCK_MONOTONIC, {1554, 637020677}) = 0 <0.19> 12:37:40.255314 clock_gettime(CLOCK_MONOTONIC, {1554, 637123483}) = 0 <0.19> 12:37:40.255416 timer_gettime(0, {it_interval={0, 0}, it_value={0, 0}}) = 0 <0.18> 12:37:40.255524 timer_settime(0, 0, {it_interval={0, 0}, it_value={0, 1400}}, NULL) = 0 <0.21> 12:37:40.255635 clock_gettime(CLOCK_MONOTONIC, {1554, 637443915}) = 0 <0.19> 12:37:40.255739 clock_gettime(CLOCK_MONOTONIC, {1554, 637547001}) = 0 <0.18> 12:37:40.255847 select(17, [4 6 8 14 16], [], [], {1, 0}) = 1 (in [16], left {0, 988000}) <0.014303> Pid 10262: 12:37:40.252531 clock_gettime(CLOCK_MONOTONIC, {1554, 634339051}) = 0 <0.18> 12:37:40.252631 timer_gettime(0, {it_interval={0, 0}, it_value={0, 17549811}}) = 0 <0.21> 12:37:40.252750 timer_settime(0, 0, {it_interval={0, 0}, it_value={0, 25}}, NULL) = 0 <0.24> 12:37:40.252868 ioctl(11, 0xae80, 0)= 0 <0.001171> 12:37:40.254128 futex(0xb81360, 0x80 /* FUTEX_??? */, 2) = 0 <0.000270> 12:37:40.254490 ioctl(7, 0x4008ae61, 0x4134bee0) = 0 <0.19> 12:37:40.254598 futex(0xb81360, 0x81 /* FUTEX_??? */, 1) = 0 <0.17> 12:37:40.254693 ioctl(11, 0xae80 fd: lrwx-- 1 root root 64 2009-04-05 12:31 0 -> /dev/pts/1 lrwx-- 1 root root 64 2009-04-05 12:31 1 -> /dev/pts/1 lrwx-- 1 root root 64 2009-04-05 12:35 10 -> /home/rusty/qemu-images/ubuntu-8.10 lrwx-- 1 root root 64 2009-04-05 12:35 11 -> anon_inode:kvm-vcpu lrwx-- 1 root root 64 2009-04-05 12:35 12 -> socket:[31414] lrwx-- 1 root root 64 2009-04-05 12:35 13 -> socket:[31416] lrwx-- 1 root root 64 2009-04-05 12:35 14 -> anon_inode:[eventfd]
Re: [RFC PATCH 00/17] virtual-bus
Chris Wright wrote: > * Gregory Haskins (ghask...@novell.com) wrote: > >> Let me ask you this: If you had a clean slate and were designing a >> hypervisor and a guest OS from scratch: What would you make the bus >> look like? >> > > Well, virtio did have a relatively clean slate. And PCI (as _one_ > transport option) is what it looks like. It's not the only transport > (as Avi already mentioned it works for s390, for example). > Got it. Thanks. > BTW, from my brief look at vbus, it seems pretty similar to xenbus. > If you are referring to the guest side interface, it was actually inspired by lguest's bus (I forget what Rusty called it now, though). I think I actually declared that in the original patch series I put out 1.5 years ago, but I might have inadvertently omitted that on this go-round. I think XenBus is more of an event channel infrastructure, isn't it? But in any case, I think the nature of getting PV drivers into a guest is relatively similar, so I wouldn't be surprised if there were parallels in quite a few of the implementations. In fact, I chose a generic name like "vbus" in hopes that it could be used across different hypervisors. :) -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >>> I'll rephrase. What are the substantial benefits that this offers >>> over PCI? >>> >> >> Simplicity and optimization. You don't need most of the junk that comes >> with PCI. Its all overhead and artificial constraints. You really only >> need things like a handful of hypercall verbs and thats it. >> >> > > Simplicity: > > The guest already supports PCI. It has to, since it was written to > the PC platform, and since today it is fashionable to run kernels that > support both bare metal and a hypervisor. So you can't remove PCI > from the guest. Agreed > > The host also already supports PCI. It has to, since it must supports > guests which do not support vbus. We can't remove PCI from the host. Agreed > > You don't gain simplicity by adding things. But you are failing to account for the fact that we still have to add something for PCI if we go with something like the in-kernel model. Its nice for the userspace side because a) it was already in qemu, and b) we need it for proper guest support. But we don't presumably have it for this new thing, so something has to be created (unless this support is somehow already there and I don't know it?) > Sure, lguest is simple because it doesn't support PCI. But Linux > will forever support PCI, and Qemu will always support PCI. You > aren't simplifying anything by adding vbus. > > Optimization: > > Most of PCI (in our context) deals with configuration. So removing it > doesn't optimize anything, unless you're counting hotplugs-per-second > or something. Most, but not all ;) (Sorry, you left the window open on that one). What about IRQ routing? What if I want to coalesce interrupts to minimize injection overhead? How do I do that in PCI? How do I route those interrupts in an arbitrarily nested fashion, say, to a guest userspace? What about scale? What if Herbet decides to implement a 2048 ring MQ device ;) Theres no great way to do that in x86 with PCI, yet I can do it in vbus. (And yes, I know, this is ridiculous..just wanting to get you thinking) > > Second of all, I want to use vbus for other things that do not speak PCI natively (like userspace for instance...and if I am gleaning this correctly, lguest doesnt either). >>> And virtio supports lguest and s390. virtio is not PCI specific. >>> >> I understand that. We keep getting wrapped around the axle on this >> one. At some point in the discussion we were talking about supporting >> the existing guest ABI without changing the guest at all. So while I >> totally understand the virtio can work over various transports, I am >> referring to what would be needed to have existing ABI guests work with >> an in-kernel version. This may or may not be an actual requirement. >> > > There is be no problem supporting an in-kernel host virtio endpoint > with the existing guest/host ABI. Nothing in the ABI assumes the host > endpoint is in userspace. Nothing in the implementation requires us > to move any of the PCI stuff into the kernel. Well, thats not really true. If the device is a PCI device, there is *some* stuff that has to go into the kernel. Not an ICH model or anything, but at least an ability to interact with userspace for config-space changes, etc. > > In fact, we already have in-kernel sources of PCI interrupts, these > are assigned PCI devices (obviously, these have to use PCI). This will help. > >>> However, for the PC platform, PCI has distinct advantages. What >>> advantages does vbus have for the PC platform? >>> >> To reiterate: IMO simplicity and optimization. Its designed >> specifically for PV use, which is software to software. >> > > To avoid reiterating, please be specific about these advantages. We are both reading the same thread, right? > >> PCI sounds good at first, but I believe its a false economy. It was designed, of course, to be a hardware solution, so it carries all this baggage derived from hardware constraints that simply do not exist in a pure software world and that have to be emulated. Things like the fixed length and centrally managed PCI-IDs, >>> Not a problem in practice. >>> >> >> Perhaps, but its just one more constraint that isn't actually needed. >> Its like the cvs vs git debate. Why have it centrally managed when you >> don't technically need it. Sure, centrally managed works, but I'd >> rather not deal with it if there was a better option. >> > > We've allocated 3 PCI device IDs so far. It's not a problem. There > are enough real problems out there. > >> PIO config cycles, BARs, pci-irq-routing, etc. >>> What are the problems with these? >>> >> >> 1) PIOs are still less efficient to decode than a hypercall vector. We >> dont need to pretend we are hardware..the guest already knows whats >> underneath them. Use the most efficient call method. >> >
Re: [RFC PATCH 00/17] virtual-bus
* Gregory Haskins (ghask...@novell.com) wrote: > Let me ask you this: If you had a clean slate and were designing a > hypervisor and a guest OS from scratch: What would you make the bus > look like? Well, virtio did have a relatively clean slate. And PCI (as _one_ transport option) is what it looks like. It's not the only transport (as Avi already mentioned it works for s390, for example). BTW, from my brief look at vbus, it seems pretty similar to xenbus. thanks, -chris -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> Avi Kivity wrote: >> >>> Gregory Haskins wrote: >>> So again, I am proposing for consideration of accepting my work (either in its current form, or something we agree on after the normal review process) not only on the basis of the future development of the platform, but also to keep current components in their running to their full potential. I will again point out that the code is almost completely off to the side, can be completely disabled with config options, and I will maintain it. Therefore the only real impact is to people who care to even try it, and to me. >>> Your work is a whole stack. Let's look at the constituents. >>> >>> - a new virtual bus for enumerating devices. >>> >>> Sorry, I still don't see the point. It will just make writing drivers >>> more difficult. The only advantage I've heard from you is that it >>> gets rid of the gunk. Well, we still have to support the gunk for >>> non-pv devices so the gunk is basically free. The clean version is >>> expensive since we need to port it to all guests and implement >>> exciting features like hotplug. >>> >> My real objection to PCI is fast-path related. I don't object, per se, >> to using PCI for discovery and hotplug. If you use PCI just for these >> types of things, but then allow fastpath to use more hypercall oriented >> primitives, then I would agree with you. We can leave PCI emulation in >> user-space, and we get it for free, and things are relatively tidy. >> > > PCI has very little to do with the fast path (nothing, if we use MSI). At the very least, PIOs are slightly slower than hypercalls. Perhaps not enough to care, but the last time I measured them they were slower, and therefore my clean slate design doesn't use them. But I digress. I think I was actually kind of agreeing with you that we could do this. :P > >> Its once you start requiring that we stay ABI compatible with something >> like the existing virtio-net in x86 KVM where I think it starts to get >> ugly when you try to move it into the kernel. So that is what I had a >> real objection to. I think as long as we are not talking about trying >> to make something like that work, its a much more viable prospect. >> > > I don't see why the fast path of virtio-net would be bad. Can you > elaborate? Im not. I am saying I think we might be able to do this. > > Obviously all the pci glue stays in userspace. > >> So what I propose is the following: >> 1) The core vbus design stays the same (or close to it) >> > > Sorry, I still don't see what advantage this has over PCI, and how you > deal with the disadvantages. I think you are confusing the vbus-proxy (guest side) with the vbus backend. (1) is saying "keep the vbus backend'" and (2) is saying drop the guest side stuff. In this proposal, the guest would speak a PCI ABI as far as its concerned. Devices in the vbus backend would render as PCI objects in the ICH (or whatever) model in userspace. > >> 2) the vbus-proxy and kvm-guest patch go away >> 3) the kvm-host patch changes to work with coordination from the >> userspace-pci emulation for things like MSI routing >> 4) qemu will know to create some MSI shim 1:1 with whatever it >> instantiates on the bus (and can communicate changes >> > > Don't userstand. What's this MSI shim? Well, if the device model was an object in vbus down in the kernel, yet PCI emulation was up in qemu, presumably we would want something to handle things like PCI config-cycles up in userspace. Like, for instance, if the guest re-routes the MSI. The shim/proxy would handle the config-cycle, and then turn around and do an ioctl to the kernel to configure the change with the in-kernel device model (or the irq infrastructure, as required). But, TBH, I haven't really looked into whats actually required to make this work yet. I am just spitballing to try to find a compromise. > >> 5) any drivers that are written for these new PCI-IDs that might be >> present are allowed to use a hypercall ABI to talk after they have been >> probed for that ID (e.g. they are not limited to PIO or MMIO BAR type >> access methods). >> > > The way we'd to it with virtio is to add a feature bit that say "you > can hypercall here instead of pio". This way old drivers continue to > work. Yep, agreed. This is what I was thinking we could do. But now that I have the possibility that I just need to write a virtio-vbus module to co-exist with virtio-pci, perhaps it doesn't even need to be explicit. > > Note that nothing prevents us from trapping pio in the kernel (in > fact, we do) and forwarding it to the device. It shouldn't be any > slower than hypercalls. Sure, its just slightly slower, so I would prefer pure hypercalls if at all possible. > >> Once I get here, I might have greater clarity to see how hard it would >> make to emulate fast path components as well
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: I'll rephrase. What are the substantial benefits that this offers over PCI? Simplicity and optimization. You don't need most of the junk that comes with PCI. Its all overhead and artificial constraints. You really only need things like a handful of hypercall verbs and thats it. Simplicity: The guest already supports PCI. It has to, since it was written to the PC platform, and since today it is fashionable to run kernels that support both bare metal and a hypervisor. So you can't remove PCI from the guest. The host also already supports PCI. It has to, since it must supports guests which do not support vbus. We can't remove PCI from the host. You don't gain simplicity by adding things. Sure, lguest is simple because it doesn't support PCI. But Linux will forever support PCI, and Qemu will always support PCI. You aren't simplifying anything by adding vbus. Optimization: Most of PCI (in our context) deals with configuration. So removing it doesn't optimize anything, unless you're counting hotplugs-per-second or something. Second of all, I want to use vbus for other things that do not speak PCI natively (like userspace for instance...and if I am gleaning this correctly, lguest doesnt either). And virtio supports lguest and s390. virtio is not PCI specific. I understand that. We keep getting wrapped around the axle on this one. At some point in the discussion we were talking about supporting the existing guest ABI without changing the guest at all. So while I totally understand the virtio can work over various transports, I am referring to what would be needed to have existing ABI guests work with an in-kernel version. This may or may not be an actual requirement. There is be no problem supporting an in-kernel host virtio endpoint with the existing guest/host ABI. Nothing in the ABI assumes the host endpoint is in userspace. Nothing in the implementation requires us to move any of the PCI stuff into the kernel. In fact, we already have in-kernel sources of PCI interrupts, these are assigned PCI devices (obviously, these have to use PCI). However, for the PC platform, PCI has distinct advantages. What advantages does vbus have for the PC platform? To reiterate: IMO simplicity and optimization. Its designed specifically for PV use, which is software to software. To avoid reiterating, please be specific about these advantages. PCI sounds good at first, but I believe its a false economy. It was designed, of course, to be a hardware solution, so it carries all this baggage derived from hardware constraints that simply do not exist in a pure software world and that have to be emulated. Things like the fixed length and centrally managed PCI-IDs, Not a problem in practice. Perhaps, but its just one more constraint that isn't actually needed. Its like the cvs vs git debate. Why have it centrally managed when you don't technically need it. Sure, centrally managed works, but I'd rather not deal with it if there was a better option. We've allocated 3 PCI device IDs so far. It's not a problem. There are enough real problems out there. PIO config cycles, BARs, pci-irq-routing, etc. What are the problems with these? 1) PIOs are still less efficient to decode than a hypercall vector. We dont need to pretend we are hardware..the guest already knows whats underneath them. Use the most efficient call method. Last time we measured, hypercall overhead was the same as pio overhead. Both vmx and svm decode pio completely (except for string pio ...) 2) BARs? No one in their right mind should use an MMIO BAR for PV. :) The last thing we want to do is cause page faults here. Don't use them, period. (This is where something like the vbus::shm() interface comes in) So don't use BARs for your fast path. virtio places the ring in guest memory (like most real NICs). 3) pci-irq routing was designed to accommodate etch constraints on a piece of silicon that doesn't actually exist in kvm. Why would I want to pretend I have PCI A,B,C,D lines that route to a pin on an IOAPIC? Forget all that stuff and just inject an IRQ directly. This gets much better with MSI, I admit, but you hopefully catch my drift now. True, PCI interrupts suck. But this was fixed with MSI. Why fix it again? One of my primary design objectives with vbus was to a) reduce the signaling as much as possible, and b) reduce the cost of signaling. That is why I do things like use explicit hypercalls, aggregated interrupts, bidir napi to mitigate signaling, the shm_signal::pending mitigation, and avoiding going to userspace by running in the kernel. All of these things together help to form what I envision would be a maximum performance transport. Not all of these tricks are interdependent (for instance, the bidir + full-duplex threading that I do can be done in
Re: [RFC PATCH 00/17] virtual-bus
Hi Avi, I think we have since covered these topics later in the thread, but in case you wanted to know my thoughts here: Avi Kivity wrote: > Gregory Haskins wrote: Yes, but the important thing to point out is it doesn't *replace* PCI. It simply an alternative. >>> Does it offer substantial benefits over PCI? If not, it's just extra >>> code. >>> >> >> First of all, do you think I would spend time designing it if I didn't >> think so? :) >> > > I'll rephrase. What are the substantial benefits that this offers > over PCI? Simplicity and optimization. You don't need most of the junk that comes with PCI. Its all overhead and artificial constraints. You really only need things like a handful of hypercall verbs and thats it. > >> Second of all, I want to use vbus for other things that do not speak PCI >> natively (like userspace for instance...and if I am gleaning this >> correctly, lguest doesnt either). >> > > And virtio supports lguest and s390. virtio is not PCI specific. I understand that. We keep getting wrapped around the axle on this one. At some point in the discussion we were talking about supporting the existing guest ABI without changing the guest at all. So while I totally understand the virtio can work over various transports, I am referring to what would be needed to have existing ABI guests work with an in-kernel version. This may or may not be an actual requirement. > > However, for the PC platform, PCI has distinct advantages. What > advantages does vbus have for the PC platform? To reiterate: IMO simplicity and optimization. Its designed specifically for PV use, which is software to software. > >> PCI sounds good at first, but I believe its a false economy. It was >> designed, of course, to be a hardware solution, so it carries all this >> baggage derived from hardware constraints that simply do not exist in a >> pure software world and that have to be emulated. Things like the fixed >> length and centrally managed PCI-IDs, > > Not a problem in practice. Perhaps, but its just one more constraint that isn't actually needed. Its like the cvs vs git debate. Why have it centrally managed when you don't technically need it. Sure, centrally managed works, but I'd rather not deal with it if there was a better option. > >> PIO config cycles, BARs, >> pci-irq-routing, etc. > > What are the problems with these? 1) PIOs are still less efficient to decode than a hypercall vector. We dont need to pretend we are hardware..the guest already knows whats underneath them. Use the most efficient call method. 2) BARs? No one in their right mind should use an MMIO BAR for PV. :) The last thing we want to do is cause page faults here. Don't use them, period. (This is where something like the vbus::shm() interface comes in) 3) pci-irq routing was designed to accommodate etch constraints on a piece of silicon that doesn't actually exist in kvm. Why would I want to pretend I have PCI A,B,C,D lines that route to a pin on an IOAPIC? Forget all that stuff and just inject an IRQ directly. This gets much better with MSI, I admit, but you hopefully catch my drift now. One of my primary design objectives with vbus was to a) reduce the signaling as much as possible, and b) reduce the cost of signaling. That is why I do things like use explicit hypercalls, aggregated interrupts, bidir napi to mitigate signaling, the shm_signal::pending mitigation, and avoiding going to userspace by running in the kernel. All of these things together help to form what I envision would be a maximum performance transport. Not all of these tricks are interdependent (for instance, the bidir + full-duplex threading that I do can be done in userspace too, as discussed). They are just the collective design elements that I think we need to make a guest perform very close to its peak. That is what I am after. > >> While emulation of PCI is invaluable for >> executing unmodified guest, its not strictly necessary from a >> paravirtual software perspective...PV software is inherently already >> aware of its context and can therefore use the best mechanism >> appropriate from a broader selection of choices. >> > > It's also not necessary to invent a new bus. You are right, its not strictly necessary to work. Its just presents the opportunity to optimize as much as possible and to move away from legacy constraints that no longer apply. And since PVs sole purpose is about optimization, I was not really interested in going "half-way". > We need a positive advantage, we don't do things just because we can > (and then lose the real advantages PCI has). Agreed, but I assert there are advantages. You may not think they outweigh the cost, and thats your prerogative, but I think they are still there nonetheless. > >> If we insist that PCI is the only interface we can support and we want >> to do something, say, in the kernel for instance, we have to have either >> somethin
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Avi Kivity wrote: Gregory Haskins wrote: So again, I am proposing for consideration of accepting my work (either in its current form, or something we agree on after the normal review process) not only on the basis of the future development of the platform, but also to keep current components in their running to their full potential. I will again point out that the code is almost completely off to the side, can be completely disabled with config options, and I will maintain it. Therefore the only real impact is to people who care to even try it, and to me. Your work is a whole stack. Let's look at the constituents. - a new virtual bus for enumerating devices. Sorry, I still don't see the point. It will just make writing drivers more difficult. The only advantage I've heard from you is that it gets rid of the gunk. Well, we still have to support the gunk for non-pv devices so the gunk is basically free. The clean version is expensive since we need to port it to all guests and implement exciting features like hotplug. My real objection to PCI is fast-path related. I don't object, per se, to using PCI for discovery and hotplug. If you use PCI just for these types of things, but then allow fastpath to use more hypercall oriented primitives, then I would agree with you. We can leave PCI emulation in user-space, and we get it for free, and things are relatively tidy. PCI has very little to do with the fast path (nothing, if we use MSI). Its once you start requiring that we stay ABI compatible with something like the existing virtio-net in x86 KVM where I think it starts to get ugly when you try to move it into the kernel. So that is what I had a real objection to. I think as long as we are not talking about trying to make something like that work, its a much more viable prospect. I don't see why the fast path of virtio-net would be bad. Can you elaborate? Obviously all the pci glue stays in userspace. So what I propose is the following: 1) The core vbus design stays the same (or close to it) Sorry, I still don't see what advantage this has over PCI, and how you deal with the disadvantages. 2) the vbus-proxy and kvm-guest patch go away 3) the kvm-host patch changes to work with coordination from the userspace-pci emulation for things like MSI routing 4) qemu will know to create some MSI shim 1:1 with whatever it instantiates on the bus (and can communicate changes Don't userstand. What's this MSI shim? 5) any drivers that are written for these new PCI-IDs that might be present are allowed to use a hypercall ABI to talk after they have been probed for that ID (e.g. they are not limited to PIO or MMIO BAR type access methods). The way we'd to it with virtio is to add a feature bit that say "you can hypercall here instead of pio". This way old drivers continue to work. Note that nothing prevents us from trapping pio in the kernel (in fact, we do) and forwarding it to the device. It shouldn't be any slower than hypercalls. Once I get here, I might have greater clarity to see how hard it would make to emulate fast path components as well. It might be easier than I think. This is all off the cuff so it might need some fine tuning before its actually workable. Does that sound reasonable? The vbus part (I assume you mean device enumeration) worries me. I don't think you've yet set down what its advantages are. Being pure and clean doesn't count, unless you rip out PCI from all existing installed hardware and from Windows. - finer-grained point-to-point communication abstractions Where virtio has ring+signalling together, you layer the two. For networking, it doesn't matter. For other applications, it may be helpful, perhaps you have something in mind. Yeah, actually. Thanks for bringing that up. So the reason why signaling and the ring are distinct constructs in the design is to facilitate constructs other than rings. For instance, there may be some models where having a flat shared page is better than a ring. A ring will naturally preserve all values in flight, where as a flat shared page would not (last update is always current). There are some algorithms where a previously posted value is obsoleted by an update, and therefore rings are inherently bad for this update model. And as we know, there are plenty of algorithms where a ring works perfectly. So I wanted that flexibility to be able to express both. I agree that there is significant potential here. One of the things I have in mind for the flat page model is that RT vcpu priority thing. Another thing I am thinking of is coming up with a PV LAPIC type replacement (where we can avoid doing the EOI trap by having the PICs state shared). You keep falling into the paravirtualize the entire universe trap. If you look deep down, you can see Jeremy struggling in there trying to bring dom0 support to Linux/Xe
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> So again, I am proposing for consideration of accepting my work (either >> in its current form, or something we agree on after the normal review >> process) not only on the basis of the future development of the >> platform, but also to keep current components in their running to their >> full potential. I will again point out that the code is almost >> completely off to the side, can be completely disabled with config >> options, and I will maintain it. Therefore the only real impact is to >> people who care to even try it, and to me. >> > > Your work is a whole stack. Let's look at the constituents. > > - a new virtual bus for enumerating devices. > > Sorry, I still don't see the point. It will just make writing drivers > more difficult. The only advantage I've heard from you is that it > gets rid of the gunk. Well, we still have to support the gunk for > non-pv devices so the gunk is basically free. The clean version is > expensive since we need to port it to all guests and implement > exciting features like hotplug. My real objection to PCI is fast-path related. I don't object, per se, to using PCI for discovery and hotplug. If you use PCI just for these types of things, but then allow fastpath to use more hypercall oriented primitives, then I would agree with you. We can leave PCI emulation in user-space, and we get it for free, and things are relatively tidy. Its once you start requiring that we stay ABI compatible with something like the existing virtio-net in x86 KVM where I think it starts to get ugly when you try to move it into the kernel. So that is what I had a real objection to. I think as long as we are not talking about trying to make something like that work, its a much more viable prospect. So what I propose is the following: 1) The core vbus design stays the same (or close to it) 2) the vbus-proxy and kvm-guest patch go away 3) the kvm-host patch changes to work with coordination from the userspace-pci emulation for things like MSI routing 4) qemu will know to create some MSI shim 1:1 with whatever it instantiates on the bus (and can communicate changes 5) any drivers that are written for these new PCI-IDs that might be present are allowed to use a hypercall ABI to talk after they have been probed for that ID (e.g. they are not limited to PIO or MMIO BAR type access methods). Once I get here, I might have greater clarity to see how hard it would make to emulate fast path components as well. It might be easier than I think. This is all off the cuff so it might need some fine tuning before its actually workable. Does that sound reasonable? > > - finer-grained point-to-point communication abstractions > > Where virtio has ring+signalling together, you layer the two. For > networking, it doesn't matter. For other applications, it may be > helpful, perhaps you have something in mind. Yeah, actually. Thanks for bringing that up. So the reason why signaling and the ring are distinct constructs in the design is to facilitate constructs other than rings. For instance, there may be some models where having a flat shared page is better than a ring. A ring will naturally preserve all values in flight, where as a flat shared page would not (last update is always current). There are some algorithms where a previously posted value is obsoleted by an update, and therefore rings are inherently bad for this update model. And as we know, there are plenty of algorithms where a ring works perfectly. So I wanted that flexibility to be able to express both. One of the things I have in mind for the flat page model is that RT vcpu priority thing. Another thing I am thinking of is coming up with a PV LAPIC type replacement (where we can avoid doing the EOI trap by having the PICs state shared). > > - your "bidirectional napi" model for the network device > > virtio implements exactly the same thing, except for the case of tx > mitigation, due to my (perhaps pig-headed) rejection of doing things > in a separate thread, and due to the total lack of sane APIs for > packet traffic. Yeah, and this part is not vbus, nor in-kernel specific. That was just a design element of venet-tap. Though note, I did design the vbus/shm-signal infrastructure with rich support for such a notion in mind, so it wasn't accidental or anything like that. > > - a kernel implementation of the host networking device > > Given the continuous rejection (or rather, their continuous > non-adoption-and-implementation) of my ideas re zerocopy networking > aio, that seems like a pragmatic approach. I wish it were otherwise. Well, that gives me hope, at least ;) > > - a promise of more wonderful things yet to come > > Obviously I can't evaluate this. Right, sorry. I wish I had more concrete examples to show you, but we only have the venet-tap working at this time. I was going for the "release early/often" approach in getting the core reviewed before we got t
Re: [RFC PATCH 00/17] virtual-bus
On Fri, Apr 03, 2009 at 03:02:22PM +0300, Avi Kivity wrote: > > But it flushes the tap device, the packet still has to go through the > bridge + real interface? Which under normal circumstances should occur before netif_rx_ni returns. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 07:54:21PM +0300, Avi Kivity wrote: 3ms latency for ping? (ping will always be scheduled immediately when the reply arrives if I understand cfs, so guest load won't delay it) That only happens if the guest immediately does some CPU-intensive computation 3ms and assuming its timeslice lasts that long. Note that this happens even if the computation is SCHED_BATCH. In any case, the same thing will happen right now if the host or some other guest on the same CPU hogs the CPU for 3ms. If the host is overloaded, that's fair. But millisecond latencies without host contention is not a good result. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: So again, I am proposing for consideration of accepting my work (either in its current form, or something we agree on after the normal review process) not only on the basis of the future development of the platform, but also to keep current components in their running to their full potential. I will again point out that the code is almost completely off to the side, can be completely disabled with config options, and I will maintain it. Therefore the only real impact is to people who care to even try it, and to me. Your work is a whole stack. Let's look at the constituents. - a new virtual bus for enumerating devices. Sorry, I still don't see the point. It will just make writing drivers more difficult. The only advantage I've heard from you is that it gets rid of the gunk. Well, we still have to support the gunk for non-pv devices so the gunk is basically free. The clean version is expensive since we need to port it to all guests and implement exciting features like hotplug. - finer-grained point-to-point communication abstractions Where virtio has ring+signalling together, you layer the two. For networking, it doesn't matter. For other applications, it may be helpful, perhaps you have something in mind. - your "bidirectional napi" model for the network device virtio implements exactly the same thing, except for the case of tx mitigation, due to my (perhaps pig-headed) rejection of doing things in a separate thread, and due to the total lack of sane APIs for packet traffic. - a kernel implementation of the host networking device Given the continuous rejection (or rather, their continuous non-adoption-and-implementation) of my ideas re zerocopy networking aio, that seems like a pragmatic approach. I wish it were otherwise. - a promise of more wonderful things yet to come Obviously I can't evaluate this. Did I miss anything? Right now my preferred course of action is to implement a prototype userspace notification for networking. Second choice is to move the host virtio implementation into the kernel. I simply don't see how the rest of the stack is cost effective. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Fri, Apr 03, 2009 at 02:54:02PM +0300, Avi Kivity wrote: It doesn't copy and queue the packet? We use O_NONBLOCK and poll() so we can tell when we can queue without blocking. Well netif_rx queues the packet, but netif_rx_ni is netif_rx plus an immediate flush. But it flushes the tap device, the packet still has to go through the bridge + real interface? Even if it's queued there, I want to know when the packet is on the wire, not on some random software or hardware queue in the middle. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: > Anthony Liguori wrote: >> Avi Kivity wrote: >>> Avi Kivity wrote: The alternative is to get a notification from the stack that the packet is done processing. Either an skb destructor in the kernel, or my new API that everyone is not rushing out to implement. >>> >>> btw, my new api is >>> >>> >>> io_submit(..., nr, ...): submit nr packets >>> io_getevents(): complete nr packets >> >> I don't think we even need that to end this debate. I'm convinced we >> have a bug somewhere. Even disabling TX mitigation, I see a ping >> latency of around 300ns whereas it's only 50ns on the host. This >> defies logic so I'm now looking to isolate why that is. > > I'm down to 90us. Obviously, s/ns/us/g above. The exec.c changes > were the big winner... I hate qemu sometimes. [ Ive already said this privately to Anthony on IRC, but ..] Hey, congrats! Thats impressive actually. So I realize that perhaps you guys are not quite seeing my long term vision here, which I think will offer some new features that we dont have today. I hope to change that over the coming weeks. However, I should also point out that perhaps even if, as of right now, my one and only working module (venet-tap) were all I could offer, it does give us a "rivalry" position between the two, and this historically has been a good thing on many projects. This helps foster innovation through competition that potentially benefits both. Case in point, a little competition provoked an investigation that brought virtio-net's latency down from 3125us to 90us. I realize its not a production-ready patch quite yet, but I am confident Anthony will find something that is suitable to checkin very soon. That's a huge improvement to a problem that was just sitting around unnoticed because there was nothing to compare it with. So again, I am proposing for consideration of accepting my work (either in its current form, or something we agree on after the normal review process) not only on the basis of the future development of the platform, but also to keep current components in their running to their full potential. I will again point out that the code is almost completely off to the side, can be completely disabled with config options, and I will maintain it. Therefore the only real impact is to people who care to even try it, and to me. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
On Fri, Apr 03, 2009 at 02:54:02PM +0300, Avi Kivity wrote: > > It doesn't copy and queue the packet? We use O_NONBLOCK and poll() so > we can tell when we can queue without blocking. Well netif_rx queues the packet, but netif_rx_ni is netif_rx plus an immediate flush. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Fri, Apr 03, 2009 at 02:46:04PM +0300, Avi Kivity wrote: The host writes the packet to tap, at which point it is consumed from its point of view. The host would like to mention that if there was an API to notify it when the packet was actually consumed, then it would gladly use it. Bonus points if this involves not copying the packet. We're using write(2) for this, no? Yes. That should invoke netif_rx_ni which blocks until the packet is "processed", which usually means that it's placed on the NIC's hardware queue. It doesn't copy and queue the packet? We use O_NONBLOCK and poll() so we can tell when we can queue without blocking. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Fri, Apr 03, 2009 at 02:46:04PM +0300, Avi Kivity wrote: > > The host writes the packet to tap, at which point it is consumed from > its point of view. The host would like to mention that if there was an > API to notify it when the packet was actually consumed, then it would > gladly use it. Bonus points if this involves not copying the packet. We're using write(2) for this, no? That should invoke netif_rx_ni which blocks until the packet is "processed", which usually means that it's placed on the NIC's hardware queue. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Andi Kleen wrote: Check shared ring status when stuffing a request. If there are requests That means you're bouncing cache lines all the time. Probably not a big issue on single socket but could be on larger systems. That's why I'd like requests to be handled on the vcpu thread rather than an auxiliary thread. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Fri, Apr 03, 2009 at 02:03:45PM +0300, Avi Kivity wrote: If the host is able to consume a request immediately, and the guest is not able to batch requests, this breaks down. And that is the current situation. Hang on, why is the host consuming the request immediately? It has to write the packet to tap, which then calls netif_rx_ni so it should actually go all the way, no? The host writes the packet to tap, at which point it is consumed from its point of view. The host would like to mention that if there was an API to notify it when the packet was actually consumed, then it would gladly use it. Bonus points if this involves not copying the packet. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Yes, but the important thing to point out is it doesn't *replace* PCI. It simply an alternative. Does it offer substantial benefits over PCI? If not, it's just extra code. First of all, do you think I would spend time designing it if I didn't think so? :) I'll rephrase. What are the substantial benefits that this offers over PCI? Second of all, I want to use vbus for other things that do not speak PCI natively (like userspace for instance...and if I am gleaning this correctly, lguest doesnt either). And virtio supports lguest and s390. virtio is not PCI specific. However, for the PC platform, PCI has distinct advantages. What advantages does vbus have for the PC platform? PCI sounds good at first, but I believe its a false economy. It was designed, of course, to be a hardware solution, so it carries all this baggage derived from hardware constraints that simply do not exist in a pure software world and that have to be emulated. Things like the fixed length and centrally managed PCI-IDs, Not a problem in practice. PIO config cycles, BARs, pci-irq-routing, etc. What are the problems with these? While emulation of PCI is invaluable for executing unmodified guest, its not strictly necessary from a paravirtual software perspective...PV software is inherently already aware of its context and can therefore use the best mechanism appropriate from a broader selection of choices. It's also not necessary to invent a new bus. We need a positive advantage, we don't do things just because we can (and then lose the real advantages PCI has). If we insist that PCI is the only interface we can support and we want to do something, say, in the kernel for instance, we have to have either something like the ICH model in the kernel (and really all of the pci chipset models that qemu supports), or a hacky hybrid userspace/kernel solution. I think this is what you are advocating, but im sorry. IMO that's just gross and unecessary gunk. If we go for a kernel solution, a hybrid solution is the best IMO. I have no idea what's wrong with it. The guest would discover and configure the device using normal PCI methods. Qemu emulates the requests, and configures the kernel part using normal Linux syscalls. The nice thing is, kvm and the kernel part don't even know about each other, except for a way for hypercalls to reach the device and a way for interrupts to reach kvm. Lets stop beating around the bush and just define the 4-5 hypercall verbs we need and be done with it. :) FYI: The guest support for this is not really *that* much code IMO. drivers/vbus/proxy/Makefile |2 drivers/vbus/proxy/kvm.c | 726 + Does it support device hotplug and hotunplug? Can vbus interrupts be load balanced by irqbalance? Can guest userspace enumerate devices? Module autoloading support? pxe booting? Plus a port to Windows, enerprise Linux distros based on 2.6.dead, and possibly less mainstream OSes. and plus, I'll gladly maintain it :) I mean, its not like new buses do not get defined from time to time. Should the computing industry stop coming up with new bus types because they are afraid that the windows ABI only speaks PCI? No, they just develop a new driver for whatever the bus is and be done with it. This is really no different. As a matter of fact, a new bus was developed recently called PCI express. It uses new slots, new electricals, it's not even a bus (routers + point-to-point links), new everything except that the software model was 1% compatible with traditional PCI. That's how much people are afraid of the Windows ABI. Note that virtio is not tied to PCI, so "vbus is generic" doesn't count. Well, preserving the existing virtio-net on x86 ABI is tied to PCI, which is what I was referring to. Sorry for the confusion. virtio-net knows nothing about PCI. If you have a problem with PCI, write virtio-blah for a new bus. Though I still don't understand why. I meant, move the development effort, testing, installed base, Windows drivers. Again, I will maintain this feature, and its completely off to the side. Turn it off in the config, or do not enable it in qemu and its like it never existed. Worst case is it gets reverted if you don't like it. Aside from the last few kvm specific patches, the rest is no different than the greater linux environment. E.g. if I update the venet driver upstream, its conceptually no different than someone else updating e1000, right? I have no objections to you maintaining vbus, though I'd much prefer if we can pool our efforts and cooperate on having one good set of drivers. I think you're integrating too tightly with kvm, which is likely to cause problems when kvm evolves. The way I'd do it is: - drop all mmu integration; instead, have your devices maintain their own slots layout and use
Re: [RFC PATCH 00/17] virtual-bus
On Fri, Apr 03, 2009 at 01:18:54PM +0200, Andi Kleen wrote: > > Check shared ring status when stuffing a request. If there are requests > > That means you're bouncing cache lines all the time. Probably not a big > issue on single socket but could be on larger systems. If the backend is running on a core that doesn't share caches with the guest queue then you've got bigger problems. Right this is unavoidable for guests with many CPUs but that should go away once we support multiqueue in virtio-net. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gerd Hoffmann wrote: > Avi Kivity wrote: > >> There is no choice. Exiting from the guest to the kernel to userspace >> is prohibitively expensive, you can't do that on every packet. >> > > I didn't look at virtio-net very closely yet. I wonder why the > notification is that a big issue though. It is easy to keep the number > of notifications low without increasing latency: > > Check shared ring status when stuffing a request. If there are requests > not (yet) consumed by the other end there is no need to send a > notification. That scheme can even span multiple rings (nics with rx > and tx for example). > FWIW: I employ this scheme. The shm-signal construct has a "dirty" and "pending" flag (all on the same cacheline, which may or may not address Andi's later point). The first time you dirty the shm, it sets both flags. The consumer side has to clear "pending" before any subsequent signals are sent. Normally the consumer side will also clear "enabled" (as part of the bidir napi thing) to further disable signals. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
> Check shared ring status when stuffing a request. If there are requests That means you're bouncing cache lines all the time. Probably not a big issue on single socket but could be on larger systems. -Andi -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Fri, Apr 03, 2009 at 02:03:45PM +0300, Avi Kivity wrote: > > If the host is able to consume a request immediately, and the guest is > not able to batch requests, this breaks down. And that is the current > situation. Hang on, why is the host consuming the request immediately? It has to write the packet to tap, which then calls netif_rx_ni so it should actually go all the way, no? Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gerd Hoffmann wrote: Avi Kivity wrote: There is no choice. Exiting from the guest to the kernel to userspace is prohibitively expensive, you can't do that on every packet. I didn't look at virtio-net very closely yet. I wonder why the notification is that a big issue though. It is easy to keep the number of notifications low without increasing latency: Check shared ring status when stuffing a request. If there are requests not (yet) consumed by the other end there is no need to send a notification. That scheme can even span multiple rings (nics with rx and tx for example). If the host is able to consume a request immediately, and the guest is not able to batch requests, this breaks down. And that is the current situation. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > There is no choice. Exiting from the guest to the kernel to userspace > is prohibitively expensive, you can't do that on every packet. I didn't look at virtio-net very closely yet. I wonder why the notification is that a big issue though. It is easy to keep the number of notifications low without increasing latency: Check shared ring status when stuffing a request. If there are requests not (yet) consumed by the other end there is no need to send a notification. That scheme can even span multiple rings (nics with rx and tx for example). Host backend can put a limit on the number of requests it takes out of the queue at once. i.e. block backend can take out some requests, throw them at the block layer, check whenever any request in flight is done, if so send back replies, start over again. guest can put more requests into the queue meanwhile without having to notify the host. I've seen the number of notifications going down to zero when running disk benchmarks in the guest ;) Of course that works best with one or more I/O threads, so the vcpu doesn't has to stop running anyway to get the I/O work done ... cheers, Gerd -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Michael S. Tsirkin wrote: Rusty, I think this is what you did in your patch from 2008 to add destructor for skb data ( http://kerneltrap.org/mailarchive/linux-netdev/2008/4/18/1464944 ): and it seems that it would make zero-copy possible - or was there some problem with that approach? Do you happen to remember? I'm planning on resurrecting it to replace the page destructor used by Xen netback. J -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: > > Anyway, if we're able to send this many packets, I suspect we'll be able > to also handle much higher throughputs without TX mitigation so that's > what I'm going to look at now. Awesome! I'm prepared to eat my words :) On the subject of TX mitigation, can we please set a standard on how we measure it? For instance, do we bind the the backend qemu to the same CPU as the guest, or do we bind it to a different CPU that shares cache? They're two completely different scenarios and I think we should be explicit about which one we're measuring. Thanks, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: Anthony Liguori wrote: I don't think we even need that to end this debate. I'm convinced we have a bug somewhere. Even disabling TX mitigation, I see a ping latency of around 300ns whereas it's only 50ns on the host. This defies logic so I'm now looking to isolate why that is. I'm down to 90us. Obviously, s/ns/us/g above. The exec.c changes were the big winner... I hate qemu sometimes. What, this: UDP_RR test was limited by CPU consumption. QEMU was pegging a CPU with only about 4000 packets per second whereas the host could do 14000. An oprofile run showed that phys_page_find/cpu_physical_memory_rw where at the top by a wide margin which makes little sense since virtio is zero copy in kvm-userspace today. That leaves the ring queue accessors that used ld[wlq]_phys and friends that happen to make use of the above. That led me to try this terrible hack below and low and beyond, we immediately jumped to 1 pps. This only works because almost nothing uses ld[wlq]_phys in practice except for virtio so breaking it for the non-RAM case didn't matter. We didn't encounter this before because when I changed this behavior, I tested streaming and ping. Both remained the same. You can only expose this issue if you first disable tx mitigation. Anyway, if we're able to send this many packets, I suspect we'll be able to also handle much higher throughputs without TX mitigation so that's what I'm going to look at now. Regards, Anthony Liguori -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >>> vbus (if I understand it right) is a whole package of things: >>> >>> - a way to enumerate, discover, and manage devices >>> >> >> Yes >> >>> That part duplicates PCI >>> >> >> Yes, but the important thing to point out is it doesn't *replace* >> PCI. It simply an alternative. >> > > Does it offer substantial benefits over PCI? If not, it's just extra > code. First of all, do you think I would spend time designing it if I didn't think so? :) Second of all, I want to use vbus for other things that do not speak PCI natively (like userspace for instance...and if I am gleaning this correctly, lguest doesnt either). PCI sounds good at first, but I believe its a false economy. It was designed, of course, to be a hardware solution, so it carries all this baggage derived from hardware constraints that simply do not exist in a pure software world and that have to be emulated. Things like the fixed length and centrally managed PCI-IDs, PIO config cycles, BARs, pci-irq-routing, etc. While emulation of PCI is invaluable for executing unmodified guest, its not strictly necessary from a paravirtual software perspective...PV software is inherently already aware of its context and can therefore use the best mechanism appropriate from a broader selection of choices. If we insist that PCI is the only interface we can support and we want to do something, say, in the kernel for instance, we have to have either something like the ICH model in the kernel (and really all of the pci chipset models that qemu supports), or a hacky hybrid userspace/kernel solution. I think this is what you are advocating, but im sorry. IMO that's just gross and unecessary gunk. Lets stop beating around the bush and just define the 4-5 hypercall verbs we need and be done with it. :) FYI: The guest support for this is not really *that* much code IMO. drivers/vbus/proxy/Makefile |2 drivers/vbus/proxy/kvm.c | 726 + and plus, I'll gladly maintain it :) I mean, its not like new buses do not get defined from time to time. Should the computing industry stop coming up with new bus types because they are afraid that the windows ABI only speaks PCI? No, they just develop a new driver for whatever the bus is and be done with it. This is really no different. > > Note that virtio is not tied to PCI, so "vbus is generic" doesn't count. Well, preserving the existing virtio-net on x86 ABI is tied to PCI, which is what I was referring to. Sorry for the confusion. > >>> and it would be pretty hard to convince me we need to move to >>> something new >>> >> >> But thats just it. You don't *need* to move. The two can coexist side >> by side peacefully. "vbus" just ends up being another device that may >> or may not be present, and that may or may not have devices on it. In >> fact, during all this testing I was booting my guest with "eth0" as >> virtio-net, and "eth1" as venet. The both worked totally fine and >> harmoniously. The guest simply discovers if vbus is supported via a >> cpuid feature bit and dynamically adds it if present. >> > > I meant, move the development effort, testing, installed base, Windows > drivers. Again, I will maintain this feature, and its completely off to the side. Turn it off in the config, or do not enable it in qemu and its like it never existed. Worst case is it gets reverted if you don't like it. Aside from the last few kvm specific patches, the rest is no different than the greater linux environment. E.g. if I update the venet driver upstream, its conceptually no different than someone else updating e1000, right? > >> >>> . virtio-pci (a) works, >>> >> And it will continue to work >> > > So why add something new? I was hoping this was becoming clear by now, but apparently I am doing a poor job of articulating things. :( I think we got bogged down in the 802.x performance discussion and lost sight of what we are trying to accomplish with the core infrastructure. So this core vbus infrastructure is for generic, in-kernel IO models. As a first pass, we have implemented a kvm-connector, which lets kvm guest kernels have access to the bus. We also have a userspace connector (which I haven't pushed yet due to remaining issues being ironed out) which allows userspace applications to interact with the devices as well. As a prototype, we built "venet" to show how it all works. In the future, we want to use this infrastructure to build IO models for various things like high performance fabrics and guest bypass technologies, etc. For instance, guest userspace connections to RDMA devices in the kernel, etc. > >> >>> (b) works on Windows. >>> >> >> virtio will continue to work on windows, as well. And if one of my >> customers wants vbus support on windows and is willing to pay us to >> develop it, we can support *it* there as well. >> > > I don't want to develop and support both v
Re: [RFC PATCH 00/17] virtual-bus
On Fri, Apr 03, 2009 at 01:06:10AM +0800, Herbert Xu wrote: > > That only happens if the guest immediately does some CPU-intensive > computation 3ms and assuming its timeslice lasts that long. > > In any case, the same thing will happen right now if the host or > some other guest on the same CPU hogs the CPU for 3ms. Even better, look at the packet's TOS. If it's marked for low- latency then vmexit immediately. Otherwise continue. In the backend you'd just set the marker in shared memory. Of course invert this for the host => guest direction. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 07:54:21PM +0300, Avi Kivity wrote: > > 3ms latency for ping? > > (ping will always be scheduled immediately when the reply arrives if I > understand cfs, so guest load won't delay it) That only happens if the guest immediately does some CPU-intensive computation 3ms and assuming its timeslice lasts that long. In any case, the same thing will happen right now if the host or some other guest on the same CPU hogs the CPU for 3ms. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 06:49:22PM +0300, Avi Kivity wrote: I still think you want one MSI per device rather than one MSI per vbus, to avoid scaling problems on large guest. After Herbert's let loose on the code, one MSI per queue. Yes, one MSI per TX queue, and one per RX queue :) We're currently limited to 1024, so go wild :) -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 06:57:38PM +0300, Avi Kivity wrote: What if the guest sends N packets, then does some expensive computation (say the guest scheduler switches from the benchmark process to evolution). So now we have the marker set at packet N, but the host will not see it until the guest timeslice is up? Well that's fine. The guest will use up the remainder of its timeslice. After all we only have one core/hyperthread here so this is no different than if the packets were held up higher up in the guest kernel and the guest decided to do some computation. 3ms latency for ping? (ping will always be scheduled immediately when the reply arrives if I understand cfs, so guest load won't delay it) -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 06:49:22PM +0300, Avi Kivity wrote: > > I still think you want one MSI per device rather than one MSI per vbus, > to avoid scaling problems on large guest. After Herbert's let loose on > the code, one MSI per queue. Yes, one MSI per TX queue, and one per RX queue :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 06:57:38PM +0300, Avi Kivity wrote: > > What if the guest sends N packets, then does some expensive computation > (say the guest scheduler switches from the benchmark process to > evolution). So now we have the marker set at packet N, but the host > will not see it until the guest timeslice is up? Well that's fine. The guest will use up the remainder of its timeslice. After all we only have one core/hyperthread here so this is no different than if the packets were held up higher up in the guest kernel and the guest decided to do some computation. Once its timeslice completes the backend can start plugging away at the backlog. Of course it would be better to put the backend on another core that shares the cache or a hyperthread on the same core. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: I don't think we even need that to end this debate. I'm convinced we have a bug somewhere. Even disabling TX mitigation, I see a ping latency of around 300ns whereas it's only 50ns on the host. This defies logic so I'm now looking to isolate why that is. I'm down to 90us. Obviously, s/ns/us/g above. The exec.c changes were the big winner... I hate qemu sometimes. What, this: diff --git a/qemu/exec.c b/qemu/exec.c index 67f3fa3..1331022 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -3268,6 +3268,10 @@ uint32_t ldl_phys(target_phys_addr_t addr) unsigned long pd; PhysPageDesc *p; +#if 1 +return ldl_p(phys_ram_base + addr); +#endif + p = phys_page_find(addr >> TARGET_PAGE_BITS); if (!p) { pd = IO_MEM_UNASSIGNED; @@ -3300,6 +3304,10 @@ uint64_t ldq_phys(target_phys_addr_t addr) unsigned long pd; PhysPageDesc *p; +#if 1 +return ldq_p(phys_ram_base + addr); +#endif + p = phys_page_find(addr >> TARGET_PAGE_BITS); if (!p) { pd = IO_MEM_UNASSIGNED; The way I read it, it will run only run slowly once per page, then settle to a cache miss per page. Regardless, it makes a memslot model even more attractive. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: Avi Kivity wrote: Avi Kivity wrote: The alternative is to get a notification from the stack that the packet is done processing. Either an skb destructor in the kernel, or my new API that everyone is not rushing out to implement. btw, my new api is io_submit(..., nr, ...): submit nr packets io_getevents(): complete nr packets I don't think we even need that to end this debate. I'm convinced we have a bug somewhere. Even disabling TX mitigation, I see a ping latency of around 300ns whereas it's only 50ns on the host. This defies logic so I'm now looking to isolate why that is. I'm down to 90us. Obviously, s/ns/us/g above. The exec.c changes were the big winner... I hate qemu sometimes. I'm pretty confident I can get at least to Greg's numbers with some poking. I think I understand why he's doing better after reading his patches carefully but I also don't think it'll scale with many guests well... stay tuned. But most importantly, we are darn near where vbus is with this patch wrt added packet latency and this is totally from userspace with no host kernel changes. So no, userspace is not the issue. Regards, Anthony Liguori Regards, Anthony Liguori diff --git a/qemu/exec.c b/qemu/exec.c index 67f3fa3..1331022 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -3268,6 +3268,10 @@ uint32_t ldl_phys(target_phys_addr_t addr) unsigned long pd; PhysPageDesc *p; +#if 1 +return ldl_p(phys_ram_base + addr); +#endif + p = phys_page_find(addr >> TARGET_PAGE_BITS); if (!p) { pd = IO_MEM_UNASSIGNED; @@ -3300,6 +3304,10 @@ uint64_t ldq_phys(target_phys_addr_t addr) unsigned long pd; PhysPageDesc *p; +#if 1 +return ldq_p(phys_ram_base + addr); +#endif + p = phys_page_find(addr >> TARGET_PAGE_BITS); if (!p) { pd = IO_MEM_UNASSIGNED; diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c index 9bce3a0..ac77b80 100644 --- a/qemu/hw/virtio-net.c +++ b/qemu/hw/virtio-net.c @@ -36,6 +36,7 @@ typedef struct VirtIONet VirtQueue *ctrl_vq; VLANClientState *vc; QEMUTimer *tx_timer; +QEMUBH *bh; int tx_timer_active; int mergeable_rx_bufs; int promisc; @@ -504,6 +505,10 @@ static void virtio_net_receive(void *opaque, const uint8_t *buf, int size) virtio_notify(&n->vdev, n->rx_vq); } +VirtIODevice *global_vdev = NULL; + +extern void tap_try_to_recv(VLANClientState *vc); + /* TX */ static void virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq) { @@ -545,42 +550,35 @@ static void virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq) len += hdr_len; } +global_vdev = &n->vdev; len += qemu_sendv_packet(n->vc, out_sg, out_num); +global_vdev = NULL; virtqueue_push(vq, &elem, len); virtio_notify(&n->vdev, vq); } + +tap_try_to_recv(n->vc->vlan->first_client); } static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) { VirtIONet *n = to_virtio_net(vdev); -if (n->tx_timer_active) { -virtio_queue_set_notification(vq, 1); -qemu_del_timer(n->tx_timer); -n->tx_timer_active = 0; -virtio_net_flush_tx(n, vq); -} else { -qemu_mod_timer(n->tx_timer, - qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL); -n->tx_timer_active = 1; -virtio_queue_set_notification(vq, 0); -} +#if 0 +virtio_queue_set_notification(vq, 0); +qemu_bh_schedule(n->bh); +#else +virtio_net_flush_tx(n, n->tx_vq); +#endif } -static void virtio_net_tx_timer(void *opaque) +static void virtio_net_handle_tx_bh(void *opaque) { VirtIONet *n = opaque; -n->tx_timer_active = 0; - -/* Just in case the driver is not ready on more */ -if (!(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) -return; - -virtio_queue_set_notification(n->tx_vq, 1); virtio_net_flush_tx(n, n->tx_vq); +virtio_queue_set_notification(n->tx_vq, 1); } static void virtio_net_save(QEMUFile *f, void *opaque) @@ -675,8 +673,8 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->vdev.get_features = virtio_net_get_features; n->vdev.set_features = virtio_net_set_features; n->vdev.reset = virtio_net_reset; -n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx); -n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx); +n->rx_vq = virtio_add_queue(&n->vdev, 512, virtio_net_handle_rx); +n->tx_vq = virtio_add_queue(&n->vdev, 512, virtio_net_handle_tx); n->ctrl_vq = virtio_add_queue(&n->vdev, 16, virtio_net_handle_ctrl); memcpy(n->mac, nd->macaddr, ETH_ALEN); n->status = VIRTIO_NET_S_LINK_UP; @@ -684,10 +682,10 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) virtio_net_receive, virtio_net_can_receive, n); n->vc->link_status_changed = virtio_net_set_link_status; +n->bh = qemu_bh_new(virti
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 06:00:17PM +0300, Avi Kivity wrote: Good point - if we rely on having excess cores in the host, large guest scalability will drop. Going back to TX mitigation, I wonder if we could avoid it altogether by having a "wakeup" mechanism that does not involve a vmexit. We have two cases: 1) UP, or rather guest runs on the same core/hyperthread as the backend. This is the easy one, the guest simply sets a marker in shared memory and keeps going until its time is up. Then the backend takes over, and uses a marker for notification too. The markers need to be interpreted by the scheduler so that it knows the guest/backend is runnable, respectively. Let's look at this first. What if the guest sends N packets, then does some expensive computation (say the guest scheduler switches from the benchmark process to evolution). So now we have the marker set at packet N, but the host will not see it until the guest timeslice is up? I think I totally misunderstood you. Can you repeat in smaller words? -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: vbus (if I understand it right) is a whole package of things: - a way to enumerate, discover, and manage devices Yes That part duplicates PCI Yes, but the important thing to point out is it doesn't *replace* PCI. It simply an alternative. Does it offer substantial benefits over PCI? If not, it's just extra code. Note that virtio is not tied to PCI, so "vbus is generic" doesn't count. and it would be pretty hard to convince me we need to move to something new But thats just it. You don't *need* to move. The two can coexist side by side peacefully. "vbus" just ends up being another device that may or may not be present, and that may or may not have devices on it. In fact, during all this testing I was booting my guest with "eth0" as virtio-net, and "eth1" as venet. The both worked totally fine and harmoniously. The guest simply discovers if vbus is supported via a cpuid feature bit and dynamically adds it if present. I meant, move the development effort, testing, installed base, Windows drivers. . virtio-pci (a) works, And it will continue to work So why add something new? (b) works on Windows. virtio will continue to work on windows, as well. And if one of my customers wants vbus support on windows and is willing to pay us to develop it, we can support *it* there as well. I don't want to develop and support both virtio and vbus. And I certainly don't want to depend on your customers. - a different way of doing interrupts Yeah, but this is ok. And I am not against doing that mod we talked about earlier where I replace dynirq with a pci shim to represent the vbus. Question about that: does userspace support emulation of MSI interrupts? Yes, this is new. See the interrupt routing stuff I mentioned. It's probably only in kvm.git, not even in 2.6.30. I would probably prefer it if I could keep the vbus IRQ (or IRQs when I support MQ) from being shared. It seems registering the vbus as an MSI device would be more conducive to avoiding this. I still think you want one MSI per device rather than one MSI per vbus, to avoid scaling problems on large guest. After Herbert's let loose on the code, one MSI per queue. - a different ring layout, and splitting notifications from the ring Again, virtio will continue to work. And if we cannot find a way to collapse virtio and ioq together in a way that everyone agrees on, there is no harm in having two. I have no problem saying I will maintain IOQ. There is plenty of precedent for multiple ways to do the same thing. IMO we should just steal whatever makes ioq better, and credit you in some file no one reads. We get backwards compatibility, Windows support, continuity, etc. I don't see the huge win here - placing the host part in the host kernel Nothing vbus-specific here. Well, it depends on what you want. Do you want a implementation that is virtio-net, kvm, and pci specific while being hardcoded in? No. virtio is already not kvm or pci specific. Definitely all the pci emulation parts will remain in user space. What happens when someone wants to access it but doesnt support pci? What if something like lguest wants to use it too? What if you want virtio-block next? This is one extreme. It works out well on the guest side, so it can work on the host side. We have virtio bindings for pci, s390, and of course lguest. virtio itself is agnostic to all of these. The main difference from vbus is that it's guest-only, but could easily be extended to the host side if we break down and do things in the kernel. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 06:00:17PM +0300, Avi Kivity wrote: > > Good point - if we rely on having excess cores in the host, large guest > scalability will drop. Going back to TX mitigation, I wonder if we could avoid it altogether by having a "wakeup" mechanism that does not involve a vmexit. We have two cases: 1) UP, or rather guest runs on the same core/hyperthread as the backend. This is the easy one, the guest simply sets a marker in shared memory and keeps going until its time is up. Then the backend takes over, and uses a marker for notification too. The markers need to be interpreted by the scheduler so that it knows the guest/backend is runnable, respectively. 2) The guest and backend runs on two cores/hyperthreads. We'll assume that they share caches as otherwise mitigation is the last thing to worry about. We use the same marker mechanism as above. The only caveat is that if one core/hyperthread is idle, its idle thread needs to monitor the marker (this would be a separate per-core marker) to wake up the scheduler. CCing Ingo so that he can flame me if I'm totally off the mark. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Patrick Mullaney wrote: >> On Thu, 2009-04-02 at 16:27 +0300, Avi Kivity wrote: >> >> >>> virtio is a stable ABI. >>> >>> However, theres still the possibility we can make this work in an ABI friendly way with cap-bits, or other such features. For instance, the virtio-net driver could register both with pci and vbus-proxy and instantiate a device with a slightly different ops structure for each or something. Alternatively we could write a host-side shim to expose vbus devices as pci devices or something like that. >>> Sounds complicated... >>> >>> >> >> IMO, it doesn't sound anymore complicated than making virtio support the >> concepts already provided by vbus/venet-tap driver. Isn't there already >> precedent for alternative approaches co-existing and having the users >> decide which is the most appropriate for their use case? Switching >> drivers in order to improve latency for a certain class of applications >> would seem like something latency sensitive users would be more than >> willing to do. I'd like to point out 2 things. Greg has offered help >> in moving virtio into the vbus infrastructure. The vbus infrastructure >> is a large part of what is being proposed here. >> > > vbus (if I understand it right) is a whole package of things: > > - a way to enumerate, discover, and manage devices Yes > > That part duplicates PCI Yes, but the important thing to point out is it doesn't *replace* PCI. It simply an alternative. > and it would be pretty hard to convince me we need to move to > something new But thats just it. You don't *need* to move. The two can coexist side by side peacefully. "vbus" just ends up being another device that may or may not be present, and that may or may not have devices on it. In fact, during all this testing I was booting my guest with "eth0" as virtio-net, and "eth1" as venet. The both worked totally fine and harmoniously. The guest simply discovers if vbus is supported via a cpuid feature bit and dynamically adds it if present. > . virtio-pci (a) works, And it will continue to work > (b) works on Windows. virtio will continue to work on windows, as well. And if one of my customers wants vbus support on windows and is willing to pay us to develop it, we can support *it* there as well. > > > - a different way of doing interrupts Yeah, but this is ok. And I am not against doing that mod we talked about earlier where I replace dynirq with a pci shim to represent the vbus. Question about that: does userspace support emulation of MSI interrupts? I would probably prefer it if I could keep the vbus IRQ (or IRQs when I support MQ) from being shared. It seems registering the vbus as an MSI device would be more conducive to avoiding this. > > Again, the need to paravirtualize kills this on Windows (I think). Not really. Its the same thing conceptually as virtio, except I am not riding on PCI so I would need to manage this somehow. Its support would not be "free", but I dont think the ability to support this new bus type is ultimately predicated on having PCI support. But like I said, this is really vbus's problem. virtio will continue to work, and customer funding (or a dev volunteer) will dictate if windows can support vbus as well. Right now I am perfectly willing to accept that windows guests have no ability to access the feature. > > - a different ring layout, and splitting notifications from the ring Again, virtio will continue to work. And if we cannot find a way to collapse virtio and ioq together in a way that everyone agrees on, there is no harm in having two. I have no problem saying I will maintain IOQ. There is plenty of precedent for multiple ways to do the same thing. > > > I don't see the huge win here > > - placing the host part in the host kernel > > Nothing vbus-specific here. Well, it depends on what you want. Do you want a implementation that is virtio-net, kvm, and pci specific while being hardcoded in? What happens when someone wants to access it but doesnt support pci? What if something like lguest wants to use it too? What if you want virtio-block next? This is one extreme. The other extreme is the direction I have gone, which is dynamically loaded/instantiated generic objects which can work with kvm or whatever subsystem wants to write a vbus-connector for. I realize this is more complex. It is also more flexible. Everything has a cost, though I will point out that a good portion of the cost has already been paid for by me and my employer ;) So yeah, it doesn't *need* vbus to do this. This is just one way of many things that could be done between the two extremes. But I didn't design this thing to be some randomly coded amorphous blob that I am now trying to miraculously shoehorn into KVM. I designed it from the start as what I felt a good virtual IO facility could be when starting with a clean slate, keeping KVM as a primary t
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 10:43:19PM +1030, Rusty Russell wrote: > On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: > > You do not need to know when the packet is copied (which I currently > > do). You only need it for zero-copy (of which I would like to support, > > but as I understand it there are problems with the reliability of proper > > callback (i.e. skb->destructor). > > But if you have a UP guest, there will *never* be another packet in the queue > at this point, since it wasn't running. > > As Avi said, you can do the processing in another thread and go back to the > guest; lguest pre-virtio did a hacky "weak" wakeup to ensure the guest ran > again before the thread did for exactly this kind of reason. > > While Avi's point about a "powerful enough userspace API" is probably valid, > I don't think it's going to happen. It's almost certainly less code to put a > virtio_net server in the kernel, than it is to create such a powerful > interface (see vringfd & tap). And that interface would have one user in > practice. > > So, let's roll out a kernel virtio_net server. Anyone? > Rusty. BTW, whatever approach is chosen, to enable zero-copy transmits, it seems that we still must add tracking of when the skb has actually been transmitted, right? Rusty, I think this is what you did in your patch from 2008 to add destructor for skb data ( http://kerneltrap.org/mailarchive/linux-netdev/2008/4/18/1464944 ): and it seems that it would make zero-copy possible - or was there some problem with that approach? Do you happen to remember? -- MST -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 04:07:09PM +0300, Avi Kivity wrote: I think Rusty did mean a UP guest, and without schedule-and-forget. Going off on a tangent here, I don't really think it should matter whether we're UP or SMP. The ideal state is where we have the same number of (virtual) TX queues as there are cores in the guest. On the host side we need the backend to run at least on a core that shares cache with the corresponding guest queue/core. If that happens to be the same core as the guest core then it should work as well. IOW we should optimise it as if the host were UP. Good point - if we rely on having excess cores in the host, large guest scalability will drop. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 04:07:09PM +0300, Avi Kivity wrote: > > I think Rusty did mean a UP guest, and without schedule-and-forget. Going off on a tangent here, I don't really think it should matter whether we're UP or SMP. The ideal state is where we have the same number of (virtual) TX queues as there are cores in the guest. On the host side we need the backend to run at least on a core that shares cache with the corresponding guest queue/core. If that happens to be the same core as the guest core then it should work as well. IOW we should optimise it as if the host were UP. > The problem is that we already have virtio guest drivers going several > kernel versions back, as well as Windows drivers. We can't keep > changing the infrastructure under people's feet. Yes I agree that changing the guest-side driver is a no-no. However, we should be able to achieve what's shown here without modifying the guest-side. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: Avi Kivity wrote: The alternative is to get a notification from the stack that the packet is done processing. Either an skb destructor in the kernel, or my new API that everyone is not rushing out to implement. btw, my new api is io_submit(..., nr, ...): submit nr packets io_getevents(): complete nr packets I don't think we even need that to end this debate. I'm convinced we have a bug somewhere. Even disabling TX mitigation, I see a ping latency of around 300ns whereas it's only 50ns on the host. This defies logic so I'm now looking to isolate why that is. Regards, Anthony Liguori -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: The alternative is to get a notification from the stack that the packet is done processing. Either an skb destructor in the kernel, or my new API that everyone is not rushing out to implement. btw, my new api is io_submit(..., nr, ...): submit nr packets io_getevents(): complete nr packets -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, 2009-04-02 at 16:27 +0300, Avi Kivity wrote: > > virtio is a stable ABI. > > > However, theres still the possibility we can make this work in an ABI > > friendly way with cap-bits, or other such features. For instance, the > > virtio-net driver could register both with pci and vbus-proxy and > > instantiate a device with a slightly different ops structure for each or > > something. Alternatively we could write a host-side shim to expose vbus > > devices as pci devices or something like that. > > > > Sounds complicated... > IMO, it doesn't sound anymore complicated than making virtio support the concepts already provided by vbus/venet-tap driver. Isn't there already precedent for alternative approaches co-existing and having the users decide which is the most appropriate for their use case? Switching drivers in order to improve latency for a certain class of applications would seem like something latency sensitive users would be more than willing to do. I'd like to point out 2 things. Greg has offered help in moving virtio into the vbus infrastructure. The vbus infrastructure is a large part of what is being proposed here. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: If you have a request-response workload with the wire idle and latency critical, then there's no problem having an exit per packet because (a) there aren't that many packets and (b) the guest isn't doing any batching, so guest overhead will swamp the hypervisor overhead. Right, so the trick is to use an algorithm that adapts here. Batching solves the first case, but not the second. The bidir napi thing solves both, but it does assume you have ample host processing power to run the algorithm concurrently. This may or may not be suitable to all applications, I admit. The alternative is to get a notification from the stack that the packet is done processing. Either an skb destructor in the kernel, or my new API that everyone is not rushing out to implement. Right now its way way way worse than 2us. In fact, at my last reading this was more like 3060us (3125-65). So shorten that 3125 to 67 (while maintaining line-rate) and I will be impressed. Heck, shorten it to 80us and I will be impressed. The 3060us thing is a timer, not cpu time. Agreed, but its still "state of the art" from an observer perspective. The reason "why", though easily explainable, is inconsequential to most people. FWIW, I have seen virtio-net do a much more respectable 350us on an older version, so I know there is plenty of room for improvement. All I want is the notification, and the timer is headed into the nearest landfill. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Patrick Mullaney wrote: On Thu, 2009-04-02 at 16:27 +0300, Avi Kivity wrote: virtio is a stable ABI. However, theres still the possibility we can make this work in an ABI friendly way with cap-bits, or other such features. For instance, the virtio-net driver could register both with pci and vbus-proxy and instantiate a device with a slightly different ops structure for each or something. Alternatively we could write a host-side shim to expose vbus devices as pci devices or something like that. Sounds complicated... IMO, it doesn't sound anymore complicated than making virtio support the concepts already provided by vbus/venet-tap driver. Isn't there already precedent for alternative approaches co-existing and having the users decide which is the most appropriate for their use case? Switching drivers in order to improve latency for a certain class of applications would seem like something latency sensitive users would be more than willing to do. I'd like to point out 2 things. Greg has offered help in moving virtio into the vbus infrastructure. The vbus infrastructure is a large part of what is being proposed here. vbus (if I understand it right) is a whole package of things: - a way to enumerate, discover, and manage devices That part duplicates PCI and it would be pretty hard to convince me we need to move to something new. virtio-pci (a) works, (b) works on Windows. - a different way of doing interrupts Again, the need to paravirtualize kills this on Windows (I think). - a different ring layout, and splitting notifications from the ring I don't see the huge win here - placing the host part in the host kernel Nothing vbus-specific here. Switching drivers is unfortunately not easy on Linux as you need a new kernel; it's easier on Windows once you have the drivers written. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> Avi Kivity wrote: >> >>> Gregory Haskins wrote: >>> Avi Kivity wrote: > My 'prohibitively expensive' is true only if you exit every packet. > > > Understood, but yet you need to do this if you want something like iSCSI READ transactions to have as low-latency as possible. >>> Dunno, two microseconds is too much? The wire imposes much more. >>> >>> >> >> No, but thats not what we are talking about. You said signaling on >> every packet is prohibitively expensive. I am saying signaling on every >> packet is required for decent latency. So is it prohibitively expensive >> or not? >> > > We're heading dangerously into the word-game area. Let's not do that. > > If you have a high throughput workload with many packets per seconds > then an exit per packet (whether to userspace or to the kernel) is > expensive. So you do exit mitigation. Latency is not important since > the packets are going to sit in the output queue anyway. Agreed. virtio-net currently does this with batching. I do with the bidir napi thing (which effectively crosses the producer::consumer > 1 threshold to mitigate the signal path). > > If you have a request-response workload with the wire idle and latency > critical, then there's no problem having an exit per packet because > (a) there aren't that many packets and (b) the guest isn't doing any > batching, so guest overhead will swamp the hypervisor overhead. Right, so the trick is to use an algorithm that adapts here. Batching solves the first case, but not the second. The bidir napi thing solves both, but it does assume you have ample host processing power to run the algorithm concurrently. This may or may not be suitable to all applications, I admit. > > If you have a low latency request-response workload mixed with a high > throughput workload, then you aren't going to get low latency since > your low latency packets will sit on the queue behind the high > throughput packets. You can fix that with multiqueue and then you're > back to one of the scenarios above. Agreed, and thats ok. Now we are getting more into 802.1p type MQ issues anyway, if the application cared about it that much. > >> I think most would agree that adding 2us is not bad, but so far that is >> an unproven theory that the IO path in question only adds 2us. And we >> are not just looking at the rate at which we can enter and exit the >> guest...we need the whole path...from the PIO kick to the dev_xmit() on >> the egress hardware, to the ingress and rx-injection. This includes any >> and all penalties associated with the path, even if they are imposed by >> something like the design of tun-tap. >> > > Correct, we need to look at the whole path. That's why the wishing > well is clogged with my 'give me a better userspace interface' emails. > >> Right now its way way way worse than 2us. In fact, at my last reading >> this was more like 3060us (3125-65). So shorten that 3125 to 67 (while >> maintaining line-rate) and I will be impressed. Heck, shorten it to >> 80us and I will be impressed. >> > > The 3060us thing is a timer, not cpu time. Agreed, but its still "state of the art" from an observer perspective. The reason "why", though easily explainable, is inconsequential to most people. FWIW, I have seen virtio-net do a much more respectable 350us on an older version, so I know there is plenty of room for improvement. > We aren't starting a JVM for each packet. Heh...it kind of feels like that right now, so hopefully some improvement will at least be on the one thing that comes out of all this. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> Avi Kivity wrote: >> >>> Gregory Haskins wrote: >>> Rusty Russell wrote: > On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: > >> You do not need to know when the packet is copied (which I currently >> do). You only need it for zero-copy (of which I would like to >> support, >> but as I understand it there are problems with the reliability of >> proper >> callback (i.e. skb->destructor). >> > But if you have a UP guest, > I assume you mean UP host ;) >>> I think Rusty did mean a UP guest, and without schedule-and-forget. >>> >> That doesnt make sense to me, tho. All the testing I did was a UP >> guest, actually. Why would I be constrained to run without the >> scheduling unless the host was also UP? >> > > You aren't constrained. And your numbers show it works. > >>> >>> The problem is that we already have virtio guest drivers going several >>> kernel versions back, as well as Windows drivers. We can't keep >>> changing the infrastructure under people's feet. >>> >> >> Well, IIUC the virtio code itself declares the ABI as unstable, so there >> technically *is* an out if we really wanted one. But I certainly >> understand the desire to not change this ABI if at all possible, and >> thus the resistance here. >> > > virtio is a stable ABI. Dang! Scratch that. > >> However, theres still the possibility we can make this work in an ABI >> friendly way with cap-bits, or other such features. For instance, the >> virtio-net driver could register both with pci and vbus-proxy and >> instantiate a device with a slightly different ops structure for each or >> something. Alternatively we could write a host-side shim to expose vbus >> devices as pci devices or something like that. >> > > Sounds complicated... Well, the first solution would be relatively trivial...at least on the guest side. All the other infrastructure is done and included in the series I sent out. The changes to the virtio-net driver on the guest itself would be minimal. The bigger effort would be converting venet-tap to use virtio-ring instead of IOQ. But this would arguably be less work than starting a virtio-net backend module from scratch because you would have to not only code up the entire virtio-net backend, but also all the pci emulation and irq routing stuff that is required (and is already done by the vbus infrastructure). Here all the major pieces are in place, just the xmit and rx routines need to be converted to virtio-isms. For the second option, I agree. Its probably too nasty and it would be better if there was just either a virtio-net to kvm-host hack, or a more pci oriented version of a vbus-like framework. That said, there is certainly nothing wrong with having an alternate option. There is plenty of precedent for having different drivers for different subsystems, etc, even if there is overlap. Heck, even KVM has realtek, e1000, and virtio-net, etc. Would our kvm community be willing to work with me to get these patches merged? I am perfectly willing to maintain them. That said, the general infrastructure should probably not live in -kvm (perhaps -tip, -mm, or -next, etc is more appropriate). So a good plan might be to shoot for the core going into a more general upstream tree. When/if that happens, then the kvm community could consider the kvm specific parts, etc. I realize this is all pending review acceptance by everyone involved... -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Avi Kivity wrote: Gregory Haskins wrote: Avi Kivity wrote: My 'prohibitively expensive' is true only if you exit every packet. Understood, but yet you need to do this if you want something like iSCSI READ transactions to have as low-latency as possible. Dunno, two microseconds is too much? The wire imposes much more. No, but thats not what we are talking about. You said signaling on every packet is prohibitively expensive. I am saying signaling on every packet is required for decent latency. So is it prohibitively expensive or not? We're heading dangerously into the word-game area. Let's not do that. If you have a high throughput workload with many packets per seconds then an exit per packet (whether to userspace or to the kernel) is expensive. So you do exit mitigation. Latency is not important since the packets are going to sit in the output queue anyway. If you have a request-response workload with the wire idle and latency critical, then there's no problem having an exit per packet because (a) there aren't that many packets and (b) the guest isn't doing any batching, so guest overhead will swamp the hypervisor overhead. If you have a low latency request-response workload mixed with a high throughput workload, then you aren't going to get low latency since your low latency packets will sit on the queue behind the high throughput packets. You can fix that with multiqueue and then you're back to one of the scenarios above. I think most would agree that adding 2us is not bad, but so far that is an unproven theory that the IO path in question only adds 2us. And we are not just looking at the rate at which we can enter and exit the guest...we need the whole path...from the PIO kick to the dev_xmit() on the egress hardware, to the ingress and rx-injection. This includes any and all penalties associated with the path, even if they are imposed by something like the design of tun-tap. Correct, we need to look at the whole path. That's why the wishing well is clogged with my 'give me a better userspace interface' emails. Right now its way way way worse than 2us. In fact, at my last reading this was more like 3060us (3125-65). So shorten that 3125 to 67 (while maintaining line-rate) and I will be impressed. Heck, shorten it to 80us and I will be impressed. The 3060us thing is a timer, not cpu time. We aren't starting a JVM for each packet. We could remove it given a notification API, or duplicating the sched-and-forget thing, like Rusty did with lguest or Mark with qemu. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> Avi Kivity wrote: >> >>> My 'prohibitively expensive' is true only if you exit every packet. >>> >>> >>> >> >> Understood, but yet you need to do this if you want something like iSCSI >> READ transactions to have as low-latency as possible. >> > > Dunno, two microseconds is too much? The wire imposes much more. > No, but thats not what we are talking about. You said signaling on every packet is prohibitively expensive. I am saying signaling on every packet is required for decent latency. So is it prohibitively expensive or not? I think most would agree that adding 2us is not bad, but so far that is an unproven theory that the IO path in question only adds 2us. And we are not just looking at the rate at which we can enter and exit the guest...we need the whole path...from the PIO kick to the dev_xmit() on the egress hardware, to the ingress and rx-injection. This includes any and all penalties associated with the path, even if they are imposed by something like the design of tun-tap. Right now its way way way worse than 2us. In fact, at my last reading this was more like 3060us (3125-65). So shorten that 3125 to 67 (while maintaining line-rate) and I will be impressed. Heck, shorten it to 80us and I will be impressed. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Avi Kivity wrote: Gregory Haskins wrote: Rusty Russell wrote: On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: You do not need to know when the packet is copied (which I currently do). You only need it for zero-copy (of which I would like to support, but as I understand it there are problems with the reliability of proper callback (i.e. skb->destructor). But if you have a UP guest, I assume you mean UP host ;) I think Rusty did mean a UP guest, and without schedule-and-forget. That doesnt make sense to me, tho. All the testing I did was a UP guest, actually. Why would I be constrained to run without the scheduling unless the host was also UP? You aren't constrained. And your numbers show it works. The problem is that we already have virtio guest drivers going several kernel versions back, as well as Windows drivers. We can't keep changing the infrastructure under people's feet. Well, IIUC the virtio code itself declares the ABI as unstable, so there technically *is* an out if we really wanted one. But I certainly understand the desire to not change this ABI if at all possible, and thus the resistance here. virtio is a stable ABI. However, theres still the possibility we can make this work in an ABI friendly way with cap-bits, or other such features. For instance, the virtio-net driver could register both with pci and vbus-proxy and instantiate a device with a slightly different ops structure for each or something. Alternatively we could write a host-side shim to expose vbus devices as pci devices or something like that. Sounds complicated... -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> Rusty Russell wrote: >> >>> On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: >>> You do not need to know when the packet is copied (which I currently do). You only need it for zero-copy (of which I would like to support, but as I understand it there are problems with the reliability of proper callback (i.e. skb->destructor). >>> But if you have a UP guest, >>> >> >> I assume you mean UP host ;) >> >> > > I think Rusty did mean a UP guest, and without schedule-and-forget. That doesnt make sense to me, tho. All the testing I did was a UP guest, actually. Why would I be constrained to run without the scheduling unless the host was also UP? > >> Hmm..well I was hoping to be able to work with you guys to make my >> proposal fit this role. If there is no interest in that, I hope that my >> infrastructure itself may still be considered for merging (in *some* >> tree, not -kvm per se) as I would prefer to not maintain it out of tree >> if it can be avoided. > > The problem is that we already have virtio guest drivers going several > kernel versions back, as well as Windows drivers. We can't keep > changing the infrastructure under people's feet. Well, IIUC the virtio code itself declares the ABI as unstable, so there technically *is* an out if we really wanted one. But I certainly understand the desire to not change this ABI if at all possible, and thus the resistance here. However, theres still the possibility we can make this work in an ABI friendly way with cap-bits, or other such features. For instance, the virtio-net driver could register both with pci and vbus-proxy and instantiate a device with a slightly different ops structure for each or something. Alternatively we could write a host-side shim to expose vbus devices as pci devices or something like that. -Greg > > signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Avi Kivity wrote: My 'prohibitively expensive' is true only if you exit every packet. Understood, but yet you need to do this if you want something like iSCSI READ transactions to have as low-latency as possible. Dunno, two microseconds is too much? The wire imposes much more. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Rusty Russell wrote: On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: You do not need to know when the packet is copied (which I currently do). You only need it for zero-copy (of which I would like to support, but as I understand it there are problems with the reliability of proper callback (i.e. skb->destructor). But if you have a UP guest, I assume you mean UP host ;) I think Rusty did mean a UP guest, and without schedule-and-forget. Hmm..well I was hoping to be able to work with you guys to make my proposal fit this role. If there is no interest in that, I hope that my infrastructure itself may still be considered for merging (in *some* tree, not -kvm per se) as I would prefer to not maintain it out of tree if it can be avoided. The problem is that we already have virtio guest drivers going several kernel versions back, as well as Windows drivers. We can't keep changing the infrastructure under people's feet. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: > > > >>> It's more of a "schedule and forget" which I think brings you the >>> win. The host disables notifications and schedules the actual tx work >>> (rx from the host's perspective). So now the guest and host continue >>> producing and consuming packets in parallel. So long as the guest is >>> faster (due to the host being throttled?), notifications continue to >>> be disabled. >>> >> Yep, when the "producer::consumer" ratio is > 1, we mitigate >> signaling. When its < 1, we signal roughly once per packet. >> >> >>> If you changed your rx_isr() to process the packets immediately >>> instead of scheduling, I think throughput would drop dramatically. >>> >> Right, that is the point. :) This is that "soft asic" thing I was >> talking about yesterday. >> > > But all that has nothing to do with where the code lives, in the > kernel or userspace. Agreed, but note Ive already stated that some of my boost is likely from in-kernel, while others are unrelated design elements such as the "soft-asic" approach (you guys dont read my 10 page emails, do you? ;). I don't deny that some of my ideas could be used in userspace as well (Credit if used would be appreciated :). -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > > > My 'prohibitively expensive' is true only if you exit every packet. > > Understood, but yet you need to do this if you want something like iSCSI READ transactions to have as low-latency as possible. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: > Rusty Russell wrote: > > >> there will *never* be another packet in the queue >> at this point, since it wasn't running. >> >> > Yep, and I'll be the first to admit that my design only looks forward. > To clarify, I am referring to the internal design of the venet-tap only. The general vbus architecture makes no such policy decisions. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Rusty Russell wrote: > On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: > >> You do not need to know when the packet is copied (which I currently >> do). You only need it for zero-copy (of which I would like to support, >> but as I understand it there are problems with the reliability of proper >> callback (i.e. skb->destructor). >> > > But if you have a UP guest, I assume you mean UP host ;) > there will *never* be another packet in the queue > at this point, since it wasn't running. > Yep, and I'll be the first to admit that my design only looks forward. Its for high speed links and multi-core cpus, etc. If you have a uniprocessor host, the throughput would likely start to suffer with my current strategy. You could probably reclaim some of that throughput (but trading latency) by doing as you are suggesting with the deferred initial signalling. However, it is still a tradeoff to account for the lower-end rig. I could certainly put a heuristic/timer on the guest->host to mitigate this as well, but this is not my target use case anyway so I am not sure it is worth it. > As Avi said, you can do the processing in another thread and go back to the > guest; lguest pre-virtio did a hacky "weak" wakeup to ensure the guest ran > again before the thread did for exactly this kind of reason. > > While Avi's point about a "powerful enough userspace API" is probably valid, > I don't think it's going to happen. It's almost certainly less code to put a > virtio_net server in the kernel, than it is to create such a powerful > interface (see vringfd & tap). And that interface would have one user in > practice. > > So, let's roll out a kernel virtio_net server. Anyone? > Hmm..well I was hoping to be able to work with you guys to make my proposal fit this role. If there is no interest in that, I hope that my infrastructure itself may still be considered for merging (in *some* tree, not -kvm per se) as I would prefer to not maintain it out of tree if it can be avoided. I think people will find that the new logic touches very few existing kernel lines at all, and can be completely disabled with config options so it should be relatively inconsequential to those that do not care. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: It's more of a "schedule and forget" which I think brings you the win. The host disables notifications and schedules the actual tx work (rx from the host's perspective). So now the guest and host continue producing and consuming packets in parallel. So long as the guest is faster (due to the host being throttled?), notifications continue to be disabled. Yep, when the "producer::consumer" ratio is > 1, we mitigate signaling. When its < 1, we signal roughly once per packet. If you changed your rx_isr() to process the packets immediately instead of scheduling, I think throughput would drop dramatically. Right, that is the point. :) This is that "soft asic" thing I was talking about yesterday. But all that has nothing to do with where the code lives, in the kernel or userspace. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Avi Kivity wrote: Gregory Haskins wrote: virtio is already non-kvm-specific (lguest uses it) and non-pci-specific (s390 uses it). Ok, then to be more specific, I need it to be more generic than it already is. For instance, I need it to be able to integrate with shm_signals. Why? Well, shm_signals is what I designed to be the event mechanism for vbus devices. One of the design criteria of shm_signal is that it should support a variety of environments, such as kvm, but also something like userspace apps. So I cannot make assumptions about things like "pci interrupts", etc. virtio doesn't make these assumptions either. The only difference I see is that you separate notification from the ring structure. By your own words, the exit to userspace is "prohibitively expensive", so that is either true or its not. If its 2 microseconds, show me. In user/test/x86/vmexit.c, change 'cpuid' to 'out %al, $0'; drop the printf() in kvmctl.c's test_outb(). I get something closer to 4 microseconds, but that's on a two year old machine; It will be around two on Nehalems. My 'prohibitively expensive' is true only if you exit every packet. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: > > > >>> Why does a kernel solution not need to know when a packet is >>> transmitted? >>> >>> >> >> You do not need to know when the packet is copied (which I currently >> do). You only need it for zero-copy (of which I would like to support, >> but as I understand it there are problems with the reliability of proper >> callback (i.e. skb->destructor). >> >> Its "fire and forget" :) >> > > It's more of a "schedule and forget" which I think brings you the > win. The host disables notifications and schedules the actual tx work > (rx from the host's perspective). So now the guest and host continue > producing and consuming packets in parallel. So long as the guest is > faster (due to the host being throttled?), notifications continue to > be disabled. Yep, when the "producer::consumer" ratio is > 1, we mitigate signaling. When its < 1, we signal roughly once per packet. > > If you changed your rx_isr() to process the packets immediately > instead of scheduling, I think throughput would drop dramatically. Right, that is the point. :) This is that "soft asic" thing I was talking about yesterday. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: > > > >>> virtio is already non-kvm-specific (lguest uses it) and >>> non-pci-specific (s390 uses it). >>> >> >> Ok, then to be more specific, I need it to be more generic than it >> already is. For instance, I need it to be able to integrate with >> shm_signals. > > Why? Well, shm_signals is what I designed to be the event mechanism for vbus devices. One of the design criteria of shm_signal is that it should support a variety of environments, such as kvm, but also something like userspace apps. So I cannot make assumptions about things like "pci interrupts", etc. So if I want to use it in vbus, virtio-ring has to be able to use them, as opposed to what it does today. Part of this would be a natural fit for the "kick()" callback in virtio, but there are other problems. For one, virtio-ring (IIUC) does its own event-masking directly in the virtio metadata. However, really I want the higher layer ring-overlay to do its masking in terms of the lower-layered shm_signal in order to work the way I envision this stuff. If you look at the IOQ implementation, this is exactly what it does. To be clear, and Ive stated this in the past: venet is just an example of this generic, in-kernel concept. We plan on doing much much more with all this. One of the things we are working on is have userspace clients be able to access this too, with an ultimately goal of supporting things like having guest-userspace doing bypass, rdma, etc. We are not there yet, though...only the kvm-host to guest kernel is currently functional and is thus the working example. I totally "get" the attraction to doing things in userspace. Its contained, naturally isolated, easily supports migration, etc. Its also a penalty. Bare-metal userspace apps have a direct path to the kernel IO. I want to give guest the same advantage. Some people will care more about things like migration than performance, and that is fine. But others will certainly care more about performance, and that is what we are trying to address. > > > >>> If you have a good exit mitigation scheme you can cut exits by a >>> factor of 100; so the userspace exit costs are cut by the same >>> factor. If you have good copyless networking APIs you can cut the >>> cost of copies to zero (well, to the cost of get_user_pages_fast(), >>> but a kernel solution needs that too). >>> >> >> "exit mitigation' schemes are for bandwidth, not latency. For latency >> it all comes down to how fast you can signal in both directions. If >> someone is going to do a stand-alone request-reply, its generally always >> going to be at least one hypercall and one rx-interrupt. So your speed >> will be governed by your signal path, not your buffer bandwidth. >> > > The userspace path is longer by 2 microseconds (for two additional > heavyweight exits) and a few syscalls. I don't think that's worthy of > putting all the code in the kernel. By your own words, the exit to userspace is "prohibitively expensive", so that is either true or its not. If its 2 microseconds, show me. We need the rtt time to go from a "kick" PIO all the way to queue a packet on the egress hardware and return. That is going to define your latency. If you can do this such that you can do something like ICMP ping in 65us (or anything close to a few dozen microseconds of this), I'll shut-up about how much I think the current path sucks ;) Even so, I still propose the concept of a frame-work for in-kernel devices for all the other reasons I mentioned above. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
On Thursday 02 April 2009 21:36:07 Gregory Haskins wrote: > You do not need to know when the packet is copied (which I currently > do). You only need it for zero-copy (of which I would like to support, > but as I understand it there are problems with the reliability of proper > callback (i.e. skb->destructor). But if you have a UP guest, there will *never* be another packet in the queue at this point, since it wasn't running. As Avi said, you can do the processing in another thread and go back to the guest; lguest pre-virtio did a hacky "weak" wakeup to ensure the guest ran again before the thread did for exactly this kind of reason. While Avi's point about a "powerful enough userspace API" is probably valid, I don't think it's going to happen. It's almost certainly less code to put a virtio_net server in the kernel, than it is to create such a powerful interface (see vringfd & tap). And that interface would have one user in practice. So, let's roll out a kernel virtio_net server. Anyone? Rusty. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: Why does a kernel solution not need to know when a packet is transmitted? You do not need to know when the packet is copied (which I currently do). You only need it for zero-copy (of which I would like to support, but as I understand it there are problems with the reliability of proper callback (i.e. skb->destructor). Its "fire and forget" :) It's more of a "schedule and forget" which I think brings you the win. The host disables notifications and schedules the actual tx work (rx from the host's perspective). So now the guest and host continue producing and consuming packets in parallel. So long as the guest is faster (due to the host being throttled?), notifications continue to be disabled. If you changed your rx_isr() to process the packets immediately instead of scheduling, I think throughput would drop dramatically. Mark had a similar change for virtio. Mark? -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: There is no choice. Exiting from the guest to the kernel to userspace is prohibitively expensive, you can't do that on every packet. Now you are making my point ;) This is part of the cost of your signaling path, and it directly adds to your latency time. It adds a microsecond. The kvm overhead of putting things in userspace is low enough, I don't know why people keep mentioning it. The problem is the kernel/user networking interfaces. You can't buffer packets here if the guest is only going to send one and wait for a response and expect that to perform well. And this is precisely what drove me to look at avoiding going back to userspace in the first place. We're not buffering any packets. What we lack is a way to tell the guest that we're done processing all packets in the ring (IOW, re-enable notifications). -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: virtio is already non-kvm-specific (lguest uses it) and non-pci-specific (s390 uses it). Ok, then to be more specific, I need it to be more generic than it already is. For instance, I need it to be able to integrate with shm_signals. Why? If you have a good exit mitigation scheme you can cut exits by a factor of 100; so the userspace exit costs are cut by the same factor. If you have good copyless networking APIs you can cut the cost of copies to zero (well, to the cost of get_user_pages_fast(), but a kernel solution needs that too). "exit mitigation' schemes are for bandwidth, not latency. For latency it all comes down to how fast you can signal in both directions. If someone is going to do a stand-alone request-reply, its generally always going to be at least one hypercall and one rx-interrupt. So your speed will be governed by your signal path, not your buffer bandwidth. The userspace path is longer by 2 microseconds (for two additional heavyweight exits) and a few syscalls. I don't think that's worthy of putting all the code in the kernel. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Herbert Xu wrote: >> On Thu, Apr 02, 2009 at 12:27:17PM +0300, Avi Kivity wrote: >> >>> If tap told us when the packets were actually transmitted, life >>> would be wonderful: >>> >> >> And why do we need this? Because we are in user space! >> >> > > Why does a kernel solution not need to know when a packet is transmitted? > You do not need to know when the packet is copied (which I currently do). You only need it for zero-copy (of which I would like to support, but as I understand it there are problems with the reliability of proper callback (i.e. skb->destructor). Its "fire and forget" :) -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Herbert Xu wrote: >> Avi Kivity wrote: >> >>> virtio is already non-kvm-specific (lguest uses it) and >>> non-pci-specific (s390 uses it). >>> >> >> I think Greg's work shows that putting the backend in the kernel >> can dramatically reduce the cost of a single guest->host transaction. >> I'm sure the same thing would work for virtio too. >> > > Virtio suffers because we've had no notification of when a packet is > actually submitted. With the notification, the only difference should > be in the cost of a kernel->user switch, which is nowhere nearly as > dramatic. > >>> If you have a good exit mitigation scheme you can cut exits by a >>> factor of 100; so the userspace exit costs are cut by the same >>> factor. If you have good copyless networking APIs you can cut the >>> cost of copies to zero (well, to the cost of get_user_pages_fast(), >>> but a kernel solution needs that too). >>> >> >> Given the choice of having to mitigate or not having the problem >> in the first place, guess what I would prefer :) >> > > There is no choice. Exiting from the guest to the kernel to userspace > is prohibitively expensive, you can't do that on every packet. > Now you are making my point ;) This is part of the cost of your signaling path, and it directly adds to your latency time. You can't buffer packets here if the guest is only going to send one and wait for a response and expect that to perform well. And this is precisely what drove me to look at avoiding going back to userspace in the first place. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > Gregory Haskins wrote: >> >> >> I think there is a slight disconnect here. This is *exactly* what I am >> trying to do. You can of course do this many ways, and I am not denying >> it could be done a different way than the path I have chosen. One >> extreme would be to just slam a virtio-net specific chunk of code >> directly into kvm on the host. Another extreme would be to build a >> generic framework into Linux for declaring arbitrary IO types, >> integrating it with kvm (as well as other environments such as lguest, >> userspace, etc), and building a virtio-net model on top of that. >> >> So in case it is not obvious at this point, I have gone with the latter >> approach. I wanted to make sure it wasn't kvm specific or something >> like pci specific so it had the broadest applicability to a range of >> environments. So that is why the design is the way it is. I understand >> that this approach is technically "harder/more-complex" than the "slam >> virtio-net into kvm" approach, but I've already done that work. All we >> need to do now is agree on the details ;) >> >> > > virtio is already non-kvm-specific (lguest uses it) and > non-pci-specific (s390 uses it). Ok, then to be more specific, I need it to be more generic than it already is. For instance, I need it to be able to integrate with shm_signals. If we can do that without breaking the existing ABI, that would be great! Last I looked, it was somewhat entwined here so I didnt try...but I admit that I didnt try that hard since I already had the IOQ library ready to go. > >>> That said, I don't think we're bound today by the fact that we're in >>> userspace. >>> >> You will *always* be bound by the fact that you are in userspace. Its >> purely a question of "how much" and "does anyone care".Right now, >> the anwer is "a lot (roughly 45x slower)" and "at least Greg's customers >> do". I have no doubt that this can and will change/improve in the >> future. But it will always be true that no matter how much userspace >> improves, the kernel based solution will always be faster. Its simple >> physics. I'm cutting out the middleman to ultimately reach the same >> destination as the userspace path, so userspace can never be equal. >> > > If you have a good exit mitigation scheme you can cut exits by a > factor of 100; so the userspace exit costs are cut by the same > factor. If you have good copyless networking APIs you can cut the > cost of copies to zero (well, to the cost of get_user_pages_fast(), > but a kernel solution needs that too). "exit mitigation' schemes are for bandwidth, not latency. For latency it all comes down to how fast you can signal in both directions. If someone is going to do a stand-alone request-reply, its generally always going to be at least one hypercall and one rx-interrupt. So your speed will be governed by your signal path, not your buffer bandwidth. What Ive done is shown that you can use techniques other than buffering the head of the queue to do exit mitigation for bandwidth, while still maintaining a very short signaling path for latency. And I also argue that the latter will always be optimal in the kernel, though I know by which degree is still TBD. Anthony thinks he can make the difference negligible, and I would love to see it but am skeptical. -Greg signature.asc Description: OpenPGP digital signature
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 12:43:54PM +0300, Avi Kivity wrote: > > So we're back to "the problem is with the kernel->user interface, not > userspace being cursed into slowness". Well until you have a patch + numbers that's only an allegation :) -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 12:38:46PM +0300, Avi Kivity wrote: Why does a kernel solution not need to know when a packet is transmitted? Because you can install your own destructor? So we're back to "the problem is with the kernel->user interface, not userspace being cursed into slowness". -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 12:38:46PM +0300, Avi Kivity wrote: > > Why does a kernel solution not need to know when a packet is transmitted? Because you can install your own destructor? I don't know what Greg did, but netback did that nasty page destructor hack which Jeremy is trying to undo :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 12:27:17PM +0300, Avi Kivity wrote: If tap told us when the packets were actually transmitted, life would be wonderful: And why do we need this? Because we are in user space! Why does a kernel solution not need to know when a packet is transmitted? -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 05:29:36PM +0800, Herbert Xu wrote: > On Thu, Apr 02, 2009 at 12:27:17PM +0300, Avi Kivity wrote: > > > > If tap told us when the packets were actually transmitted, life would be > > wonderful: > > And why do we need this? Because we are in user space! > > I'll continue to wait for your patch and numbers :) And in case you're working on that patch, this might interest you. Check out the netdev thread titled "TX time stamping". Now that we assign the tap skb with its own sk, these two scenarios are pretty much identical. I also noitced despite davem's threats to revert the patch, it has now made Linus's tree :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 12:27:17PM +0300, Avi Kivity wrote: > > If tap told us when the packets were actually transmitted, life would be > wonderful: And why do we need this? Because we are in user space! I'll continue to wait for your patch and numbers :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 12:02:09PM +0300, Avi Kivity wrote: There is no choice. Exiting from the guest to the kernel to userspace is prohibitively expensive, you can't do that on every packet. I was referring to the bit between the kernel and userspace. In any case, I just looked at the virtio mitigation code again and I am completely baffled at why we need it. Look at Greg's code or the netback/netfront notification, why do we need this completely artificial mitigation when the ring itself provides a natural way of stemming the flow? If the vcpu thread does the transmit, then it will always complete sending immediately: guest: push packet, notify qemu qemu: disable notification qemu: pop packet qemu: copy to tap qemu: ?? At this point, qemu must enable notification again, since we have no notification from tap that the transmit completed. The only alternative is the timer. If we do the transmit through an extra thread, then scheduling latency buys us some time: guest: push packet, notify qemu qemu: disable notification qemu: schedule iothread iothread: pop packet iothread: copy to tap iothread: check for more packets iothread: enable notification If tap told us when the packets were actually transmitted, life would be wonderful: guest: push packet, notify qemu qemu: disable notification qemu: pop packet qemu: queue on tap qemu: return to guest hardware: churn churn churn tap: packet is out iothread: check for more packets iothread: enable notification -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 12:02:09PM +0300, Avi Kivity wrote: > > There is no choice. Exiting from the guest to the kernel to userspace > is prohibitively expensive, you can't do that on every packet. I was referring to the bit between the kernel and userspace. In any case, I just looked at the virtio mitigation code again and I am completely baffled at why we need it. Look at Greg's code or the netback/netfront notification, why do we need this completely artificial mitigation when the ring itself provides a natural way of stemming the flow? Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 12:03:32PM +0300, Avi Kivity wrote: > > Like Anthony said, the problem is with the kernel->user interfaces. We > won't have a good user space virtio implementation until that is fixed. If it's just the interface that's bad, then it should be possible to do a proof-of-concept patch to show that this is the case. Even if we have to redesign the interface, at least you can then say that you guys were right all along :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: On Thu, Apr 02, 2009 at 09:46:49AM +0300, Avi Kivity wrote: I don't understand this. If we had good interfaces, all that userspace would do is translate guest physical addresses to host physical addresses, and translate the guest->host protocol to host API calls. I don't see anything there that benefits from being in the kernel. Can you elaborate? I think Greg has expressed it clearly enough. At the end of the day, the numbers speak for themselves. So if and when there's a user-space version that achieves the same or better results, then I will change my mind :) Like Anthony said, the problem is with the kernel->user interfaces. We won't have a good user space virtio implementation until that is fixed. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: Avi Kivity wrote: virtio is already non-kvm-specific (lguest uses it) and non-pci-specific (s390 uses it). I think Greg's work shows that putting the backend in the kernel can dramatically reduce the cost of a single guest->host transaction. I'm sure the same thing would work for virtio too. Virtio suffers because we've had no notification of when a packet is actually submitted. With the notification, the only difference should be in the cost of a kernel->user switch, which is nowhere nearly as dramatic. If you have a good exit mitigation scheme you can cut exits by a factor of 100; so the userspace exit costs are cut by the same factor. If you have good copyless networking APIs you can cut the cost of copies to zero (well, to the cost of get_user_pages_fast(), but a kernel solution needs that too). Given the choice of having to mitigate or not having the problem in the first place, guess what I would prefer :) There is no choice. Exiting from the guest to the kernel to userspace is prohibitively expensive, you can't do that on every packet. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
On Thu, Apr 02, 2009 at 09:46:49AM +0300, Avi Kivity wrote: > > I don't understand this. If we had good interfaces, all that userspace > would do is translate guest physical addresses to host physical > addresses, and translate the guest->host protocol to host API calls. I > don't see anything there that benefits from being in the kernel. > > Can you elaborate? I think Greg has expressed it clearly enough. At the end of the day, the numbers speak for themselves. So if and when there's a user-space version that achieves the same or better results, then I will change my mind :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Avi Kivity wrote: > > virtio is already non-kvm-specific (lguest uses it) and non-pci-specific > (s390 uses it). I think Greg's work shows that putting the backend in the kernel can dramatically reduce the cost of a single guest->host transaction. I'm sure the same thing would work for virtio too. > If you have a good exit mitigation scheme you can cut exits by a factor > of 100; so the userspace exit costs are cut by the same factor. If you > have good copyless networking APIs you can cut the cost of copies to > zero (well, to the cost of get_user_pages_fast(), but a kernel solution > needs that too). Given the choice of having to mitigate or not having the problem in the first place, guess what I would prefer :) Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Gregory Haskins wrote: I think there is a slight disconnect here. This is *exactly* what I am trying to do. You can of course do this many ways, and I am not denying it could be done a different way than the path I have chosen. One extreme would be to just slam a virtio-net specific chunk of code directly into kvm on the host. Another extreme would be to build a generic framework into Linux for declaring arbitrary IO types, integrating it with kvm (as well as other environments such as lguest, userspace, etc), and building a virtio-net model on top of that. So in case it is not obvious at this point, I have gone with the latter approach. I wanted to make sure it wasn't kvm specific or something like pci specific so it had the broadest applicability to a range of environments. So that is why the design is the way it is. I understand that this approach is technically "harder/more-complex" than the "slam virtio-net into kvm" approach, but I've already done that work. All we need to do now is agree on the details ;) virtio is already non-kvm-specific (lguest uses it) and non-pci-specific (s390 uses it). That said, I don't think we're bound today by the fact that we're in userspace. You will *always* be bound by the fact that you are in userspace. Its purely a question of "how much" and "does anyone care".Right now, the anwer is "a lot (roughly 45x slower)" and "at least Greg's customers do". I have no doubt that this can and will change/improve in the future. But it will always be true that no matter how much userspace improves, the kernel based solution will always be faster. Its simple physics. I'm cutting out the middleman to ultimately reach the same destination as the userspace path, so userspace can never be equal. If you have a good exit mitigation scheme you can cut exits by a factor of 100; so the userspace exit costs are cut by the same factor. If you have good copyless networking APIs you can cut the cost of copies to zero (well, to the cost of get_user_pages_fast(), but a kernel solution needs that too). -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Herbert Xu wrote: Anthony Liguori wrote: That said, I don't think we're bound today by the fact that we're in userspace. Rather we're bound by the interfaces we have between the host kernel and userspace to generate IO. I'd rather fix those interfaces than put more stuff in the kernel. I'm sorry but I totally disagree with that. By having our IO infrastructure in user-space we've basically given up the main advantage of kvm, which is that the physical drivers operate in the same environment as the hypervisor. I don't understand this. If we had good interfaces, all that userspace would do is translate guest physical addresses to host physical addresses, and translate the guest->host protocol to host API calls. I don't see anything there that benefits from being in the kernel. Can you elaborate? -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
* Gregory Haskins (ghask...@novell.com) wrote: > I cant think of more examples right now, but I will update this list > if/when I come up with more. I hope that satisfactorily answered your > question, though! Yes, that helps, thanks. There's still the simple issue of guest/host interface widening w/ kernel resident backend where a plain ol' bug (good that you thought about the isolation) can take out more than single guest. Always the balance... ;-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Rusty Russell wrote: > > As you point out, 350-450 is possible, which is still bad, and it's at least > partially caused by the exit to userspace and two system calls. If virtio_net > had a backend in the kernel, we'd be able to compare numbers properly. FWIW I don't really care whether we go with this or a kernel virtio_net backend. Either way should be good. However the status quo where we're stuck with a user-space backend really sucks! Thanks, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Chris Wright wrote: > >> That said, I don't think we're bound today by the fact that we're in >> userspace. Rather we're bound by the interfaces we have between the >> host kernel and userspace to generate IO. I'd rather fix those >> interfaces than put more stuff in the kernel. > > And more stuff in the kernel can come at the potential cost of weakening > protection/isolation. Protection/isolation always comes at a cost. Not everyone wants to pay that, just like health insurance :) We should enable the users to choose which model they want, based on their needs. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: > > That said, I don't think we're bound today by the fact that we're in > userspace. Rather we're bound by the interfaces we have between the > host kernel and userspace to generate IO. I'd rather fix those > interfaces than put more stuff in the kernel. I'm sorry but I totally disagree with that. By having our IO infrastructure in user-space we've basically given up the main advantage of kvm, which is that the physical drivers operate in the same environment as the hypervisor. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 00/17] virtual-bus
Anthony Liguori wrote: > Gregory Haskins wrote: >> Anthony Liguori wrote: >> I think there is a slight disconnect here. This is *exactly* what >> I am >> trying to do. > > If it were exactly what you were trying to do, you would have posted a > virtio-net in-kernel backend implementation instead of a whole new > paravirtual IO framework ;-) semantics, semantics ;) but ok, fair enough. > >>> That said, I don't think we're bound today by the fact that we're in >>> userspace. >>> >> You will *always* be bound by the fact that you are in userspace. > > Again, let's talk numbers. A heavy-weight exit is 1us slower than a > light weight exit. Ideally, you're taking < 1 exit per packet because > you're batching notifications. If you're ping latency on bare metal > compared to vbus is 39us to 65us, then all other things being equally, > the cost imposed by doing what your doing in userspace would make the > latency be 66us taking your latency from 166% of native to 169% of > native. That's not a huge difference and I'm sure you'll agree there > are a lot of opportunities to improve that even further. Ok, so lets see it happen. Consider the gauntlet thrown :) Your challenge, should you chose to accept it, is to take todays 4000us and hit a 65us latency target while maintaining 10GE line-rate (at least 1500 mtu line-rate). I personally don't want to even stop at 65. I want to hit that 36us! In case you think that is crazy, my first prototype of venet was hitting about 140us, and I shaved 10us here, 10us there, eventually getting down to the 65us we have today. The low hanging fruit is all but harvested at this point, but I am not done searching for additional sources of latency. I just needed to take a breather to get the code out there for review. :) > > And you didn't mention whether your latency tests are based on ping or > something more sophisticated Well, the numbers posted were actually from netperf -t UDP_RR. This generates a pps from a continuous (but non-bursted) RTT measurement. So I invert the pps result of this test to get the average rtt time. I have also confirmed that ping jives with these results (e.g. virtio-net results were about 4ms, and venet were about 0.065ms as reported by ping). > as ping will be a pathological case Ah, but this is not really pathological IMO. There are plenty of workloads that exhibit request-reply patterns (e.g. RPC), and this is a direct measurement of the systems ability to support these efficiently. And even unidirectional flows can be hampered by poor latency (think PTP clock sync, etc). Massive throughput with poor latency is like Andrew Tanenbaum's station-wagon full of backup tapes ;) I think I have proven we can actually get both with a little creative use of resources. > that doesn't allow any notification batching. Well, if we can take anything away from all this: I think I have demonstrated that you don't need notification batching to get good throughput. And batching on the head-end of the queue adds directly to your latency overhead, so I don't think its a good technique in general (though I realize that not everyone cares about latency, per se, so maybe most are satisfied with the status-quo). > >> I agree that the "does anyone care" part of the equation will approach >> zero as the latency difference shrinks across some threshold (probably >> the single microsecond range), but I will believe that is even possible >> when I see it ;) >> > > Note the other hat we have to where is not just virtualization > developer but Linux developer. If there are bad userspace interfaces > for IO that impose artificial restrictions, then we need to identify > those and fix them. Fair enough, and I would love to take that on but alas my development/debug bandwidth is rather finite these days ;) -Greg signature.asc Description: OpenPGP digital signature