Skip to contentSkip to conversation

xen: add persistent grants to xbd_xenbus

PATCH Manuel Bouyer 3 participants 7 messages Nov 10, 2012 – Nov 13, 2012 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 26 lines · Roger Pau Monne

This patch implements persistent grants for xbd_xenbus (blkfront in Linux terminology). The effect of this change is to reduce the number of unmap operations performed, since they cause a (costly) TLB shootdown. This allows the I/O performance to scale better when a large number of VMs are performing I/O.

On startup xbd_xenbus notifies the backend driver that it is using persistent grants. If the backend driver is not capable of persistent mapping, xbd_xenbus will still use the same grants, since it is compatible with the previous protocol, and simplifies the code complexity in xbd_xenbus.

Each time a request is send to the backend driver, xbd_xenbus will check if there are free grants already mapped and will try to use one of those. If there are not enough grants already mapped, xbd_xenbus will request new grants, and they will be added to the list of free grants when the transaction is finished, so they can be reused. Data has to be copied from the request (struct buf) to the mapped grant, or from the mapped grant to the request, depending on the operation being performed.

To test the performance impact of this patch I've benchmarked the number of IOPS performed simultaneously by 15 NetBSD DomU guests on a Linux Dom0 that supports persistent grants. The backend used to perform this tests was a ramdisk of size 1GB.

Quoted 8 lines

Sum of IOPS
Non-persistent 336718
Persistent 686010

As seen, there's a x2 increase in the total number of IOPS being performed. As a reference, using exactly the same setup Linux DomUs are able to achieve 1102019 IOPS, so there's still plenty of room for improvement.

I'd like to see a similar test run against a NetBSD dom0. Also, how big are your IOPs ?

Signature · 3 lines
Manuel Bouyer <[email protected]>
     NetBSD: 26 ans d'experience feront toujours la difference
--

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 31 lines · Manuel Bouyer
Quoted 30 lines · Roger Pau Monne

This patch implements persistent grants for xbd_xenbus (blkfront in Linux terminology). The effect of this change is to reduce the number of unmap operations performed, since they cause a (costly) TLB shootdown. This allows the I/O performance to scale better when a large number of VMs are performing I/O.

On startup xbd_xenbus notifies the backend driver that it is using persistent grants. If the backend driver is not capable of persistent mapping, xbd_xenbus will still use the same grants, since it is compatible with the previous protocol, and simplifies the code complexity in xbd_xenbus.

Each time a request is send to the backend driver, xbd_xenbus will check if there are free grants already mapped and will try to use one of those. If there are not enough grants already mapped, xbd_xenbus will request new grants, and they will be added to the list of free grants when the transaction is finished, so they can be reused. Data has to be copied from the request (struct buf) to the mapped grant, or from the mapped grant to the request, depending on the operation being performed.

To test the performance impact of this patch I've benchmarked the number of IOPS performed simultaneously by 15 NetBSD DomU guests on a Linux Dom0 that supports persistent grants. The backend used to perform this tests was a ramdisk of size 1GB.

Sum of IOPS
Non-persistent 336718
Persistent 686010

Quoted 7 lines
Quoted 4 lines

As seen, there's a x2 increase in the total number of IOPS being performed. As a reference, using exactly the same setup Linux DomUs are able to achieve 1102019 IOPS, so there's still plenty of room for improvement.

I'd like to see a similar test run against a NetBSD dom0. Also, how big are your IOPs ?

I will try to perform a similar test with a NetBSD Dom0, but with the patch it will probably be a little bit slower than without it (because we have to perform the memcpy in the frontend, but anyway NetBSD block frontend was also performing a memcpy if the memory region was not aligned to PAGE_SIZE).

I have to check, but I belive NetBSD Dom0 will not benefit from persistent grants in the backend driver, because it is limited to only one vcpu, and my guess is that with only one vcpu the TLB flush will be faster than the memcpy (anyway I need to actually check this).

The test was performed with fio, using the following configuration:

[read]
rw=read
size=900m
bs=4k
filename=/foo/bar

Where /foo/bar is the mountpoint of a disk backed with a ramdisk on the Dom0, the filesystem is FFSv2 without WAPL and default blocksize. Block size used on the test is 4k, the test was performed 3 times and averaged.

Roger.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 4 lines · Roger Pau Monné

