Source-Changes-HG archive

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

[src/trunk]: src move and rename the uvm history code out of uvm_stat to "ker...



details:   https://anonhg.NetBSD.org/src/rev/9030a95d2770
branches:  trunk
changeset: 765041:9030a95d2770
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue May 17 04:18:05 2011 +0000

description:
move and rename the uvm history code out of uvm_stat to "kernhist".

rename "UVMHIST" option to enable the uvm histories.

TODO:
- make UVMHIST properly depend upon KERNHIST
- enable dynamic registration of histories.  this is mostly just
  allocating something in a bitmap, and is only for viewing multiple
  histories in a merged form.


tested on amd64 and sparc64.

diffstat:

 sys/arch/sparc64/conf/GENERIC |    6 +-
 sys/conf/files                |    9 +-
 sys/ddb/db_command.c          |   21 ++--
 sys/dev/ic/sl811hs.c          |   49 +++++----
 sys/kern/kern_history.c       |  191 ++++++++++++++++++++++++++++++++++++++++
 sys/sys/kernhist.h            |  199 ++++++++++++++++++++++++++++++++++++++++++
 sys/uvm/uvm.h                 |    4 +-
 sys/uvm/uvm_ddb.h             |    3 +-
 sys/uvm/uvm_map.c             |    8 +-
 sys/uvm/uvm_stat.c            |  153 +-------------------------------
 sys/uvm/uvm_stat.h            |  181 ++++++-------------------------------
 usr.bin/vmstat/vmstat.c       |   37 ++++---
 12 files changed, 499 insertions(+), 362 deletions(-)

diffs (truncated from 1211 to 300 lines):

diff -r 7f949d8d1a37 -r 9030a95d2770 sys/arch/sparc64/conf/GENERIC
--- a/sys/arch/sparc64/conf/GENERIC     Tue May 17 03:35:38 2011 +0000
+++ b/sys/arch/sparc64/conf/GENERIC     Tue May 17 04:18:05 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.137 2011/05/12 07:06:00 mrg Exp $
+# $NetBSD: GENERIC,v 1.138 2011/05/17 04:18:05 mrg Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.137 $"
+#ident                 "GENERIC-$Revision: 1.138 $"
 
 maxusers       64
 
@@ -99,7 +99,7 @@
 ## Compile the kernel with debugging symbols (`netbsd.gdb' is the debug file),
 ## such that gdb(1) can be used on a kernel coredump.
 
-#makeoptions   DEBUG="-g"
+makeoptions    DEBUG="-g"
 
 
 ## Adds code to the kernel that does internal consistency checks, and will
diff -r 7f949d8d1a37 -r 9030a95d2770 sys/conf/files
--- a/sys/conf/files    Tue May 17 03:35:38 2011 +0000
+++ b/sys/conf/files    Tue May 17 04:18:05 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1011 2011/05/05 17:38:35 drochner Exp $
+#      $NetBSD: files,v 1.1012 2011/05/17 04:18:06 mrg Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -1384,6 +1384,13 @@
 include "uvm/files.uvm"
 
 #
+# Kernel history/tracing. Old UVMHIST depends upon this.
+# XXXMRG can't make UVMHIST depend properly on KERNHIST?
+#
+defflag opt_kernhist.h                 KERNHIST KERNHIST_PRINT
+file   kern/kern_history.c             kernhist
+
+#
 # Security models
 #
 include "secmodel/files.secmodel"
diff -r 7f949d8d1a37 -r 9030a95d2770 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Tue May 17 03:35:38 2011 +0000
+++ b/sys/ddb/db_command.c      Tue May 17 04:18:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.135 2011/04/10 20:59:22 christos Exp $        */
+/*     $NetBSD: db_command.c,v 1.136 2011/05/17 04:18:06 mrg Exp $     */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.135 2011/04/10 20:59:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.136 2011/05/17 04:18:06 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -68,7 +68,7 @@
 #include "opt_kgdb.h"
 #include "opt_mqueue.h"
 #include "opt_inet.h"
-#include "opt_uvmhist.h"
+#include "opt_kernhist.h"
 #include "opt_ddbparam.h"
 #include "opt_multiprocessor.h"
 #include "arp.h"
@@ -90,6 +90,7 @@
 #include <sys/cpu.h>
 #include <sys/buf.h>
 #include <sys/module.h>
+#include <sys/kernhist.h>
 
 /*include queue macros*/
 #include <sys/queue.h>
