Commit Graph

233473 Commits

Author SHA1 Message Date
Conrad Meyer
ede2f7731d Correctly handle the padding for IPv6-AH, as specified by RFC4302
The RFC specifies that under IPv6 the complete AH header must be 64 bit
aligned, and under IPv4, 32 bit aligned. Prior to this change, we (along
with other BSDs and MacOS) had violated this requirement.

This makes it possible to set up IPv6-AH between Linux and BSD, and also
probably between Windows and BSD.

PR:		222684
Reported and tested by:	Jason Mader <jasonmader AT gmail.com>
Obtained from:	NetBSD xform_ah.c 1.105
		(b939fe2483972eb43d71bf990cfb7f26dece7839 NetBSD/src on GH)
		by Maxime Villard
MFC after:	35.2731 hours
Relnotes:	probably (breaks ipv6 compat with older FreeBSD/NetBSD/MacOS)
Sponsored by:	Dell EMC Isilon
2018-06-04 18:51:06 +00:00
Conrad Meyer
3d825c42ca str(r)chr: Replace union abuse with __DECONST
Writing one union member and reading another is technically illegal C,
although we do it in many places in the tree.  Use the __DECONST macro
instead, which is (technically) a valid C construct.

Trivial style(9) cleanups to touched lines while here.

Sponsored by:	Dell EMC Isilon
2018-06-04 18:47:14 +00:00
Matt Macy
cf823003a7 hwpmc: remove gratuitous curthread checks 2018-06-04 17:49:34 +00:00
Mark Johnston
27e29d103f Correct the description of vm_pageout_scan_inactive() after r334508.
Reported by:	alc
2018-06-04 16:46:36 +00:00
Alan Cox
3e7cb27cdd Use a single, consistent approach to returning success versus failure in
vm_map_madvise().  Previously, vm_map_madvise() used a traditional Unix-
style "return (0);" to indicate success in the common case, but Mach-
style return values in the edge cases.  Since KERN_SUCCESS equals zero,
the only problem with this inconsistency was stylistic.  vm_map_madvise()
has exactly two callers in the entire source tree, and only one of them
cares about the return value.  That caller, kern_madvise(), can be
simplified if vm_map_madvise() consistently uses Unix-style return
values.

Since vm_map_madvise() uses the variable modify_map as a Boolean, make it
one.

Eliminate a redundant error check from kern_madvise().  Add a comment
explaining where the check is performed.

Explicitly note that exec_release_args_kva() doesn't care about
vm_map_madvise()'s return value.  Since MADV_FREE is passed as the
behavior, the return value will always be zero.

Reviewed by:	kib, markj
MFC after:	7 days
2018-06-04 16:28:06 +00:00
Ruslan Bukin
a8db1fa14d Sort GCC warning flags and remove duplicates.
Sponsored by:	DARPA, AFRL
2018-06-04 16:21:18 +00:00
Ruslan Bukin
8cd6c09e7e Fix build: ignore a GCC 7.2.0 warning which says that third argument of
memset(3) should contain the number of elements multiplied by the element
size.

Sponsored by:	DARPA, AFRL
2018-06-04 16:20:22 +00:00
Justin Hibbits
12f691959f Align UMA data to 128 byte cacheline size
Suggested by:	mjg
2018-06-04 15:44:17 +00:00
Brad Davis
8dc84f09e0 Move /sys symlink creating out of etc/Makefile.
This is prep for etc/Makefile going away.

Approved by:	bapt (mentor)
2018-06-04 15:17:24 +00:00
Mark Johnston
bcc51ef48d Fix the NUMA build for non-x86 platforms.
acpi_map_pxm_to_vm_domainid() is currently implemented only on x86.

MFC after:	1 week
2018-06-04 14:56:02 +00:00
Justin Hibbits
fdb600af60 Set kernelname in bootconfig to the kernel file
Summary:
The kernel reads 'kernelname' to set the kern.bootfile sysctl.  By setting this,
'make installkernel' will backup the running kernel as appropriate.

Reviewed by:	nwhitehorn
Differential Revision: https://reviews.freebsd.org/D15660
2018-06-04 14:42:13 +00:00
Rick Macklem
8472f76005 Revert r334586 since I now think __unused is the better way to handle this. 2018-06-04 11:35:04 +00:00
Matt Macy
b79ce32e4e pmc filter: avoid spurious gcc uninitialized warning 2018-06-04 06:30:35 +00:00
Eitan Adler
cda7a5d5ed top(1): some nitpicks
- prefer fully spelled names to "u_long"
- fix speeling
2018-06-04 05:27:00 +00:00
Matt Macy
ce6fc9d779 update pmc_pmu_idx_get_by_event signature for !x86 2018-06-04 05:04:40 +00:00
Matt Macy
bfb46e2ba8 pmc: add filter command
pmc filter allows the user to select event types, threads, and processes from
a sample.

