Source-Changes-HG archive

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

[src/trunk]: src/sys/kern If we're only doing a count-only kern.buf sysctl, j...



details:   https://anonhg.NetBSD.org/src/rev/6c1590b1c76d
branches:  trunk
changeset: 984826:6c1590b1c76d
user:      simonb <simonb%NetBSD.org@localhost>
date:      Sun Jul 25 06:06:40 2021 +0000

description:
If we're only doing a count-only kern.buf sysctl, just return the number
of active members in the pool cache (plus some slop) instead of looking
in all the free buffer list.  Should reduce CPU usage for "systat vm"
to << 1% especially for machines with a larger number of buffers.

diffstat:

 sys/kern/vfs_bio.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 3e8d0b910fda -r 6c1590b1c76d sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Sun Jul 25 06:04:40 2021 +0000
+++ b/sys/kern/vfs_bio.c        Sun Jul 25 06:06:40 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.300 2021/07/24 13:28:14 simonb Exp $     */
+/*     $NetBSD: vfs_bio.c,v 1.301 2021/07/25 06:06:40 simonb Exp $     */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.300 2021/07/24 13:28:14 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.301 2021/07/25 06:06:40 simonb Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -1804,6 +1804,14 @@
            elem_size < 1 || elem_count < 0)
                return (EINVAL);
 
+       if (oldp == NULL) {
+               /* count only, don't run through the buffer queues */
+               needed = pool_cache_nget(buf_cache) - pool_cache_nput(buf_cache);
+               *oldlenp = (needed + KERN_BUFSLOP) * elem_size;
+
+               return 0;
+       }
+
        error = 0;
        needed = 0;
        sysctl_unlock();
@@ -1848,8 +1856,6 @@
        sysctl_relock();
 
        *oldlenp = needed;
-       if (oldp == NULL)
-               *oldlenp += KERN_BUFSLOP * elem_size;
 
        return (error);
 }



Home | Main Index | Thread Index | Old Index