@@ -205,8 +206,8 @@
 static void    db_sync_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_whatis_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_uvmexp_print_cmd(db_expr_t, bool, db_expr_t, const char *);
-#ifdef UVMHIST
-static void    db_uvmhist_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+#ifdef KERNHIST
+static void    db_kernhist_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 #endif
 static void    db_vnode_print_cmd(db_expr_t, bool, db_expr_t, const char *);
 static void    db_vmem_print_cmd(db_expr_t, bool, db_expr_t, const char *);
@@ -276,8 +277,8 @@
        { DDB_ADD_CMD("uvmexp", db_uvmexp_print_cmd, 0,
            "Print a selection of UVM counters and statistics.",
            NULL,NULL) },
-#ifdef UVMHIST
-       { DDB_ADD_CMD("uvmhist", db_uvmhist_print_cmd, 0,
+#ifdef KERNHIST
+       { DDB_ADD_CMD("kernhist", db_kernhist_print_cmd, 0,
            "Print the UVM history logs.",
            NULL,NULL) },
 #endif
@@ -1197,14 +1198,14 @@
 #endif
 }
 
-#ifdef UVMHIST
+#ifdef KERNHIST
 /*ARGSUSED*/
 static void
-db_uvmhist_print_cmd(db_expr_t addr, bool have_addr,
+db_kernhist_print_cmd(db_expr_t addr, bool have_addr,
     db_expr_t count, const char *modif)
 {
 
-       uvmhist_print(db_printf);
+       kernhist_print(db_printf);
 }
 #endif
 
diff -r 7f949d8d1a37 -r 9030a95d2770 sys/dev/ic/sl811hs.c
--- a/sys/dev/ic/sl811hs.c      Tue May 17 03:35:38 2011 +0000
+++ b/sys/dev/ic/sl811hs.c      Tue May 17 04:18:05 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sl811hs.c,v 1.27 2011/03/13 05:26:14 kiyohara Exp $    */
+/*     $NetBSD: sl811hs.c,v 1.28 2011/05/17 04:18:06 mrg Exp $ */
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.27 2011/03/13 05:26:14 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.28 2011/05/17 04:18:06 mrg Exp $");
 
 #include "opt_slhci.h"
 
@@ -561,35 +561,42 @@
 int slhci_usbdebug = -1; /* value to set usbdebug on attach, -1 = leave alone */
 #endif
 
-/* Add UVMHIST history for debugging: 
+/*
+ * XXXMRG the SLHCI UVMHIST code has been converted to KERNHIST, but it has
+ * not been tested.  the extra instructions to enable it can probably be
+ * commited to the kernhist code, and these instructions reduced to simply
+ * enabling SLHCI_DEBUG.
+ */
+
+/* Add KERNHIST history for debugging: 
  *
- *   Before uvm_hist in sys/uvm/uvm_stat.c add:
- *      UVMHIST_DECL(slhcihist);
+ *   Before kern_hist in sys/kern/subr_kernhist.c add:
+ *      KERNHIST_DECL(slhcihist);
  *
- *   In uvm_hist add:
- *      if ((bitmask & UVMHIST_SLHCI))
+ *   In kern_hist add:
+ *      if ((bitmask & KERNHIST_SLHCI))
  *              hists[i++] = &slhcihist;
  *
- *   In sys/uvm/uvm_stat.h add UVMHIST_SLHCI define.
+ *   In sys/sys/kernhist.h add KERNHIST_SLHCI define.
  */
 
-#include <uvm/uvm_stat.h>
-UVMHIST_DECL(slhcihist);
-
-#if !defined(UVMHIST) || !defined(UVMHIST_SLHCI)
-#error "SLHCI_DEBUG requires UVMHIST (with modifications, see sys/dev/ic/sl81hs.c)"
+#include <sys/kernhist.h>
+KERNHIST_DECL(slhcihist);
+
+#if !defined(KERNHIST) || !defined(KERNHIST_SLHCI)
+#error "SLHCI_DEBUG requires KERNHIST (with modifications, see sys/dev/ic/sl81hs.c)"
 #endif
 
 #ifndef SLHCI_NHIST
 #define SLHCI_NHIST 409600
 #endif
-const unsigned int SLHCI_HISTMASK = UVMHIST_SLHCI;
-struct uvm_history_ent slhci_he[SLHCI_NHIST];
+const unsigned int SLHCI_HISTMASK = KERNHIST_SLHCI;
+struct kern_history_ent slhci_he[SLHCI_NHIST];
 
 #define SLHCI_DEXEC(x, y) do { if ((slhci_debug & SLHCI_ ## x)) { y; } \
 } while (/*CONSTCOND*/ 0)
-#define DDOLOG(f, a, b, c, d) do { const char *_uvmhist_name = __func__; \
-    u_long _uvmhist_call = 0; UVMHIST_LOG(slhcihist, f, a, b, c, d);        \
+#define DDOLOG(f, a, b, c, d) do { const char *_kernhist_name = __func__; \
+    u_long _kernhist_call = 0; KERNHIST_LOG(slhcihist, f, a, b, c, d);      \
 } while (/*CONSTCOND*/0)
 #define DLOG(x, f, a, b, c, d) SLHCI_DEXEC(x, DDOLOG(f, a, b, c, d))
 /* DLOGFLAG8 is a macro not a function so that flag name expressions are not 
@@ -597,10 +604,10 @@
  * x is debug mask, y is flag identifier, z is flag variable, 
  * a-h are flag names (must evaluate to string constants, msb first). */
 #define DDOLOGFLAG8(y, z, a, b, c, d, e, f, g, h) do { uint8_t _DLF8 = (z);   \