% pmcstat -S unhalted_core_cycles -S llc-misses -S -S  resource_stalls.any -O pmc.log
% pmc filter -e llc-misses pmc.log pmc-llc-misses.log
% pmc filter -e unhalted_core_cycles -t 100339  pmc.log pmc-core-cycles.log
etc...
% pmcstat -R pmc-core-cycles.log -G pmc-core-cycles.stacks
2018-06-04 04:59:48 +00:00
Eitan Adler
8d0d26767b top(1): include what you use
- Change headers to more closely match what we use
- use more standard functions instead of bzero, bcmp, bcopy
- Add myself to authors.

Tested with: base clang (amd64), gcc 9 (amd64), base clang (i386), base
gcc (mips)
2018-06-04 04:59:32 +00:00
Eitan Adler
5dc98aeeaa top(1): Prefer memcpy over bcopy 2018-06-04 04:59:24 +00:00
Matt Macy
9645bcabdf hwpmc: fix fixed counters checks 2018-06-04 04:49:06 +00:00
Eitan Adler
a9a99372d9 top(1): Use strsep instead of homegrown alternative
This replaces some complex, and not quite correct logic, with a more
common strsep pattern.

Reviewed by:	mmacy (older version)
2018-06-04 03:16:24 +00:00
Matt Macy
07d80fd8dc hwpmc: ABI fixes
- increase pmc cpuid field from 8 to 12 bits
- add cpuid version string to initialize entry in the log
  so that filter can identify which counter index an
  event name maps to
- GC unused config flags
- make fixed counter assignment more robust as well as the
  changes needed to be properly identified for filter
2018-06-04 02:05:48 +00:00
Matt Macy
5de96e33d6 hwpmc: support sampling both kernel and user stacks when interrupted in kernel
This adds the -U options to pmcstat which will attribute in-kernel samples
back to the user stack that invoked the system call. It is not the default,
because when looking at kernel profiles it is generally more desirable to
merge all instances of a given system call together.

Although heavily revised, this change is directly derived from D7350 by
Jonathan T. Looney.

Obtained from: jtl
Sponsored by: Juniper Networks, Limelight Networks
2018-06-04 01:10:23 +00:00
Devin Teske
e52d921647 dwatch(1): Update manual to reference actual release
MFC after:	3 days
X-MFC-to:	stable/11
Sponsored by:	Smule, Inc.
2018-06-03 23:49:02 +00:00
Eitan Adler
eae589f1ce top(1): another pass of cleanup
- avoid the need to call a function to get size of known array. I'll
likely re-arrange some of the indirect in a later to avoid the magic
constants.
- use correct type
- add const
- replace caddr_t with void*. This corrects an alignment warning.
- remove duplicated include from immediately prior commit

Under base clang we're now down to:
- 3 warning in top.c, 1 warning in mahcine.c,  4 warning in display.c,
- 1 warning in utils.c

Tested with base clang, gcc7, gcc9, base gcc (mips)
2018-06-03 23:40:54 +00:00
Alan Somers
01e77fa0bf audit(4): add tests for the cl audit class
The only syscalls in this class are close, closefrom, munmap, and revoke.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15650
2018-06-03 23:36:29 +00:00
Eitan Adler
9f8096e339 top(1): top warnings and cleanup
- Add const where helpful
- add missing 'static' for file-local functions
- use nitems where possible
- convert manual abort() to assert
- use strndup instead of homegrown version

Tested with clang, gcc7, and gcc9
2018-06-03 22:42:54 +00:00
Piotr Pawel Stefaniak
aac30b753f indent(1): new option -lpl
With -lpl, code surrounded by parentheses in continuation lines is lined up
even if it would extend past the right margin.

With -nlpl (the default), such a line that would extend past the right
margin is moved left to keep it within the margin, if that does not require
placing it to the left of the prevailing indentation level.

These switches have no effect if -nlp is selected.

Submitted by:	Tom Lane
2018-06-03 21:40:38 +00:00
Piotr Pawel Stefaniak
50a2976094 indent(1): revert introduction of -lpl
That was committed with the wrong message. Will be re-added.
2018-06-03 21:34:29 +00:00
Piotr Pawel Stefaniak
971e1c47ec indent(1): new option -lpl (always line up to parenthesis)
With -lp, if a line has an opening paren which is not closed on that line,
then continuation lines will be lined up to start at the character position
just after the opening paren.

Submitted by:	Tom Lane
2018-06-03 20:59:59 +00:00
Piotr Pawel Stefaniak
5834814ee8 indent(1): manual page corretions
Add missing options, synchronize syntax summary with the actual option list,
and other fixes.

Submitted by:	Tom Lane
2018-06-03 20:48:58 +00:00
Rick Macklem
12c7a494ad Fix a gcc8 warning about a write only variable.
gcc8 warns that "verf" was set but not used. This was because the code
that uses it is disabled via a "#if 0".
This patch adds a "#if 0" to the variable's declaration and assignment
to get rid of the warning.
This way the code could be re-enabled without difficulty.

