Source-Changes-HG archive

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

[src/trunk]: src/sys change b_wapbllist to TAILQ, to preserve the LRU order



details:   https://anonhg.NetBSD.org/src/rev/442e604da80a
branches:  trunk
changeset: 352614:442e604da80a
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 10 19:52:38 2017 +0000

description:
change b_wapbllist to TAILQ, to preserve the LRU order

diffstat:

 sys/kern/vfs_wapbl.c |  38 ++++++++++++++++++--------------------
 sys/sys/buf.h        |   4 ++--
 sys/sys/param.h      |   4 ++--
 3 files changed, 22 insertions(+), 24 deletions(-)

diffs (180 lines):

diff -r f722320b25ef -r 442e604da80a sys/kern/vfs_wapbl.c
--- a/sys/kern/vfs_wapbl.c      Mon Apr 10 19:49:39 2017 +0000
+++ b/sys/kern/vfs_wapbl.c      Mon Apr 10 19:52:38 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_wapbl.c,v 1.93 2017/04/05 20:38:53 jdolecek Exp $  */
+/*     $NetBSD: vfs_wapbl.c,v 1.94 2017/04/10 19:52:38 jdolecek Exp $  */
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.93 2017/04/05 20:38:53 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.94 2017/04/10 19:52:38 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -199,7 +199,7 @@
        size_t wl_bufcount;     /* m:   Count of buffers in wl_bufs */
        size_t wl_bcount;       /* m:   Total bcount of wl_bufs */
 
-       LIST_HEAD(, buf) wl_bufs; /* m: Buffers in current transaction */
+       TAILQ_HEAD(, buf) wl_bufs; /* m: Buffers in current transaction */
 
        kcondvar_t wl_reclaimable_cv;   /* m (obviously) */
        size_t wl_reclaimable_bytes; /* m:      Amount of space available for
@@ -542,7 +542,7 @@
        rw_init(&wl->wl_rwlock);
        mutex_init(&wl->wl_mtx, MUTEX_DEFAULT, IPL_NONE);
        cv_init(&wl->wl_reclaimable_cv, "wapblrec");
-       LIST_INIT(&wl->wl_bufs);
+       TAILQ_INIT(&wl->wl_bufs);
        SIMPLEQ_INIT(&wl->wl_entries);
 
        wl->wl_logvp = vp;
@@ -750,7 +750,7 @@
         */
        mutex_enter(&bufcache_lock);
        mutex_enter(&wl->wl_mtx);