-    const char *_uvmhist_name = __func__; u_long _uvmhist_call = 0;          \
-    if (_DLF8 & 0xf0) UVMHIST_LOG(slhcihist, y " %s %s %s %s", _DLF8 & 0x80 ?  \
+    const char *_kernhist_name = __func__; u_long _kernhist_call = 0;        \
+    if (_DLF8 & 0xf0) KERNHIST_LOG(slhcihist, y " %s %s %s %s", _DLF8 & 0x80 ?  \
     (a) : "", _DLF8 & 0x40 ? (b) : "", _DLF8 & 0x20 ? (c) : "", _DLF8 & 0x10 ? \
-    (d) : ""); if (_DLF8 & 0x0f) UVMHIST_LOG(slhcihist, y " %s %s %s %s",      \
+    (d) : ""); if (_DLF8 & 0x0f) KERNHIST_LOG(slhcihist, y " %s %s %s %s",      \
     _DLF8 & 0x08 ? (e) : "", _DLF8 & 0x04 ? (f) : "", _DLF8 & 0x02 ? (g) : "", \
     _DLF8 & 0x01 ? (h) : "");                                                 \
 } while (/*CONSTCOND*/ 0)
@@ -1143,7 +1150,7 @@
        t = &sc->sc_transfers;
 
 #ifdef SLHCI_DEBUG
-       UVMHIST_INIT_STATIC(slhcihist, slhci_he);
+       KERNHIST_INIT_STATIC(slhcihist, slhci_he);
 #endif
        simple_lock_init(&sc->sc_lock);
 #ifdef SLHCI_WAITLOCK
diff -r 7f949d8d1a37 -r 9030a95d2770 sys/kern/kern_history.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/kern/kern_history.c   Tue May 17 04:18:05 2011 +0000
@@ -0,0 +1,191 @@
+/*     $NetBSD: kern_history.c,v 1.1 2011/05/17 04:18:06 mrg Exp $      */
+
+/*
+ * Copyright (c) 1997 Charles D. Cranor and Washington University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * from: NetBSD: uvm_stat.c,v 1.36 2011/02/02 15:13:34 chuck Exp
+ * from: Id: uvm_stat.c,v 1.1.2.3 1997/12/19 15:01:00 mrg Exp
+ */
+
+/*
+ * subr_kernhist.c
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: kern_history.c,v 1.1 2011/05/17 04:18:06 mrg Exp $");
+
+#include "opt_kernhist.h"
+#include "opt_uvmhist.h"
+#include "opt_ddb.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/cpu.h>
+#include <sys/kernhist.h>
+
+#include <uvm/uvm.h>
+
+/*
+ * globals
+ */
+
+struct kern_history_head kern_histories;
+
+int kernhist_print_enabled = 1;
+
+#ifdef DDB
+
+/*
+ * prototypes
+ */
+
+void kernhist_dump(struct kern_history *);
+void kernhist_dumpmask(u_int32_t);
+static void kernhist_dump_histories(struct kern_history *[]);
+
+
+/*
+ * call this from ddb
+ *
+ * expects the system to be quiesced, no locking
+ */



Home | Main Index | Thread Index | Old Index