]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoindent(1): don't add a space after a label
pstef [Sun, 3 Jun 2018 18:34:36 +0000 (18:34 +0000)]
indent(1): don't add a space after a label

It's not needed and it fools pr_comment().

6 years agoindent(1): ignore null characters from input
pstef [Sun, 3 Jun 2018 18:32:11 +0000 (18:32 +0000)]
indent(1): ignore null characters from input

6 years agoindent(1): don't overflow di_stack[]
pstef [Sun, 3 Jun 2018 18:29:20 +0000 (18:29 +0000)]
indent(1): don't overflow di_stack[]

6 years agoindent(1): improve CHECK_SIZE_ macros
pstef [Sun, 3 Jun 2018 18:19:41 +0000 (18:19 +0000)]
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.

6 years agoindent(1): remove troff output support
pstef [Sun, 3 Jun 2018 17:55:50 +0000 (17:55 +0000)]
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.

6 years agoindent(1): avoid resetting last_bl to a bogus value when reallocating
pstef [Sun, 3 Jun 2018 17:11:01 +0000 (17:11 +0000)]
indent(1): avoid resetting last_bl to a bogus value when reallocating
underlying buffer

6 years agoindent(1): the check for buffer overflow has to be done before copy
pstef [Sun, 3 Jun 2018 17:07:56 +0000 (17:07 +0000)]
indent(1): the check for buffer overflow has to be done before copy

6 years agoindent(1): use errx() instead of abort()
pstef [Sun, 3 Jun 2018 17:05:55 +0000 (17:05 +0000)]
indent(1): use errx() instead of abort()

6 years agoindent(1): limit character classification functions' input to unsigned char
pstef [Sun, 3 Jun 2018 17:03:55 +0000 (17:03 +0000)]
indent(1): limit character classification functions' input to unsigned char

6 years agoindent(1): recognize more type names
pstef [Sun, 3 Jun 2018 16:52:30 +0000 (16:52 +0000)]
indent(1): recognize more type names

Most are from C99.

6 years agoindent(1): don't format function declarations as variables
pstef [Sun, 3 Jun 2018 16:42:58 +0000 (16:42 +0000)]
indent(1): don't format function declarations as variables

6 years agoindent(1): remove is_procname.
pstef [Sun, 3 Jun 2018 16:27:40 +0000 (16:27 +0000)]
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().

6 years agoindent(1): disjoint parser state from lexi()
pstef [Sun, 3 Jun 2018 16:21:15 +0000 (16:21 +0000)]
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.

6 years agoindent(1): improve handling of boxed comments indentation
pstef [Sun, 3 Jun 2018 15:28:55 +0000 (15:28 +0000)]
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).

6 years agoindent(1): improve predictability of lexi()
pstef [Sun, 3 Jun 2018 14:13:11 +0000 (14:13 +0000)]
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.

6 years agoindent(1): improve handling of comments and newlines between "if (...)" or
pstef [Sun, 3 Jun 2018 14:03:20 +0000 (14:03 +0000)]
indent(1): improve handling of comments and newlines between "if (...)" or
"while (...)" and "else" or "{"

* Don't flush newlines - there can be multiple of them and they can happen
before a token that isn't else or {. Instead, always store them in save_com.
* Don't dump the buffer's contents on newline assuming that there is only
one comment before else or {.
* Avoid producing surplus newlines, especially before else when -ce is on.
* When -bl is on, don't treat { as a comment (was implemented by falling
through "case lbrace:" to "case comment:").

This commit fixes the above, but exposes another bug and thus breaks several
other tests. Another commit will make them pass again.

6 years agotop(1): restore size for kern.cp_times
eadler [Sun, 3 Jun 2018 13:41:23 +0000 (13:41 +0000)]
top(1): restore size for kern.cp_times

Restore last minute change that broke top(1).

6 years agoindent(1): remove undocumented and rather useless option (-ps)
pstef [Sun, 3 Jun 2018 13:40:58 +0000 (13:40 +0000)]
indent(1): remove undocumented and rather useless option (-ps)

It's used to treat the "->" access operator as a binary operator and put
space characters around it.

6 years ago[evdev] Sync event codes with Linux kernel 4.16
wulf [Sun, 3 Jun 2018 10:53:10 +0000 (10:53 +0000)]
[evdev] Sync event codes with Linux kernel 4.16

MFC after: 2 weeks

6 years agotop(1): Only use NO_WERROR for base gcc
eadler [Sun, 3 Jun 2018 06:02:31 +0000 (06:02 +0000)]
top(1): Only use NO_WERROR for base gcc

This is what was intended. If statements are hard.

6 years agotop(1): partial revert of r334517
eadler [Sun, 3 Jun 2018 05:20:11 +0000 (05:20 +0000)]
top(1): partial revert of r334517

In fixing issues with uid > INT_MAX, I broke the uid without username
case. The latter is more important so return the old state.

Discussed with: allanjude

6 years agotop(1): remove chdir to /
eadler [Sun, 3 Jun 2018 05:07:46 +0000 (05:07 +0000)]
top(1): remove chdir to /

