Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Poor disk performance in NetBSD DomU, again



Hello,
the attached patch may help.
What happens is that, even through the pagedaemon sends ordered
write requests, dk_start() will probably dequeue and requeue them in a
different order. This causes the underlying device to see out of order
write requests and this seems to make a big difference for some devices.

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: dksubr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/dksubr.c,v
retrieving revision 1.42
diff -u -p -u -r1.42 dksubr.c
--- dksubr.c    19 Nov 2010 06:44:39 -0000      1.42
+++ dksubr.c    19 May 2014 18:12:44 -0000
@@ -234,10 +240,21 @@ dk_start(struct dk_intf *di, struct dk_s
 
        DPRINTF_FOLLOW(("dk_start(%s, %p)\n", di->di_dkname, dksc));
 
+       /* first see if there's a buf waiting for ressources */
+       if (dksc->sc_nextbufp != NULL) {
+               if (di->di_diskstart(dksc, dksc->sc_nextbufp) != 0) {
+                       /* still no ressources, just return */
+                       return;
+               }
+       }
+       dksc->sc_nextbufp = NULL; /* it has been queued now */
+
        /* Process the work queue */
        while ((bp = bufq_get(dksc->sc_bufq)) != NULL) {
                if (di->di_diskstart(dksc, bp) != 0) {
-                       bufq_put(dksc->sc_bufq, bp);
+                       KASSERT(dksc->sc_nextbufp == NULL);
+                       /* try bp again later */
+                       dksc->sc_nextbufp = bp;
                        break;
                }
        }
Index: dkvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/dkvar.h,v
retrieving revision 1.15
diff -u -p -u -r1.15 dkvar.h
--- dkvar.h     19 Nov 2010 06:44:39 -0000      1.15
+++ dkvar.h     19 May 2014 18:12:44 -0000
@@ -56,6 +56,7 @@ struct dk_softc {
        char                     sc_xname[DK_XNAME_SIZE]; /* external name */
        struct disk              sc_dkdev;      /* generic disk info */
        struct bufq_state       *sc_bufq;       /* buffer queue */
+       struct buf              *sc_nextbufp;   /* buf waiting for ressources */
 };
 
 /* sc_flags:


Home | Main Index | Thread Index | Old Index