tech-kern archive

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

Proposed changes for PR kern/52639 - kernhist(9)



The attached diffs implement the following changes in the KERNHIST
feature, and is the proposed fix for PR kern/52639.  (The diffs are
compressed to allow them to be attached to this Email;  they would
otherwise exceed message-size limitations.)

I would appreciate your review and (constructive) comments.

Since this PR is interfering with other developers' efforts, I would
like to get this committed within the next few days.

Changes:
* All history arguments are stored as uintmax_t values, both in the
  kernel and in the structures used for exporting the history data
  to userland.  This avoids problems on some architectures where
  passing a 64-bit (or larger) value to printf() can result in
  printf() processing the value as multiple arguments.  (This is
  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.)

* All [1] existing users of KERNHIST 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 unitmax_t.

* All [1] existing users of KERNHIST 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."

* vmstat(1) has been modified to handle the new size of arguments
  in the history data as exported by sysctl().

* The kernhist(9) man-page has been updated to note the additional
  requirements imposed on the format strings, along with several
  other minor changes.

Note that it would have been possible to use an explicit length for
the history arguments, for example uint64_t, rather than uintmax_t.
But that would require another "rototill" of all the users in the
future when we find an architecture that supports a larger size.
Also, the printf() format specifiers for explicitly-sized values,
such as "%"PRIu64", is much more verbose (and less aesthetically
appealing, IMHO) than simply using "%ju".

[1] Further note that I've tried very hard to find all "the existing
users of KERNHIST" but it is possible that I've missed a couple.  I
would be glad to update any stragglers that anyone identifies.


+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+

Attachment: diffs.text.gz
Description: Binary data



Home | Main Index | Thread Index | Old Index