While this came out of a conversation in IRC, it turn out that some
people don't like it. Since this was a courtesy feature, just remove it.

6 years agotop(1): use greater warnings
eadler [Sun, 3 Jun 2018 05:07:39 +0000 (05:07 +0000)]
top(1): use greater warnings

One of the downsides of using numeric WARNS is that if we only have a
single type of issue we get no protection from other changes.  For
example, we got no warning for missing variable declaration, due to
the issues with "const".

For this utility, explicitly list out the warnings which are failing.
They should still be fixed, so only reduce them to warning instead of
error.

Tested with: clang base (amd64, i386), gcc6, gcc7, gcc9, gcc base (mips)

6 years agoRevert r326083, it doesn't behave as expected.
jhibbits [Sun, 3 Jun 2018 03:53:11 +0000 (03:53 +0000)]
Revert r326083, it doesn't behave as expected.

Even though there do appear to be more artificial frames, with 12, stack
traces no longer list at all.  Revert until a better, more stable value can
be determined.

6 years agotop(1): misc minor improvements
eadler [Sun, 3 Jun 2018 02:58:53 +0000 (02:58 +0000)]
top(1): misc minor improvements

- use bool instead of int [0]
- use calloc correctly [0]
(this also caught an incorrect sizeof argument) [1]
- use size_t over int [2]
- correct style

Reported by: pfg [0], scan-build [1], gcc [2]

6 years agopty.3: Add a HISTORY section
asomers [Sat, 2 Jun 2018 22:40:16 +0000 (22:40 +0000)]
pty.3: Add a HISTORY section

These functions were first added in 4.3 BSD-Reno, according to
http://unix.superglobalmegacorp.com/ and the CSRG svn repository.

Reviewed by: bcr, bjk
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15652

6 years agoRemove an unused argument to turnstile_unpend.
mjg [Sat, 2 Jun 2018 22:37:53 +0000 (22:37 +0000)]
Remove an unused argument to turnstile_unpend.

PR: 228694
Submitted by: Julian Pszczołowski <julian.pszczolowski@gmail.com>

6 years agomalloc: try to use builtins for zeroing at the callsite
mjg [Sat, 2 Jun 2018 22:20:09 +0000 (22:20 +0000)]
malloc: try to use builtins for zeroing at the callsite

Plenty of allocation sites pass M_ZERO and sizes which are small and known
at compilation time. Handling them internally in malloc loses this information
and results in avoidable calls to memset.

Instead, let the compiler take the advantage of it whenever possible.

Discussed with: jeff

6 years agotop(1): Fix two speeling errors I introduced
eadler [Sat, 2 Jun 2018 22:12:57 +0000 (22:12 +0000)]
top(1): Fix two speeling errors I introduced

6 years agotop(1): chdir to / as init; remove unneeded comment
eadler [Sat, 2 Jun 2018 22:06:27 +0000 (22:06 +0000)]
top(1): chdir to / as init; remove unneeded comment

- chdir to / to allow unmounting of wd
- remove warning about running top(1) as setuid. If this is a concern we
should just drop privs instead.

6 years agotop(1): cleanup memory allocation and warnings
eadler [Sat, 2 Jun 2018 21:40:45 +0000 (21:40 +0000)]
top(1): cleanup memory allocation and warnings

- Prefer calloc over malloc. This is more predicable and we're not in a
performance sensitive context. [1]
- Remove bogus comment (obsolete from prior commit). [2]
- Remove void casts and type casts of NULL
- Remove redundant declaration of 'quit'
- Add additional const

Reported by: kib [1], vangyzen [2]

6 years agoIncluded VSX registers in powerpc core dumps
jhibbits [Sat, 2 Jun 2018 20:28:58 +0000 (20:28 +0000)]
Included VSX registers in powerpc core dumps

Summary: Included VSX registers in powerpc core dumps (both kernel and gcore)

Submitted by: Luis Pires
Differential Revision: https://reviews.freebsd.org/D15512

6 years agoamd64: add a mild depessimization to rep mov/stos users
mjg [Sat, 2 Jun 2018 20:14:43 +0000 (20:14 +0000)]
amd64: add a mild depessimization to rep mov/stos users

Currently all the primitives are waiting for a rewrite, tidy them up in the
meantime.

Vast majority of cases pass sizes which are multiple of 8. Which means the
following rep stosb/movb has nothing to do. Turns out testing first if there
is anything to do is a big win across the board (cpus with and without ERMS,
Intel and AMD) while not pessimizing the case where there is work to do.

Sample results for zeroing 64 bytes (ops/second):
Ryzen Threadripper 1950X 91433212 -> 147265741
Intel(R) Xeon(R) CPU X5675 @ 3.07GHz 90714044 -> 121992888

bzero and bcopy are on their way out and were not modified. Nothing in the
tree uses them.

6 years agoAdded ptrace support for reading/writing powerpc VSX registers
jhibbits [Sat, 2 Jun 2018 19:17:11 +0000 (19:17 +0000)]
Added ptrace support for reading/writing powerpc VSX registers