-       while ((bp = LIST_FIRST(&wl->wl_bufs)) != NULL) {
+       while ((bp = TAILQ_FIRST(&wl->wl_bufs)) != NULL) {
                if (bbusy(bp, 0, 0, &wl->wl_mtx) == 0) {
                        /*
                         * The buffer will be unlocked and
@@ -791,7 +791,7 @@
        KASSERT(wl->wl_bufbytes == 0);
        KASSERT(wl->wl_bcount == 0);
        KASSERT(wl->wl_bufcount == 0);
-       KASSERT(LIST_EMPTY(&wl->wl_bufs));
+       KASSERT(TAILQ_EMPTY(&wl->wl_bufs));
        KASSERT(SIMPLEQ_EMPTY(&wl->wl_entries));
        KASSERT(wl->wl_inohashcnt == 0);
        KASSERT(TAILQ_EMPTY(&wl->wl_dealloclist));
@@ -826,7 +826,7 @@
        KASSERT(wl->wl_bufbytes == 0);
        KASSERT(wl->wl_bcount == 0);
        KASSERT(wl->wl_bufcount == 0);
-       KASSERT(LIST_EMPTY(&wl->wl_bufs));
+       KASSERT(TAILQ_EMPTY(&wl->wl_bufs));
        KASSERT(wl->wl_dealloccnt == 0);
        KASSERT(SIMPLEQ_EMPTY(&wl->wl_entries));
        KASSERT(wl->wl_inohashcnt == 0);
@@ -1180,7 +1180,7 @@
 
        mutex_enter(&wl->wl_mtx);
        if (bp->b_flags & B_LOCKED) {
-               LIST_REMOVE(bp, b_wapbllist);
+               TAILQ_REMOVE(&wl->wl_bufs, bp, b_wapbllist);
                WAPBL_PRINTF(WAPBL_PRINT_BUFFER2,
                   ("wapbl_add_buf thread %d.%d re-adding buf %p "
                    "with %d bytes %d bcount\n",
@@ -1198,7 +1198,7 @@
                    curproc->p_pid, curlwp->l_lid, bp, bp->b_bufsize,
                    bp->b_bcount));
        }
-       LIST_INSERT_HEAD(&wl->wl_bufs, bp, b_wapbllist);
+       TAILQ_INSERT_TAIL(&wl->wl_bufs, bp, b_wapbllist);
        mutex_exit(&wl->wl_mtx);
 
        bp->b_flags |= B_LOCKED;
@@ -1236,7 +1236,7 @@
        wl->wl_bufcount--;
        KASSERT((wl->wl_bufcount == 0) == (wl->wl_bufbytes == 0));
        KASSERT((wl->wl_bufcount == 0) == (wl->wl_bcount == 0));
-       LIST_REMOVE(bp, b_wapbllist);
+       TAILQ_REMOVE(&wl->wl_bufs, bp, b_wapbllist);
 
        bp->b_flags &= ~B_LOCKED;
 }
@@ -1799,12 +1799,10 @@
        SIMPLEQ_INSERT_TAIL(&wl->wl_entries, we, we_entries);
 
        /*
-        * this flushes bufs in reverse order than they were queued
-        * it shouldn't matter, but if we care we could use TAILQ instead.
-        * XXX Note they will get put on the lru queue when they flush
-        * so we might actually want to change this to preserve order.
+        * This flushes bufs in order than they were queued, so the LRU
+        * order is preserved.
         */
-       while ((bp = LIST_FIRST(&wl->wl_bufs)) != NULL) {
+       while ((bp = TAILQ_FIRST(&wl->wl_bufs)) != NULL) {
                if (bbusy(bp, 0, 0, &wl->wl_mtx)) {
                        continue;
                }
@@ -1969,8 +1967,8 @@
        if (full) {
                int cnt = 0;
                (*pr)("bufs =");
-               LIST_FOREACH(bp, &wl->wl_bufs, b_wapbllist) {
-                       if (!LIST_NEXT(bp, b_wapbllist)) {
+               TAILQ_FOREACH(bp, &wl->wl_bufs, b_wapbllist) {
+                       if (!TAILQ_NEXT(bp, b_wapbllist)) {
                                (*pr)(" %p", bp);
                        } else if ((++cnt % 6) == 0) {
                                (*pr)(" %p,\n\t", bp);
@@ -2406,7 +2404,7 @@
 
        KASSERT(rw_write_held(&wl->wl_rwlock));
 
-       bp = LIST_FIRST(&wl->wl_bufs);
+       bp = TAILQ_FIRST(&wl->wl_bufs);
 
        while (bp) {
                int cnt;
@@ -2438,7 +2436,7 @@
                        wc->wc_blocks[wc->wc_blkcount].wc_dlen = bp->b_bcount;
                        wc->wc_len += bp->b_bcount;
                        wc->wc_blkcount++;
-                       bp = LIST_NEXT(bp, b_wapbllist);
+                       bp = TAILQ_NEXT(bp, b_wapbllist);
                }
                if (wc->wc_len % blocklen != 0) {
                        padding = blocklen - wc->wc_len % blocklen;
@@ -2461,7 +2459,7 @@
                            bp->b_bcount, &off);
                        if (error)
                                return error;
-                       bp = LIST_NEXT(bp, b_wapbllist);
+                       bp = TAILQ_NEXT(bp, b_wapbllist);
                }
                if (padding) {
                        void *zero;
diff -r f722320b25ef -r 442e604da80a sys/sys/buf.h
--- a/sys/sys/buf.h     Mon Apr 10 19:49:39 2017 +0000
+++ b/sys/sys/buf.h     Mon Apr 10 19:52:38 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.h,v 1.127 2017/04/05 20:15:49 jdolecek Exp $ */
+/*     $NetBSD: buf.h,v 1.128 2017/04/10 19:52:38 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc.
@@ -153,7 +153,7 @@
        LIST_ENTRY(buf)         b_hash;         /* c: hash chain */
        LIST_ENTRY(buf)         b_vnbufs;       /* c: associated vnode */
        TAILQ_ENTRY(buf)        b_freelist;     /* c: position if not active */
-       LIST_ENTRY(buf)         b_wapbllist;    /* c: transaction buffer list */
+       TAILQ_ENTRY(buf)        b_wapbllist;    /* c: transaction buffer list */
        daddr_t                 b_lblkno;       /* c: logical block number */
        int                     b_freelistindex;/* c: free list index (BQ_) */
        u_int                   b_cflags;       /* c: BC_* flags */
diff -r f722320b25ef -r 442e604da80a sys/sys/param.h
--- a/sys/sys/param.h   Mon Apr 10 19:49:39 2017 +0000
+++ b/sys/sys/param.h   Mon Apr 10 19:52:38 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: param.h,v 1.534 2017/03/30 09:16:53 hannken Exp $      */
+/*     $NetBSD: param.h,v 1.535 2017/04/10 19:52:38 jdolecek Exp $     */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *     2.99.9          (299000900)
  */
 
-#define        __NetBSD_Version__      799006700       /* NetBSD 7.99.67 */
+#define        __NetBSD_Version__      799006800       /* NetBSD 7.99.68 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)



Home | Main Index | Thread Index | Old Index