Source-Changes-HG archive

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

[src/netbsd-8]: src Pull up following revision(s) (requested by pgoyette in t...



details:   https://anonhg.NetBSD.org/src/rev/c7dc4ac18051
branches:  netbsd-8
changeset: 434370:c7dc4ac18051
user:      snj <snj%NetBSD.org@localhost>
date:      Thu Nov 02 21:29:51 2017 +0000

description:
Pull up following revision(s) (requested by pgoyette in ticket #335):
        share/man/man9/kernhist.9: 1.5-1.8
        sys/arch/acorn26/acorn26/pmap.c: 1.39
        sys/arch/arm/arm32/fault.c: 1.105 via patch
        sys/arch/arm/arm32/pmap.c: 1.350, 1.359
        sys/arch/arm/broadcom/bcm2835_bsc.c: 1.7
        sys/arch/arm/omap/if_cpsw.c: 1.20
        sys/arch/arm/omap/tiotg.c: 1.7
        sys/arch/evbarm/conf/RPI2_INSTALL: 1.3
        sys/dev/ic/sl811hs.c: 1.98
        sys/dev/usb/ehci.c: 1.256
        sys/dev/usb/if_axe.c: 1.83
        sys/dev/usb/motg.c: 1.18
        sys/dev/usb/ohci.c: 1.274
        sys/dev/usb/ucom.c: 1.119
        sys/dev/usb/uhci.c: 1.277
        sys/dev/usb/uhub.c: 1.137
        sys/dev/usb/umass.c: 1.160-1.162
        sys/dev/usb/umass_quirks.c: 1.100
        sys/dev/usb/umass_scsipi.c: 1.55
        sys/dev/usb/usb.c: 1.168
        sys/dev/usb/usb_mem.c: 1.70
        sys/dev/usb/usb_subr.c: 1.221
        sys/dev/usb/usbdi.c: 1.175
        sys/dev/usb/usbdi_util.c: 1.67-1.70
        sys/dev/usb/usbroothub.c: 1.3
        sys/dev/usb/xhci.c: 1.75
        sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: 1.34
        sys/kern/kern_history.c: 1.15
        sys/kern/kern_xxx.c: 1.74
        sys/kern/vfs_bio.c: 1.275-1.276
        sys/miscfs/genfs/genfs_io.c: 1.71
        sys/sys/kernhist.h: 1.21
        sys/ufs/ffs/ffs_balloc.c: 1.63
        sys/ufs/lfs/lfs_vfsops.c: 1.361
        sys/ufs/lfs/ulfs_inode.c: 1.21
        sys/ufs/lfs/ulfs_vnops.c: 1.52
        sys/ufs/ufs/ufs_inode.c: 1.102
        sys/ufs/ufs/ufs_vnops.c: 1.239
        sys/uvm/pmap/pmap.c: 1.37-1.39
        sys/uvm/pmap/pmap_tlb.c: 1.22
        sys/uvm/uvm_amap.c: 1.108
        sys/uvm/uvm_anon.c: 1.64
        sys/uvm/uvm_aobj.c: 1.126
        sys/uvm/uvm_bio.c: 1.91
        sys/uvm/uvm_device.c: 1.66
        sys/uvm/uvm_fault.c: 1.201
        sys/uvm/uvm_km.c: 1.144
        sys/uvm/uvm_loan.c: 1.85
        sys/uvm/uvm_map.c: 1.353
        sys/uvm/uvm_page.c: 1.194
        sys/uvm/uvm_pager.c: 1.111
        sys/uvm/uvm_pdaemon.c: 1.109
        sys/uvm/uvm_swap.c: 1.175
        sys/uvm/uvm_vnode.c: 1.103
        usr.bin/vmstat/vmstat.c: 1.219
Reorder to test for null before null deref in debug code
--
Reorder to test for null before null deref in debug code
--
KNF
--
No need for '\n' in UVMHIST_LOG
--
normalise a BIOHIST log message
--
Update the kernhist(9) kernel history code to address issues identified
in PR kern/52639, as well as some general cleaning-up...
(As proposed on tech-kern@ with additional changes and enhancements.)
Details of changes:
* All history arguments are now stored as uintmax_t values[1], both in
   the kernel and in the structures used for exporting the history data
   to userland via sysctl(9).  This avoids problems on some architectures
   where passing a 64-bit (or larger) value to printf(3) can cause it to
   process the value as multiple arguments.  (This can be particularly
   problematic when printf()'s format string is not a literal, since in
   that case the compiler cannot know how large each argument should be.)
* Update the data structures used for exporting kernel history data to
   include a version number as well as the length of history arguments.
* All [2] existing users of kernhist(9) have had their format strings
   updated.  Each format specifier now includes an explicit length
   modifier 'j' to refer to numeric values of the size of uintmax_t.
* All [2] existing users of kernhist(9) have had their format strings
   updated to replace uses of "%p" with "%#jx", and the pointer
   arguments are now cast to (uintptr_t) before being subsequently cast
   to (uintmax_t).  This is needed to avoid compiler warnings about
   casting "pointer to integer of a different size."
* All [2] existing users of kernhist(9) have had instances of "%s" or
   "%c" format strings replaced with numeric formats; several instances
   of mis-match between format string and argument list have been fixed.
* vmstat(1) has been modified to handle the new size of arguments in the
   history data as exported by sysctl(9).
* vmstat(1) now provides a warning message if the history requested with
   the -u option does not exist (previously, this condition was silently
   ignored, with only a single blank line being printed).
* vmstat(1) now checks the version and argument length included in the
   data exported via sysctl(9) and exits if they do not match the values
   with which vmstat was built.
* The kernhist(9) man-page has been updated to note the additional
   requirements imposed on the format strings, along with several other
   minor changes and enhancements.
[1] It would have been possible to use an explicit length (for example,
     uint64_t) for the history arguments.  But that would require another
     "rototill" of all the users in the future when we add support for an
     architecture that supports a larger size.  Also, the printf(3)
format
     specifiers for explicitly-sized values, such as "%"PRIu64, are much
     more verbose (and less aesthetically appealing, IMHO) than simply
     using "%ju".
[2] I've tried very hard to find "all [the] existing users of
kernhist(9)"
     but it is possible that I've missed some of them.  I would be glad
to
     update any stragglers that anyone identifies.
--
For some reason this single kernel seems to have outgrown its declared
size as a result of the kernhist(9) changes.  Bump the size.
XXX The amount of increase may be excessive - anyone with more detailed
XXX knowledge please feel free to further adjust the value
appropriately.
--
Misssed one cast of pointer --> uintptr_t in previous kernhist(9) commit
--
And yet another one.  :(
--
Use correct mark-up for NetBSD version.
--
More improvements in grammar and readability.
--
Remove a stray '"' (obvious typo) and add a couple of casts that are
probably needed.
--
And replace an instance of "%p" conversion with "%#jx"
--
Whitespace fix. Give Bl tag table a width. Fix Xr.

diffstat:

 share/man/man9/kernhist.9                      |  126 ++++++++--
 sys/arch/acorn26/acorn26/pmap.c                |   38 +-
 sys/arch/arm/arm32/fault.c                     |   20 +-
 sys/arch/arm/arm32/pmap.c                      |   83 +++---
 sys/arch/arm/broadcom/bcm2835_bsc.c            |   28 +-
 sys/arch/arm/omap/if_cpsw.c                    |   51 ++--
 sys/arch/arm/omap/tiotg.c                      |   11 +-
 sys/arch/evbarm/conf/RPI2_INSTALL              |    4 +-
 sys/dev/ic/sl811hs.c                           |  111 ++++----
 sys/dev/usb/ehci.c                             |  293 +++++++++++++-----------
 sys/dev/usb/if_axe.c                           |   39 +-
 sys/dev/usb/motg.c                             |  141 ++++++-----
 sys/dev/usb/ohci.c                             |  273 ++++++++++++----------
 sys/dev/usb/ucom.c                             |   60 ++--
 sys/dev/usb/uhci.c                             |  193 ++++++++-------
 sys/dev/usb/uhub.c                             |   65 ++--
 sys/dev/usb/umass.c                            |  181 ++++++++------
 sys/dev/usb/umass_quirks.c                     |    8 +-
 sys/dev/usb/umass_scsipi.c                     |   52 ++--
 sys/dev/usb/usb.c                              |   24 +-
 sys/dev/usb/usb_mem.c                          |   16 +-
 sys/dev/usb/usb_subr.c                         |  153 ++++++------
 sys/dev/usb/usbdi.c                            |  141 ++++++-----
 sys/dev/usb/usbdi_util.c                       |   89 ++++---
 sys/dev/usb/usbroothub.c                       |   16 +-
 sys/dev/usb/xhci.c                             |  237 ++++++++++---------
 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c |    8 +-
 sys/kern/kern_history.c                        |   16 +-
 sys/kern/kern_xxx.c                            |   32 +-
 sys/kern/vfs_bio.c                             |   32 +-
 sys/miscfs/genfs/genfs_io.c                    |  104 ++++----
 sys/sys/kernhist.h                             |   58 ++--
 sys/ufs/ffs/ffs_balloc.c                       |   10 +-
 sys/ufs/lfs/lfs_vfsops.c                       |   20 +-
 sys/ufs/lfs/ulfs_inode.c                       |    8 +-
 sys/ufs/lfs/ulfs_vnops.c                       |    8 +-
 sys/ufs/ufs/ufs_inode.c                        |    8 +-
 sys/ufs/ufs/ufs_vnops.c                        |    8 +-
 sys/uvm/pmap/pmap.c                            |  179 +++++++-------
 sys/uvm/pmap/pmap_tlb.c                        |   39 +-
 sys/uvm/uvm_amap.c                             |   75 +++--
 sys/uvm/uvm_anon.c                             |   15 +-
 sys/uvm/uvm_aobj.c                             |   25 +-
 sys/uvm/uvm_bio.c                              |   34 +-
 sys/uvm/uvm_device.c                           |   27 +-
 sys/uvm/uvm_fault.c                            |   58 ++--
 sys/uvm/uvm_km.c                               |   23 +-
 sys/uvm/uvm_loan.c                             |   26 +-
 sys/uvm/uvm_map.c                              |  125 +++++-----
 sys/uvm/uvm_page.c                             |   10 +-
 sys/uvm/uvm_pager.c                            |   19 +-
 sys/uvm/uvm_pdaemon.c                          |    8 +-
 sys/uvm/uvm_swap.c                             |   61 ++--
 sys/uvm/uvm_vnode.c                            |   26 +-
 usr.bin/vmstat/vmstat.c                        |   28 +-
 55 files changed, 1916 insertions(+), 1627 deletions(-)

diffs (truncated from 11361 to 300 lines):

diff -r 4760beb34646 -r c7dc4ac18051 share/man/man9/kernhist.9
--- a/share/man/man9/kernhist.9 Thu Nov 02 21:03:34 2017 +0000
+++ b/share/man/man9/kernhist.9 Thu Nov 02 21:29:51 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: kernhist.9,v 1.4 2015/10/29 00:32:55 mrg Exp $
+.\"    $NetBSD: kernhist.9,v 1.4.8.1 2017/11/02 21:29:51 snj Exp $
 .\"
 .\" Copyright (c) 2015 Matthew R. Green
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 28, 2015
+.Dd October 25, 2017
 .Dt KERNHIST 9
 .Os
 .Sh NAME
@@ -63,29 +63,61 @@
 extremely early in the kernel initialisation.
 It provides a simple restricted
 .Xr printf 3
-format syntax with a maximum of 4 arguments.
-The format must be a literal string that can be referenced later as it
-is not stored with the event, only a pointer to it.
+format syntax with a maximum of 4 arguments, each of type
+.Vt uintmax_t .
 .Pp
 .Cd options KERNHIST
 must be present in the kernel configuration to enable these functions and
 macros.
 .Pp
-Arguments that require additional dereferences, such as
+A kernel history is a fixed-size buffer,either statically or dynamically
+allocated, that is written and read on a circular basis.
+Each entry includes the time the entry was made, the CPU from which the entry
+was recorded, the
+.Xr printf 3
+like format string and length, the function name and length, the unique call
+count for this function, and the 4 arguments.
+.Pp
+The history event data can be viewed using the
+.Fl U
+and
+.Fl u
+.Ar histname
+options to
+.Xr vmstat 1 ,
+or by using the
+.Ic show kernhist
+command in
+.Xr ddb 4 .
+User-written programs can retrieve history data from the kernel using the
+.Xr sysctl 9
+variable kern.hist.histname.
+.Pp
+The format string must be a literal string that can be referenced later as it
+is not stored with the event (only a pointer to the format string is stored).
+It should only contain conversion specifiers suitable for
+.Vt uintmax_t
+sized values, such as
+.Dq %jx ,
+.Dq %ju ,
+and
+.Dq %jo ,
+and address (pointer) arguments should be cast to
+.Vt uintptr_t
+to avoid compiler errors on architectures where pointers are smaller than
+.Vt uintmax_t
+integers.
+Conversion specifiers without a length modifier, and specifiers with length
+modifiers other than j, should not be used.
+.Pp
+Conversion specifiers that require additional dereferences of their
+corresponding arguments, such as
 .Dq %s ,
 will not work in
 .Xr vmstat 1 ,
-but will when called from
+but will work when called from
 .Xr ddb 4 .
 .Pp
-A kernel history is a fixed-size buffer of an either statically or dynamically
-allocated buffer that is used and read in a cycled basis.
-It includes the time an entry was made, the CPU that the entry was recorded
-from, the
-.Xr printf 3
-like format and length, the function name and length, the unique call count
-for this function, and the 4 argumnts.
-.Pp
 These macros provide access to most kernel history functionality:
 .Bl -tag -width 4n
 .It Fn KERNHIST_DECL name
@@ -118,18 +150,22 @@
 .It Fn KERNHIST_LOG name fmt arg0 arg1 arg2 arg3
 For the given kernel history
 .Fa name ,
-log the format and arguments in the history as a unique event.
+log the format string and arguments in the history as a unique event.
 .It Fn KERNHIST_CALLED name
 Declare a function as being called.
 Either this or
 .Fn KERNHIST_CALLARGS
-must be used near the function entry point.
+must be used once, near the function entry point, to maintain the number of
+times the function has been called.
 .It Fn KERNHIST_CALLARGS name fmt arg0 arg1 arg2 arg3
-A frontend to
+A combination of
+.Fn KERNHIST_CALLED
+and
 .Fn KERNHIST_LOG
-that avoids that
+that avoids having a
 .Dq called!
-log message in addition to normal arguments.
+log message in addition to a message containing normal arguments with a
+format string.
 .It Fn KERNHIST_DUMP name
 Call
 .Fn kernhist_dump
@@ -141,7 +177,7 @@
 The following histories and their respective value (as seen in
 .Pa kernhist.h )
 are available:
-.Bl -tag
+.Bl -tag -width KERNHIST_SCDEBUGHISTXXX
 .It KERNHIST_UVMMAPHIST
 Include events from
 .Dq maphist .
@@ -160,6 +196,9 @@
 .It KERNHIST_SCDEBUGHIST
 Include events from
 .Dq scdebughist .
+.It KERNHIST_BIOHIST
+Include events from
+.Dq biohist .
 .El
 .It Fn kernhist_print pr
 Print all the kernel histories to the kernel message buffer.
@@ -167,6 +206,19 @@
 .Fn pr
 argument is currently ignored.
 .El
+.Sh CODE REFERENCES
+The
+.Nm
+functionality is implemented within the files
+.Pa sys/sys/kernhist.h
+and
+.Pa sys/kern/kern_history.c .
+The former file contains the definitions of data structures used to export
+the
+.Nm data
+via the
+.Xr sysctl 9
+mechanism.
 .Sh SEE ALSO
 .Xr vmstat 1 ,
 .Xr usbdi 9 ,
@@ -176,6 +228,22 @@
 .\" add example here of code usage
 .\"
 .Sh HISTORY
+A uvm-specific version of the
+.Nm
+facility first appeared in
+.Nx 1.4 .
+The generalized version of
+.Nm
+appeared in
+.Nx 6.0 .
+The
+.Xr sysctl 9
+interface to
+.Nm
+was introduced in
+.Nx 8.0 .
+.Sh AUTHORS
+.An -nosplit
 .Nm
 was originally written by
 .An Charles D. Cranor
@@ -183,15 +251,19 @@
 .Xr uvm 9
 framework, under the name UVMHIST.
 .An Matthew R. Green
-generalised it into its current form to be available to non
+generalized it into its current form to be available to non
 .Xr uvm 9
 frameworks.
+.An Paul Goyette Aq Mt pgoyette%NetBSD.org@localhost
+provided the
+.Xr sysctl 9
+interface.
 .Sh BUGS
-The restriction about using
+The restriction against using
 .Dq %s
 .Xr printf 3
-format strings could be reduced to literal strings (such as the table of
-system call names) if
+specifier in format strings could be reduced to literal strings (such as
+the table of system call names) if
 .Xr vmstat 1
 was extended to convert
 .Dq %s
@@ -205,6 +277,10 @@
 list of masks could be properly published and made available, and as such
 this function may be removed in a future release.
 .Pp
+In addition to a statically-defined set of kernel histories, it would be
+possible to allow modular code to register and unregister their own
+histories dynamically, when a module is loaded or unloaded.
+.Pp
 The
 .Fn kernhist_print
 function currently ignores its
diff -r 4760beb34646 -r c7dc4ac18051 sys/arch/acorn26/acorn26/pmap.c
--- a/sys/arch/acorn26/acorn26/pmap.c   Thu Nov 02 21:03:34 2017 +0000
+++ b/sys/arch/acorn26/acorn26/pmap.c   Thu Nov 02 21:29:51 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.38 2016/12/24 17:11:31 cherry Exp $ */
+/* $NetBSD: pmap.c,v 1.38.8.1 2017/11/02 21:29:51 snj Exp $ */
 /*-
  * Copyright (c) 1997, 1998, 2000 Ben Harris
  * All rights reserved.
@@ -102,7 +102,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.38 2016/12/24 17:11:31 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.38.8.1 2017/11/02 21:29:51 snj Exp $");
 
 #include <sys/kernel.h> /* for cold */
 #include <sys/kmem.h>
@@ -556,7 +556,8 @@
        UVMHIST_FUNC("pv_get");
 
        UVMHIST_CALLED(pmaphist);
-       UVMHIST_LOG(pmaphist, "(pmap=%p, ppn=%d, lpn=%d)", pmap, ppn, lpn, 0);
+       UVMHIST_LOG(pmaphist, "(pmap=%#jx, ppn=%jd, lpn=%jd)",
+           (uintptr_t)pmap, ppn, lpn, 0);
        /* If the head entry's free use that. */
        pv = &pv_table[ppn];
        if (pv->pv_pmap == NULL) {
@@ -567,8 +568,8 @@
        /* If this mapping exists already, use that. */
        for (pv = pv; pv != NULL; pv = pv->pv_next)
                if (pv->pv_pmap == pmap && pv->pv_lpn == lpn) {
-                       UVMHIST_LOG(pmaphist, "<-- existing (pv=%p)",
-                           pv, 0, 0, 0);
+                       UVMHIST_LOG(pmaphist, "<-- existing (pv=%#jx)",
+                           (uintptr_t)pv, 0, 0, 0);
                        return pv;
                }
        /* Otherwise, allocate a new entry and link it in after the head. */
@@ -578,7 +579,7 @@
        pv->pv_next = pv_table[ppn].pv_next;
        pv_table[ppn].pv_next = pv;
        pmap->pm_stats.resident_count++;
-       UVMHIST_LOG(pmaphist, "<-- new (pv=%p)", pv, 0, 0, 0);
+       UVMHIST_LOG(pmaphist, "<-- new (pv=%#jx)", (uintptr_t)pv, 0, 0, 0);
        return pv;
 }
 
@@ -592,7 +593,8 @@
        UVMHIST_FUNC("pv_release");
 
        UVMHIST_CALLED(pmaphist);
-       UVMHIST_LOG(pmaphist, "(pmap=%p, ppn=%d, lpn=%d)", pmap, ppn, lpn, 0);
+       UVMHIST_LOG(pmaphist, "(pmap=%#jx, ppn=%jd, lpn=%jd)",
+           (uintptr_t)pmap, ppn, lpn, 0);
        pv = &pv_table[ppn];
        /*
         * If it is the first entry on the list, it is actually
@@ -603,13 +605,15 @@
        if (pmap == pv->pv_pmap && lpn == pv->pv_lpn) {
                npv = pv->pv_next;
                if (npv) {
-                       UVMHIST_LOG(pmaphist, "pv=%p; pull-up", pv, 0, 0, 0);
+                       UVMHIST_LOG(pmaphist, "pv=%#jx; pull-up",
+                           (uintptr_t)pv, 0, 0, 0);
                        /* Pull up first entry from chain. */
                        memcpy(pv, npv, offsetof(struct pv_entry, pv_pflags));
                        pv->pv_pmap->pm_entries[pv->pv_lpn] = pv;
                        pv_free(npv);
                } else {
-                       UVMHIST_LOG(pmaphist, "pv=%p; empty", pv, 0, 0, 0);
+                       UVMHIST_LOG(pmaphist, "pv=%#jx; empty",
+                           (uintptr_t)pv, 0, 0, 0);
                        memset(pv, 0, offsetof(struct pv_entry, pv_pflags));
                }
        } else {
@@ -619,7 +623,7 @@
                        pv = npv;
                }
                KASSERT(npv != NULL);
-               UVMHIST_LOG(pmaphist, "pv=%p; tail", pv, 0, 0, 0);
+               UVMHIST_LOG(pmaphist, "pv=%#jx; tail", (uintptr_t)pv, 0, 0, 0);



Home | Main Index | Thread Index | Old Index