Summary:
Added ptrace support for getting/setting the remaining part of the VSX registers
(the part that's not already covered by FPR or VR registers).

This is necessary to add support for VSX registers in debuggers.

Submitted by: Luis Pires
Differential Revision: https://reviews.freebsd.org/D15458

6 years agoUse __builtin for various mem* and b* (e.g. bzero) routines.
mjg [Sat, 2 Jun 2018 18:03:35 +0000 (18:03 +0000)]
Use __builtin for various mem* and b* (e.g. bzero) routines.

Some of the routines were using artificially limited builtin already,
drop the explicit limit.

The use of builtins allows quite often allows the compiler to elide the call
or most zeroing to begin with. For instance, if the target object is 32 bytes
in size and gets zeroed + has 16 bytes initialized, the compiler can just
add code to zero out the rest.

Note not all the primites have asm variants and some of the existing ones
are not optimized. Maintaines are strongly encourage to take a look
(regardless of this change).

6 years agolibkern: tidy up memset
mjg [Sat, 2 Jun 2018 17:57:09 +0000 (17:57 +0000)]
libkern: tidy up memset

1. Remove special-casing of 0 as it just results in an extra function call.
This is clearly pessimal.
2. Drop the inline stuff. For the most part it is much better served with
__builtin_memset (coming later).
3. Move the declaration to systm.h to match other funcs.

Archs are encouraged to implement the variant for their own platform so that
this implementation can be dropped.

6 years agoDon't overflow a buffer if we receive an INIT or INIT-ACK chunk
tuexen [Sat, 2 Jun 2018 16:28:10 +0000 (16:28 +0000)]
Don't overflow a buffer if we receive an INIT or INIT-ACK chunk
without a RANDOM parameter but with a CHUNKS or HMAC-ALGO parameter.
Please note that sending this combination violates the specification.

Thnanks to Ronald E. Crane for reporting the issue for the userland
stack.

MFC after: 3 days

6 years agotop: add -p option and p command to only show a single process
novel [Sat, 2 Jun 2018 15:52:18 +0000 (15:52 +0000)]
top: add -p option and p command to only show a single process

Allow to show only a single process specified by PID. This could
be done either by running top like 'top -p PID' or using the 'p' command
inside top.

Reviewed by: eadler
Approved by: eadler
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D15501

6 years agoImprove defaults for per-CPU kernel console colors, especially with 2
bde [Sat, 2 Jun 2018 14:07:27 +0000 (14:07 +0000)]
Improve defaults for per-CPU kernel console colors, especially with 2
or 4 CPUs.  Add a compile-time option SC_KERNEL_CONS_ATTRS to control the
defaults.

Default to color numbers in reverse order to CPU numbers (instead of
in the same order with white first and wrapping to dark grey), so that
the brightest bright colors are used first.  Don't use dark grey at all;
replace it by dark green.

Syscons has too many compile-time options, but this one is needed in
in case the defaults give something like white on white, or the user
really hates this feature and can't wait to turn it off in rc.

MFC after: next release?

6 years agoUse per-CPU attributes earlier.
bde [Sat, 2 Jun 2018 10:36:30 +0000 (10:36 +0000)]
Use per-CPU attributes earlier.

The per-CPU ts is not initialized early, so the global kernel ts is used
early, but it ony has 1 (normal) attribute.  Switch this to the per-CPU
attribute.

The difference is most visible with EARLY_AP_STARTUP.

Change to using the curcpu macro instead of PCPU_GET(cpuid) in 2 places for
the above and in 1 other place in my old code in syscons.  The function-like
spelling is perhaps better for indicating that curcpu is volatile (unlike
curthread), but for CPU attributes volatility is a feature.

6 years agoOops, the last minute reduction in the clobber list for i386
bde [Sat, 2 Jun 2018 09:59:27 +0000 (09:59 +0000)]
Oops, the last minute reduction in the clobber list for i386
MCOUNT_OVERHEAD() in r334522 was too agressive.  Only mcount exit
preserves %eax and %edx.

6 years agoUse stpcpy instead of home grown solution
eadler [Sat, 2 Jun 2018 08:46:09 +0000 (08:46 +0000)]
Use stpcpy instead of home grown solution

6 years agoFix low-level locking during panics.
bde [Sat, 2 Jun 2018 08:38:59 +0000 (08:38 +0000)]
Fix low-level locking during panics.

The SCHEDULER_STOPPED() hack breaks locking generally, and
mtx_trylock_*() especially.  When mtx_trylock_*() returns nonzero,
naive code version here trusts it to have worked.  But when
SCHEDULER_STOPPED() is true, mtx_trylock_*() returns 1 without doing
anything.  Then mtx_unlock_*() crashes especially badly attempting to
unlock iff the error is detected, since mutex unlocking functions don't
check SCHEDULER_STOPPED().

syscons already didn't trust mtx_trylock_spin(), but it was missing the
logic to turn on sp->kdb_locked when turning off sp->mtx_locked during
panics.  It also used panicstr instead of SCHEDULER_LOCKED because I
thought that panicstr was more fragile.  They only differ for a window
of lines in panic(), and in broken cases where stop_cpus_hard() in panic()
didn't work.

6 years agotop(1): remove wrapper around putchar
eadler [Sat, 2 Jun 2018 07:44:53 +0000 (07:44 +0000)]
top(1): remove wrapper around putchar

This appears to have been written for portability which we no longer
need.

6 years agotop(1): const poison part 2
eadler [Sat, 2 Jun 2018 07:44:50 +0000 (07:44 +0000)]
top(1): const poison part 2

Further reduce the number of warnings emitted by gcc.

6 years agoFinish COMPAT_AOUT support for amd64. It wasn't in any amd64 or MI
bde [Sat, 2 Jun 2018 06:40:15 +0000 (06:40 +0000)]
Finish COMPAT_AOUT support for amd64.  It wasn't in any amd64 or MI
file in /sys/conf, so was unavailable in configurations that don't use
modules, and was not testable or notable in NOTES.  Its normal
configuration (not using a module) is still silently deprecated in
aout(4) by not mentioning it there.

Update i386 NOTES for COMPAT_AOUT.  It is not i386-only, or even very MD.
Sort its entry better.

Finish gzip configuration (but not support) for amd64.  gzip is really
gzipped aout.  It is currently broken even for i386 (a call to vm fails).
amd64 has always attempted to configure and test it, but it depends on
COMPAT_AOUT (as noted).  The bug that it depends on unconfigured files
was not detected since it is configured as a device.  All other optional
image activators are configured properly using an option.

6 years agoFix high resolution kernel profiling just enough to not crash at boot
bde [Sat, 2 Jun 2018 05:48:44 +0000 (05:48 +0000)]
Fix high resolution kernel profiling just enough to not crash at boot
time, especially for SMP.  If configured, it turns itself on at boot
time for calibration, so is fragile even if never otherwise used.

Both types of kernel profiling were supposed to use a global spinlock
in the SMP case.  If hi-res profiling is configured (but not necessarily
used), this was supposed to be optimized by only using it when
necessary, and slightly more efficiently, in asm.  But it was not done
at all for mcount entry where it is necessary.  This caused crashes
in the SMP case when either type of profiling was enabled.  For mcount
exit, it only caused wrong times.  The times were wrongest with an
i8254 timer since using that requires exclusive access to the hardware.
The i8254 timer was too slow to use here 20 years ago and is much less
usable now, but it is the default for the SMP case since TSCs weren't
invariant when SMP was new.  Do the locking in all hi-res SMP cases for
simplicity.

Calibration uses special asms, and the clobber lists in these were sort
of inverted.  They contained the arg and return registers which are not
clobbered, but on amd64 they didn't contain the residue of the call-used
registers which may be clobbered (%r10 and %r11).  This usually caused
hangs at boot time.  This usually affected even the UP case.

6 years agotop(1): const poison
eadler [Sat, 2 Jun 2018 04:37:37 +0000 (04:37 +0000)]
top(1): const poison

top(1) has a number of issues with writing to const strings. Begin
helping this along by marking easy cases as const.

6 years agoFix recent breakages of kernel profiling, mostly on i386 (high resolution
bde [Sat, 2 Jun 2018 04:25:09 +0000 (04:25 +0000)]
Fix recent breakages of kernel profiling, mostly on i386 (high resolution
kernel profiling remains broken).

memmove() was broken using ALTENTRY().  ALTENTRY() is only different from
ENTRY() in the profiling case, and its use in that case was sort of
backwards.  The backwardness magically turned memmove() into memcpy()
instead of completely breaking it.  Only the high resolution parts of
profiling itself were broken.  Use ordinary ENTRY() for memmove().
Turn bcopy() into a tail call to memmove() to reduce complications.
This gives slightly different pessimizations and profiling lossage.
The pessimizations are minimized by not using a frame pointer() for
bcopy().

Calls to profiling functions from exception trampolines were not
relocated.  This caused crashes on the first exception.  Fix this using
function pointers.

Addresses of exception handlers in trampolines were not relocated.  This
caused unknown offsets in the profiling data.  Relocate by abusing
setidt_disp as for pmc although this is slower than necessary and
requires namespace pollution.  pmc seems to be missing some relocations.
Stack traces and lots of other things in debuggers need similar relocations.

Most user addresses were misclassified as unknown kernel addresses and
then ignored.  Treat all unknown addresses as user. Now only user
addresses in the kernel text range are significantly misclassified (as
known kernel addresses).

The ibrs functions didn't preserve enough registers.  This is the only
recent breakage on amd64.  Although these functions are written in
asm, in the profiling case they call profiling functions which are
mostly for the C ABI, so they only have to save call-used registers.
They also have to save arg and return registers in some cases and
actually save them in all cases to reduce complications.  They end up
saving all registers except %ecx on i386 and %r10 and %r11 on amd64.
Saving these is only needed for 1 caller on each of amd64 and i386.
Save them there.  This is slightly simpler.

Remove saving %ecx in handle_ibrs_exit on i386.  Both handle_ibrs_entry
and handle_ibrs_exit use %ecx, but only the latter needed to or did
save it.  But saving it there doesn't work for the profiling case.

amd64 has more automatic saving of the most common scratch registers
%rax, %rcx and %rdx (its complications for %r10 are from unusual use
of %r10 by SYSCALL).  Thus profiling of handle_ibrs_exit_rs() was not
broken, and I didn't simplify the saving by moving the saving of these
registers from it to the caller.

6 years agotop(1): clean up a bit
eadler [Sat, 2 Jun 2018 04:20:42 +0000 (04:20 +0000)]
top(1): clean up a bit

- remove unused defines
- use standard defines for STDOUT
- don't cast for memset
- avoid using (void) cast

6 years agotop(1): help scan-build along a bit
eadler [Sat, 2 Jun 2018 04:08:52 +0000 (04:08 +0000)]
top(1): help scan-build along a bit

Teach scan-build that some arrays are larger than zero, and thus not to
warn.

6 years agotop(1): Use uid_t for uid rather than 'int'
eadler [Sat, 2 Jun 2018 03:54:50 +0000 (03:54 +0000)]
top(1): Use uid_t for uid rather than 'int'

Remove unneeded define while here.

6 years agotop(1): Remove now-invalid NOTE
eadler [Sat, 2 Jun 2018 03:33:02 +0000 (03:33 +0000)]
top(1): Remove now-invalid NOTE

6 years agotop(1): avoid casting malloc
eadler [Sat, 2 Jun 2018 03:31:14 +0000 (03:31 +0000)]
top(1): avoid casting malloc

6 years agotop(1): Use standard boolean rather than homegrown alternative
eadler [Sat, 2 Jun 2018 03:25:15 +0000 (03:25 +0000)]
top(1): Use standard boolean rather than homegrown alternative

6 years agoFix the default number of threads for Flex File layout pNFS client I/O.
rmacklem [Sat, 2 Jun 2018 00:11:26 +0000 (00:11 +0000)]
Fix the default number of threads for Flex File layout pNFS client I/O.

The intent was that the default would be based on number of CPUs, but the
code disabled using taskqueue() by default.
This code is only executed when mounting a NFSv4.1 server that supports the
Flexible File layout for pNFS and, since such servers are rare, this change
shouldn't result in a POLA violation.
(The FreeBSD pNFS server is still a project and the only other one that
 uses Flexible File layout is being developed by Primary Data and I don't
 know if they have even shipped any to customers yet.)
Found while testing the pNFS server.

6 years agotop(1): remove two unneeded headers
eadler [Sat, 2 Jun 2018 00:02:27 +0000 (00:02 +0000)]
top(1): remove two unneeded headers

6 years agotop(1): ansify, style(9). and nits
eadler [Sat, 2 Jun 2018 00:02:15 +0000 (00:02 +0000)]
top(1): ansify, style(9). and nits

- Prefer using ansi prototypes rather than C prototypes
- Keep type on separate line from name of function
- Try to keep things const where possible. This will help get to WARNS=6
- switch to "bool" where it makes sense

6 years agoRemove the "pass" variable from the page daemon control loop.
markj [Sat, 2 Jun 2018 00:01:07 +0000 (00:01 +0000)]
Remove the "pass" variable from the page daemon control loop.

It serves little purpose after r308474 and r329882.  As a side
effect, the removal fixes a bug in r329882 which caused the
page daemon to periodically invoke lowmem handlers even in the
absence of memory pressure.

Reviewed by: jeff
Differential Revision: https://reviews.freebsd.org/D15491

6 years agoOnly check for MAP_32BIT when available.
kib [Fri, 1 Jun 2018 23:50:51 +0000 (23:50 +0000)]
Only check for MAP_32BIT when available.

Reported by: mmacy
Sponsored by: The FreeBSD Foundation
MFC after: 10 days

6 years agoAvoid completing I/O when dumping core after a panic.
markj [Fri, 1 Jun 2018 23:49:32 +0000 (23:49 +0000)]
Avoid completing I/O when dumping core after a panic.

Filesystem or pager completion callbacks are generally non-functional
after a panic and may trigger deadlocks if invoked in this context
(e.g., by attempting to destroying a buffer mapping).  To avoid this
situation, short-circuit I/O completion in biodone().

Reviewed by: imp
Discussed with: mav
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15592

6 years agoDon't export _end on arm64 and riscv.
markj [Fri, 1 Jun 2018 23:42:10 +0000 (23:42 +0000)]
Don't export _end on arm64 and riscv.

These platforms don't support brk() and sbrk(), which are the reason
for exporting _end in the first place.

MFC after: 1 week

6 years agoRemove an inaccuracy from mincore.2.
markj [Fri, 1 Jun 2018 23:40:43 +0000 (23:40 +0000)]
Remove an inaccuracy from mincore.2.

Super pages are supported on non-x86 architectures, so just remove the
incorrect note.  While here, change terminology to be consistent with
mmap.2.

MFC after: 1 week

6 years agoat.man: Bump .Dd missed in r334502
cem [Fri, 1 Jun 2018 22:57:19 +0000 (22:57 +0000)]
at.man: Bump .Dd missed in r334502

Sponsored by: Dell EMC Isilon

6 years agoUpdate other man pages to match leap second reality
cem [Fri, 1 Jun 2018 22:37:59 +0000 (22:37 +0000)]
Update other man pages to match leap second reality

Missed these in r334501; see justification there:

https://svnweb.freebsd.org/base?view=revision&revision=334501

Sponsored by: Dell EMC Isilon

6 years agotouch.1: Update to conform to POSIX 2004
cem [Fri, 1 Jun 2018 22:34:59 +0000 (22:34 +0000)]
touch.1: Update to conform to POSIX 2004

POSIX borrowed the "double leap second" bug from C89.  Double leap seconds can
never happen.  This mistake was present in at least POSIX 1997 and fixed by
POSIX 2004.  I can't find a copy of 2001 online to determine if the bug was
present in that revision.

While here, remove duplicate language between -d and -t.  A few other minor
enhancements and an igor (lint) bugfix.

Further reading:

2018 POSIX (documents -d):
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html

2004 POSIX (documents SS from 0-60):
http://pubs.opengroup.org/onlinepubs/009695399/utilities/touch.html

1997 POSIX/SUSv2 (historical interest, 0-61):
http://pubs.opengroup.org/onlinepubs/007908799/xcu/touch.html

More on this subject (start at "Unix system time and the POSIX standard")
https://www.ucolick.org/~sla/leapsecs/onlinebib.html

And: https://marc.info/?l=openbsd-tech&m=92682843416159&w=2

Reported by: Vishal Sahu <vsahu AT isilon.com>
Sponsored by: Dell EMC Isilon

6 years agoRemove support for SYS_sys_exit in favor of SYS_exit.
brooks [Fri, 1 Jun 2018 22:09:27 +0000 (22:09 +0000)]
Remove support for SYS_sys_exit in favor of SYS_exit.

SYS_exit has been defined in the repo since 1994 except for a brief
window when SYS_sys_exit was defined in 2000.

6 years agoOnly a small subset of mmap(2)'s flags should be used in combination with
alc [Fri, 1 Jun 2018 21:37:42 +0000 (21:37 +0000)]
Only a small subset of mmap(2)'s flags should be used in combination with
the flag MAP_GUARD.  Rather than enumerating the flags that are not
allowed, enumerate the flags that are allowed.  The list of allowed flags
is much shorter and less likely to change.  (As an aside, one of the
previously enumerated flags, MAP_PREFAULT, was not even a legal flag for
mmap(2).  However, because of an earlier check within kern_mmap(), this
misuse of MAP_PREFAULT was harmless.)

Reviewed by: kib
MFC after: 10 days

6 years agoIncrease powerpc64 KVA from ~7.25GB to 32GB
jhibbits [Fri, 1 Jun 2018 21:37:20 +0000 (21:37 +0000)]
Increase powerpc64 KVA from ~7.25GB to 32GB

This will let us use much more KVA for ZFS ARC where needed.  This may be
incresed in the future if memory requirements increase.

Discussed with: nwhitehorn

6 years agoLimit the retransmission timer for SYN-ACKs by TCPTV_REXMTMAX.
tuexen [Fri, 1 Jun 2018 21:24:27 +0000 (21:24 +0000)]
Limit the retransmission timer for SYN-ACKs by TCPTV_REXMTMAX.

Use the same logic to handle the SYN-ACK retransmission when sent from
the syn cache code as when sent from the main code.

MFC after: 3 days
Sponsored by: Netflix, Inc.

6 years agoaudit(4): add tests for the fd audit class
asomers [Fri, 1 Jun 2018 21:24:10 +0000 (21:24 +0000)]
audit(4): add tests for the fd audit class

The only syscalls in this class are rmdir, unlink, unlinkat, rename, and
renameat.  Also, set is_exclusive for all audit(4) tests, because they can
start and stop auditd.

Submitted by: aniketp
MFC after: 2 weeks
Sponsored by: Google, Inc. (GSoC 2018)
Differential Revision: https://reviews.freebsd.org/D15647

6 years agoindent(1): improve an error message
pstef [Fri, 1 Jun 2018 20:45:35 +0000 (20:45 +0000)]
indent(1): improve an error message

When producing a "[...] requires a parameter" error, provide the recognized
name of the option instead of argument provided.

6 years agoEnsure net.inet.tcp.syncache.rexmtlimit is limited by TCP_MAXRXTSHIFT.
tuexen [Fri, 1 Jun 2018 19:58:19 +0000 (19:58 +0000)]
Ensure net.inet.tcp.syncache.rexmtlimit is limited by TCP_MAXRXTSHIFT.

If the sysctl variable is set to a value larger than TCP_MAXRXTSHIFT+1,
the array tcp_syn_backoff[] is accessed out of bounds.

Discussed with: jtl@
MFC after: 3 days
Sponsored by: Netflix, Inc.

6 years agoindent(1): restore working -pcs
pstef [Fri, 1 Jun 2018 19:56:41 +0000 (19:56 +0000)]
indent(1): restore working -pcs

My previous indent(1) commit accidentally broke the -pcs option (which adds
space between function name and opening parenthesis in function calls) by
copying all but one of a few conditions in an if clause. Reinstate the
condition.

Add a regression test to lower the chances of breaking it again.

Correct a comment with description of what the option does.

6 years agoAdd the BindConnectiontoSession operation to the NFSv4.1 server.
rmacklem [Fri, 1 Jun 2018 19:47:41 +0000 (19:47 +0000)]
Add the BindConnectiontoSession operation to the NFSv4.1 server.

Under some fairly unusual circumstances, the Linux NFSv4.1 client is
doing a BindConnectiontoSession operation for TCP connections.
It is also used by the ESXi6.5 NFSv4.1 client.
This patch adds this operation to the NFSv4.1 server.

Reported by: andreas.nagy@frequentis.com
Tested by: andreas.nagy@frequentis.com
MFC after: 2 weeks

6 years agoAdd PNP_INFO to aac
imp [Fri, 1 Jun 2018 19:42:59 +0000 (19:42 +0000)]
Add PNP_INFO to aac

Reviewed by: imp, chuck
Submitted by: Lakhan Shiva Kamireddy <lakhanshiva@gmail.com>
Sponsored by: Google, Inc. (GSoC 2018)

6 years agoUpdate the sysctl(9) manpage to indicate that <sys/param.h> is required
jtl [Fri, 1 Jun 2018 16:47:39 +0000 (16:47 +0000)]
Update the sysctl(9) manpage to indicate that <sys/param.h> is required
instead of <sys/types.h>.  (<sys/sysctl.h> includes NULL, which is defined
with <sys/param.h> and not <sys/types.h>.)

Sponsored by: Netflix

6 years agocxgbe(4): Include full duplex mediaopt in media that can be reported as
np [Fri, 1 Jun 2018 16:46:29 +0000 (16:46 +0000)]
cxgbe(4): Include full duplex mediaopt in media that can be reported as
active.  Always report full duplex in active media.

Sponsored by: Chelsio Communications

6 years agoUnbreak 32-bit binaries on powerpc64
jhibbits [Fri, 1 Jun 2018 16:31:05 +0000 (16:31 +0000)]
Unbreak 32-bit binaries on powerpc64

Recently a change was made which broke loading 32-bit binaries on powerpc64,
with an assertion in ld-elf32.so.1:

ld-elf32.so.1: assert failed:
/usr/local/poudriere/jails/ppc64/usr/src/libexec/rtld-elf/rtld.c:390

It turns out Elf32_AuxInfo was broken for a very long time on powerpc64, as
it uses long and pointers, which are both 64 bits on powerpc64, and only
manifested with the recent work on auxargs.

6 years agoaudit(4): Add tests for the fw class of syscalls.
asomers [Fri, 1 Jun 2018 16:23:47 +0000 (16:23 +0000)]
audit(4): Add tests for the fw class of syscalls.

truncate and ftruncate are the only syscalls in this class, apart from
certain variations of open and openat, which will be handled in a different
file.

Submitted by: aniketp
MFC after: 2 weeks
Sponsored by: Google, Inc. (GSoC 2018)
Differential Revision: https://reviews.freebsd.org/D15640

6 years agoANSIfy sys/kern
emaste [Fri, 1 Jun 2018 13:26:45 +0000 (13:26 +0000)]
ANSIfy sys/kern

6 years agopowerpc64: Avoid overwriting initrd area
leitao [Fri, 1 Jun 2018 12:43:13 +0000 (12:43 +0000)]
powerpc64: Avoid overwriting initrd area

Currently kexec loads an initrd file into the main memory but does not
mark that region as reserved, thus the area is not protected.

If any initrd/md file is loaded from kexec/petitboot, the region might become
corarupted/overwritten since FreeBSD does not know the region is 'reserved'.

This patch simply adds the initrd area as a reserved memory region.

Approved by: jhibbits
Differential Revision: https://reviews.freebsd.org/D15610

6 years agoImplement the __sg_alloc_table_from_pages() function based on the existing
hselasky [Fri, 1 Jun 2018 12:09:07 +0000 (12:09 +0000)]
Implement the __sg_alloc_table_from_pages() function based on the existing
sg_alloc_table_from_pages() function in the LinuxKPI.

This basically allow segments to have a limit, max_segment.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

6 years agoImplement radix_tree_iter_delete() in the LinuxKPI.
hselasky [Fri, 1 Jun 2018 11:42:09 +0000 (11:42 +0000)]
Implement radix_tree_iter_delete() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

6 years agoImprove high resolution timer support in the LinuxKPI.
hselasky [Fri, 1 Jun 2018 11:33:14 +0000 (11:33 +0000)]
Improve high resolution timer support in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

6 years agoAdd more GFP macro definitions in the LinuxKPI.
hselasky [Fri, 1 Jun 2018 11:14:59 +0000 (11:14 +0000)]
Add more GFP macro definitions in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

6 years agoindent(1): don't add unneeded space to function pointer declarations
pstef [Fri, 1 Jun 2018 09:58:44 +0000 (09:58 +0000)]
indent(1): don't add unneeded space to function pointer declarations

If the current token is an opening parenthesis, it's either a function call
(or sizeof or offsetof) or a declaration. The former doesn't need a space
before the parenthesis.

6 years agocall AcpiLeaveSleepStatePrep after re-enabling interrupts
avg [Fri, 1 Jun 2018 09:44:23 +0000 (09:44 +0000)]
call AcpiLeaveSleepStatePrep after re-enabling interrupts

I want to do this change because this call (actually,
AcpiHwLegacyWakePrep) does a memory allocation and ACPI namespace
evaluation.  Although it is not very likely to run into any trouble, it
is still not safe to make those calls with interrupts disabled.
witness(4) and malloc(9) do not currently check for a context with
interrupts disabled via intr_disable and we lack a facility for doing
that.  So, those unsafe operations fly under the radar.  But if
intr_disable in acpi_EnterSleepState was replaced with spinlock_enter
(which it probably should be), then witness and malloc would immediately
complain.

Also, AcpiLeaveSleepStatePrep is documented as called when interrupts
are enabled.  It used to require disabled interrupts, but that
requirement was changed a long time ago when support for _BFS and _GTS
was removed from ACPICA.

The ACPI wakeup sequence is very sensitive to changes. I consider this
change to be correct, but there can be fallouts from it.

What AcpiHwLegacyWakePrep essentially does is writing a value
corresponding to S0 into SLP_TYPx bits of PM1 Control Register(s).
According to ACPI specifications that write should be a NOP as SLP_EN
bit is not set.  But I see in some chipset specifications that they
allow to ignore SLP_EN altogether and to act on a change of SLP_TYPx
alone.

Also, there are a couple of accesses to ACPI hardware before the new
location of the call to AcpiLeaveSleepStatePrep.  One is to clear the
power button status and the other is to enable SCI.  So, the move may
affect the interaction between then OS and ACPI platform.

I have not seen any regressions on my test system, but it's a desktop.

MFC after: 5 weeks

6 years agoindent(1): don't indent typedef declarations as object declarations
pstef [Fri, 1 Jun 2018 09:41:15 +0000 (09:41 +0000)]
indent(1): don't indent typedef declarations as object declarations

6 years agoindent(1): consider tab characters when forcing a newline after a comma
pstef [Fri, 1 Jun 2018 09:32:42 +0000 (09:32 +0000)]
indent(1): consider tab characters when forcing a newline after a comma

6 years agoSet bDeviceClass properly for composite device (template 8). There should
trasz [Fri, 1 Jun 2018 09:17:20 +0000 (09:17 +0000)]
Set bDeviceClass properly for composite device (template 8).  There should
be no functional change.

PR: 203289
Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoindent(1): identifiers inside parentheses are not declarations
pstef [Fri, 1 Jun 2018 08:54:51 +0000 (08:54 +0000)]
indent(1): identifiers inside parentheses are not declarations

Also make lparen position calculation consider tab stops.

This improves function pointer typedef formatting.

6 years agotop(1): Display of TID when using 'H' flag
eadler [Fri, 1 Jun 2018 05:51:40 +0000 (05:51 +0000)]
top(1): Display of TID when using 'H' flag

Some users prefer seeing the TID when viewing individual threads. This
makes sense as the PID will be the same for multiple entries. An attempt
was made to include both, but there is insufficient room. As such, using
the TID.

While here, rename the header variables to be more understandable.

Discussed with: mmacy
Reported on: 2009-10-07

6 years agoservice(1): Improve manual page
eadler [Fri, 1 Jun 2018 04:14:16 +0000 (04:14 +0000)]
service(1): Improve manual page

* Sort options..
* Fix some typos.
* Use one Bd macro for code blocks instead of a bunch of Dl macros.
* Improve formatting.
* Clarify 'jail' argument

PR: 228552
Submitted by: 0mp
MFC After: 3 weeks

6 years agoaudit(4): Add tests for the fr class of syscalls
asomers [Fri, 1 Jun 2018 01:37:07 +0000 (01:37 +0000)]
audit(4): Add tests for the fr class of syscalls

readlink and readlinkat are the only syscalls in this class.  open and
openat are as well, but they'll be handled in a different file.  Also, tidy
up the copyright headers of recently added files in this area.

Submitted by: aniketp
MFC after: 2 weeks
Sponsored by: Google, Inc. (GSoC 2018)
Differential Revision: https://reviews.freebsd.org/D15636

6 years agocxgbe(4): Retire an old check.
np [Fri, 1 Jun 2018 01:05:34 +0000 (01:05 +0000)]
cxgbe(4): Retire an old check.

6 years agoUpdate FreeBSD_version to reflect removal of in-kernel pmc tables for Intel
mmacy [Fri, 1 Jun 2018 00:49:20 +0000 (00:49 +0000)]
Update FreeBSD_version to reflect removal of in-kernel pmc tables for Intel

6 years agopmc: add list-events command
mmacy [Fri, 1 Jun 2018 00:45:59 +0000 (00:45 +0000)]
pmc: add list-events command

6 years agolibpmc: allow substring for list and add function for printing event details
mmacy [Fri, 1 Jun 2018 00:45:53 +0000 (00:45 +0000)]
libpmc: allow substring for list and add function for printing event details

6 years agolibpmc: Intel doesn't require runtime counter table init
mmacy [Fri, 1 Jun 2018 00:45:48 +0000 (00:45 +0000)]
libpmc: Intel doesn't require runtime counter table init