I will try to perform a similar test with a NetBSD Dom0, but with the patch it will probably be a little bit slower than without it (because we have to perform the memcpy in the frontend,

Doesn't the frontend fallback to the same old code as always if the b/e doesn't advertise the new feature?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monné

I will try to perform a similar test with a NetBSD Dom0, but with the patch it will probably be a little bit slower than without it (because we have to perform the memcpy in the frontend,

Doesn't the frontend fallback to the same old code as always if the b/e doesn't advertise the new feature?

No, the frontend always uses persistent grants, since it's compatible with a backend not using persistent grants, the frontend will reuse the same grants, and the backend will use the old mechanism of mapping and unmapping them.

Actually it seems I was wrong on that, using a persistent frontend with a non-persistent backend lets to a more consistent performance, see the following graph:

http://xenbits.xen.org/people/royger/persistent_grants/nonpers_read.png

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw
In reply to a message not in the archive
Quoted 31 lines · Manuel Bouyer
Quoted 30 lines · Roger Pau Monne

This patch implements persistent grants for xbd_xenbus (blkfront in Linux terminology). The effect of this change is to reduce the number of unmap operations performed, since they cause a (costly) TLB shootdown. This allows the I/O performance to scale better when a large number of VMs are performing I/O.

On startup xbd_xenbus notifies the backend driver that it is using persistent grants. If the backend driver is not capable of persistent mapping, xbd_xenbus will still use the same grants, since it is compatible with the previous protocol, and simplifies the code complexity in xbd_xenbus.

Each time a request is send to the backend driver, xbd_xenbus will check if there are free grants already mapped and will try to use one of those. If there are not enough grants already mapped, xbd_xenbus will request new grants, and they will be added to the list of free grants when the transaction is finished, so they can be reused. Data has to be copied from the request (struct buf) to the mapped grant, or from the mapped grant to the request, depending on the operation being performed.

To test the performance impact of this patch I've benchmarked the number of IOPS performed simultaneously by 15 NetBSD DomU guests on a Linux Dom0 that supports persistent grants. The backend used to perform this tests was a ramdisk of size 1GB.

Sum of IOPS
Non-persistent 336718
Persistent 686010

Quoted 7 lines
Quoted 4 lines

As seen, there's a x2 increase in the total number of IOPS being performed. As a reference, using exactly the same setup Linux DomUs are able to achieve 1102019 IOPS, so there's still plenty of room for improvement.

I'd like to see a similar test run against a NetBSD dom0. Also, how big are your IOPs ?

I've run some test on a NetBSD Dom0, but it is not a big box, it only has 8-ways. I've run 7 NetBSD DomUs on a NetBSD Dom0, and here are the results (again using a block size of 4k and a md based backend):

Persistent frontend: 297688 IOPS
Non-persistent frontend: 326497 IOPS

This is consistent with the Linux graph on
http://xenbits.xen.org/people/royger/persistent_grants/nonpers_read.png,
which shows that there's a performance improvement when using at least 8 guests or more. I will also work on a persistent implementation for NetBSD xbd backend, but I don't think it's going to make a difference until we get a MP Dom0 (so it might be better to work on getting a MP Dom0 first).

Roger.

#8 lore raw
In reply to a message not in the archive

Review xbd_connect(struct xbd_xenbus_softc *sc) · line 696

Quoted 12 lines · Roger Pau Monne
(quoted diff) +8 -0
@@ -652,6 +686,15 @@ xbd_connect(struct xbd_xenbus_softc *sc)
        else
                sc->sc_cache_flush = 0;
 
+       err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
+           "feature-persistent", &feature_persistent, 10);
+       if (err)
+               feature_persistent = 0;
+       if (feature_persistent > 0)
+               sc->sc_persistent_grants = 1;
+       else
+               sc->sc_persistent_grants = 0;

I can't find anywhere which reads sc->sc_persistent_grants?

Ian.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Roger Pau Monne
(quoted diff) +0 -0
@@ -652,6 +686,15 @@ xbd_connect(struct xbd_xenbus_softc *sc)
        else
                sc->sc_cache_flush = 0;
 
Quoted 10 lines

Review xbd_connect(struct xbd_xenbus_softc *sc) · line 696

Quoted 8 lines
(quoted diff) +8 -0
+       err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
+           "feature-persistent", &feature_persistent, 10);
+       if (err)
+               feature_persistent = 0;
+       if (feature_persistent > 0)
+               sc->sc_persistent_grants = 1;
+       else
+               sc->sc_persistent_grants = 0;

I can't find anywhere which reads sc->sc_persistent_grants?

I've added this to be used for debugging mainly, but I think we should probably print it, to know if the backend supports persistent grants or not (like the Linux kernel does).