Requested by:	mmacy
MFC after:	2 weeks
2018-06-03 19:46:44 +00:00
Matt Macy
2ce69a4d04 hwpmc: ensure that mapin updates are synchronous 2018-06-03 19:37:17 +00:00
Matt Macy
a1a1e8a89a pmc: remove assert that is invalid in interrupt context 2018-06-03 19:37:09 +00:00
Piotr Pawel Stefaniak
2364d1a74e indent(1): if an identifier can be either a typedef name or as a struct
member, it is taken as the latter
2018-06-03 19:05:20 +00:00
Piotr Pawel Stefaniak
01a206e63c indent(1): if the token is a "[" then neither of the blocks is relevant 2018-06-03 18:38:03 +00:00
Piotr Pawel Stefaniak
fa7ea0c961 indent(1): don't add a space after a label
It's not needed and it fools pr_comment().
2018-06-03 18:34:36 +00:00
Piotr Pawel Stefaniak
9963ad6fdf indent(1): ignore null characters from input 2018-06-03 18:32:11 +00:00
Piotr Pawel Stefaniak
370d0cf9be indent(1): don't overflow di_stack[] 2018-06-03 18:29:20 +00:00
Piotr Pawel Stefaniak
9de29bfb5a indent(1): improve CHECK_SIZE_ macros
Rewrite the macros so that they take a parameter. Consumers use it to signal
how much room in the buffer they need; this lets them do that once when
required space is known instead of doing the check once every loop step.

Also take the parameter value into consideration when resizing the buffer;
the requested space may be larger than the constant 400 bytes that the
previous version used - now it's the sum of those two values.

On the consumer side, don't copy strings byte by byte - use memcpy().

Deduplicate code that copied base 2, base 8 and base 16 literals.

Don't advance the e_token pointer once the token has been copied into
s_token. This allows easy calculation of the token's length.
2018-06-03 18:19:41 +00:00
Piotr Pawel Stefaniak
1479f36d8e indent(1): remove troff output support
The troff output in indent was invented at Sun and the online documentation
for some post-SunOS operating system includes this:
The usual way to  get  a  troffed listing is with the command
                       indent -troff program.c | troff -mindent

The indent manual page in FreeBSD 1.0 already lacks that information and
troff -mindent complains about not being able to find the macro file.
It seems that the file did exist on SunOS and was supposed to be imported
into 4.3BSD together with the feature, but that has never happened.

Removal of troff output support simplifies a lot of indent's code.

vgrind(1) seems to be a promising replacement.
2018-06-03 17:55:50 +00:00
Piotr Pawel Stefaniak
7c5f6031fe indent(1): avoid resetting last_bl to a bogus value when reallocating
underlying buffer
2018-06-03 17:11:01 +00:00
Piotr Pawel Stefaniak
bef613ff2f indent(1): the check for buffer overflow has to be done before copy 2018-06-03 17:07:56 +00:00
Piotr Pawel Stefaniak
33c2464207 indent(1): use errx() instead of abort() 2018-06-03 17:05:55 +00:00
Piotr Pawel Stefaniak
e1baf57e4b indent(1): limit character classification functions' input to unsigned char 2018-06-03 17:03:55 +00:00
Piotr Pawel Stefaniak
95b813e501 indent(1): recognize more type names
Most are from C99.
2018-06-03 16:52:30 +00:00
Piotr Pawel Stefaniak
9522d0b0d2 indent(1): don't format function declarations as variables 2018-06-03 16:42:58 +00:00
Piotr Pawel Stefaniak
e95d1e3c93 indent(1): remove is_procname.
It was a shorthand for checking if ps.procname is a non-empty string; the
same can be done with ps.procname[0] which avoids the need for updating
is_procname after every call to lexi().
2018-06-03 16:27:40 +00:00
Piotr Pawel Stefaniak
f9287a9d85 indent(1): disjoint parser state from lexi()
The function is sometimes used as a look-ahead, so ideally it should bear
no information about parser state.
2018-06-03 16:21:15 +00:00
Piotr Pawel Stefaniak
3c51c3cf5f indent(1): improve handling of boxed comments indentation
The trick is to copy everything from the start of the line into the buffer
that stores newlines and comments until indent finds a brace or an else.
pr_comment() will use that information to calculate the original indentation
of the boxed comment.

This requires storing two pieces of information: the real start of the
buffer (sc_buf) and the start of the comment (save_com).
2018-06-03 15:28:55 +00:00
Piotr Pawel Stefaniak
63c3f22696 indent(1): improve predictability of lexi()
lexi() reads the input stream and categorizes the next token. indent will
sometimes buffer up a sequence of tokens in order rearrange them. That is
needed for properly cuddling else or placing braces correctly according to
the chosen style (KNF vs Allman) when comments are around. The loop that
buffers tokens up uses lexi() to decide if it's time to stop buffering. Then
the temporary buffer is used to feed lexi() the same tokens again, this time
for normal processing.

The problem is that lexi() apart from recognizing the token, can change
a lot of information about the current state, for example ps.last_nl,
ps.keyword, buf_ptr. It also abandons leading whitespace, which is needed
mainly for comment-related considerations. So the call to lexi() while
tokens are buffered up and categorized can change the state before they're
read again for normal processing which may easily result in changing
interpretation of the current state and lead to incorrect output.

To work around the problems:
1) copy the whitespace into the save_com buffer so that it will be read
again when processed
2) trick lexi() into modifying a temporary copy of the parser state instead
of the original.
2018-06-03 14:13:11 +00:00