Commit Graph

19 Commits

Author SHA1 Message Date
skrll 208170f3b1 Traiing whitespace 2019-10-09 05:59:51 +00:00
riastradh d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
mrg ba0c19d412 extend the ddb "show kernhist" command. the synopsis is now:
show kernhist[/i] [addr[,count]]

the i modifier means display info instead of entries, and the count
restricts to the last count entries.

the count option is only supported for specified histories.  it
could be extended but requires more logic than the single history,
as multiple histories are merged during display.
2018-08-13 03:20:19 +00:00
pgoyette 64ae8753d8 Remove the ABI version-and-length check that was recently introduced;
sysctl(9) ABIs should be stable across versions.

XXX Pull-up to -8
2017-11-03 22:45:14 +00:00
pgoyette cb32a134a5 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.
2017-10-28 00:37:11 +00:00
pgoyette 4869ce0a43 Use membar_{producer,consumer}() to ensure proper access to the "ready"
flag.
2017-01-10 22:08:14 +00:00
pgoyette 5a30768de5 Rework the sysctl initialization to avoid creating new nodes from
within the helper function.  This should avoid the "locking against
myself" error reported earlier.
2017-01-10 00:50:57 +00:00
christos f896811791 fix build without ddb. 2017-01-08 19:49:25 +00:00
pgoyette c9b6361b98 By popular demand, update kernhist to use bintime(9) as the basis for
its timestamps.

As this changes storage structures for data passed between kernel and
userland, welcome to 7.99.55!

XXX Output routines still use microsecond resolution when printf()ing.

XXX Possible future feature would be addition of option to use
XXX getbintime(9) for less time-critical histories.
2017-01-05 03:40:33 +00:00
pgoyette 5a0b3ff699 Rearrange the sysctl export structure for better alignment. 2017-01-04 01:05:58 +00:00
pgoyette c2efd8c96e Provide a sysctl method of exporting the kernel history data.
XXX vmstat will be update soon to use the sysctl rather than grovelling
XXX through kvm.
2017-01-01 23:58:47 +00:00
pgoyette d05a55c879 #include giohist.h from proper location 2016-12-26 23:49:53 +00:00
pgoyette 7f0851cee1 Add a BIOHIST option. As mentioned on tech-kern. 2016-12-26 23:12:33 +00:00
skrll 70699ce203 Fix UVMHIST builds for kernels that don't include usb 2016-06-23 07:32:12 +00:00
skrll 0895dad130 KNF . Sort includes 2016-06-22 07:44:02 +00:00
skrll 1a04d8c9f0 Improve ddb(4) show kernhist
1) really prints all the histories merged together (rather than just the
   "first" when no argument specified
2) dumps a single history when an argument is given, e.g.
   "show kernhist usbhist"
3) uses db_printf correctly
2016-04-06 21:56:24 +00:00
mrg 1e1a1a8da3 if NUSB == 0, don't look for usbhist. 2015-10-29 18:40:19 +00:00
mrg 679d7c25a6 introduce a new way of handling SYSCALL_DEBUG messages -- send them to
a kernel history, settable via the SCDEBUG_KERNHIST flag.

this requires a fairly significantly different set of messages than the
normal debug as histories are restricted:
	- each message can take one literal format string and upto 4
	  arguments
	- the arguments can not be strings if you want vmstat -u to
	  work (this could be fixed, and i might, as it would be nice
	  if we could print syscall names as well as numbers.)

introduce SCDEBUG_DEFAULT that is settable in the kernel config.

fix a problem in kernhist_dump_histories() where it would crash when a
history with no allocated entries was found.

extend kernhist_dumpmask() to handle the usbhist and scdebughist.
2015-10-29 00:27:08 +00:00
mrg 8169e46991 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.
2011-05-17 04:18:05 +00:00