markj [Tue, 12 Dec 2017 17:29:34 +0000 (17:29 +0000)]
Address a possible lost wakeup for gmirror events.
g_mirror_event_send() acquires the I/O queue lock to deliver a wakeup
to the worker thread, and this is done after enqueuing the event.
So it's sufficient to check the event queue before atomically releasing
the queue lock and going to sleep.
mmel [Tue, 12 Dec 2017 11:25:30 +0000 (11:25 +0000)]
Rework alignment handling in __libc_allocate_tls() for Variant I of TLS layout.
There are two versions of variant I of TLS
- ARM and aarch64 uses original version of variant I here TP points to
start of TCB followed by aligned TLS segment. Both TCB and TLS must
be aligned to alignment of TLS section. The TCB[0] points to DTV vector
and DTV values are real addresses (without bias).
- MIPS, PowerPC and RISC-V use modified version of variant I,
where TP points (with bias) to TLS and TCB immediately precedes TLS
without any alignment gap. Only TLS should be aligned. The TCB[0]
points to DTV vector and DTV values are biased by constant value (0x8000)
from real addresses.
Take all this in account when allocating memory for TLS structures.
dim [Mon, 11 Dec 2017 20:04:40 +0000 (20:04 +0000)]
Pull in r320396 from upstream clang trunk (by Malcolm Parsons):
[Sema] Fix crash in unused-lambda-capture warning for VLAs
Summary:
Clang was crashing when diagnosing an unused-lambda-capture for a VLA
because From.getVariable() is null for the capture of a VLA bound.
Warning about the VLA bound capture is not helpful, so only warn for
the VLA itself.
shurd [Mon, 11 Dec 2017 20:01:28 +0000 (20:01 +0000)]
Increment encap_pad_mbuf_fail when m_dup() fails in padding
Previously, the counter was only incremented when m_append() failed. Since
the function can also fail on m_dup() now, increment the counter there as
well.
markj [Mon, 11 Dec 2017 19:21:39 +0000 (19:21 +0000)]
Pass the trap frame to fasttrap hooks.
The DTrace fasttrap entry points expect a struct reg containing the
register values of the calling thread. Perform the conversion in
fasttrap rather than in the trap handler: this reduces the number of
ifdefs and avoids wasting stack space for traps that don't involve
DTrace.
kevans [Mon, 11 Dec 2017 18:04:04 +0000 (18:04 +0000)]
Add generic 'syscon' driver
Upstream dts for allwinner will require a syscon driver, since the emac node
coming in 4.15 will be using xref to /soc/syscon for configuring the emac
clock. Add a generic syscon driver to attach to /soc/syscon for use by
if_awg, providing basic read/write functionality to consumers.
syscon driver will also be used by arm64 at least for A64+H5 emac/if_awg.
Written by: mmel
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D13295
imp [Mon, 11 Dec 2017 16:18:05 +0000 (16:18 +0000)]
Fix regression with lua import
Don't print when we can't find a file. Copy it instead to the error
buffer. Higher level routines determine if it's appropriate to print
the error message.
Also, remove dead code (labeled bogusly lost functionality) since we
never used that functionality. Remove unused arg from interact() too.
markj [Mon, 11 Dec 2017 15:33:24 +0000 (15:33 +0000)]
Use a dedicated counter for inactive queue scans.
The laundry thread keeps track of the number of inactive queue scans
performed by the page daemon, and was previously using the v_pdwakeups
counter to count them. However, in some cases the inactive queue may
be scanned multiple times after a single wakeup, so it's more accurate
to use a dedicated counter.
bapt [Mon, 11 Dec 2017 14:54:42 +0000 (14:54 +0000)]
Remove hard coded number of lun definition
The number of lun exposed is now exposed via sysctl by the kernel.
Use that number in ctlstat instead of the hardcoded version
Add a backward compatibility in case the sysctl(2) request fails.
This also allows ctlstat -l 1118 to actually work when having more than
1024 luns.
Reviewed by: avg, manu (both before the backward compatibility addition)
Approved by: avg, manu (both before the backward compatibility addition)
MFC after: 2 weeks
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D13446
kib [Mon, 11 Dec 2017 11:59:45 +0000 (11:59 +0000)]
ofed: Define barriers for mips and arm.
I used the strongest barriers available on the architectures, so if
the future analysis show that it is excessive, the barriers could be
relaxed. Still, it is unlikely that it is meaningful to run IB on 32bit
ARM or current MIPS machines, so the change is to make WITH_OFED to pass
tinderbox.
kib [Mon, 11 Dec 2017 11:57:46 +0000 (11:57 +0000)]
ofed: Remove duplicated symbols from the version file.
ld.bfd accepts multiple listing of the same symbol in the version script.
lld is stricter and errors out. Since arm64 and sometimes amd64 use lld,
we should correct this cosmetic issue.
cem [Mon, 11 Dec 2017 04:32:37 +0000 (04:32 +0000)]
i386: Bump KSTACK_PAGES default to match amd64
Logically, extend r286288 to cover all threads, by default.
The world has largely moved on from i386. Most FreeBSD users and developers
test on amd64 hardware. For better or worse, we have written a non-trivial
amount of kernel code that relies on stacks larger than 8 kB, and it "just
works" on amd64, so there has been little incentive to shrink it.
amd64 had its KSTACK_PAGES bumped to 4 back in Peter's initial AMD64 commit,
r114349, in 2003. Since that time, i386 has limped along on a stack half
the size. We've even observed the stack overflows years ago, but neglected
to fix the issue; see the 20121223 and 20150728 entries in UPDATING.
If anyone is concerned with this change, I suggest they configure their
AMD64 kernels with KSTACK_PAGES 2 and fix the fallout there first. Eugene
has identified a list of high stack usage functions in the first PR below.
imp [Mon, 11 Dec 2017 02:44:15 +0000 (02:44 +0000)]
Start adding commands that I know are good to build up residual
knowledge about qemu's quirks. Other qemu commands are possible, but
this is the quickest for testing.
imp [Mon, 11 Dec 2017 02:44:10 +0000 (02:44 +0000)]
Add -I to just run the imaging part of nanobsd so you can test out
changes to the packaging part of nanobsd more easily, or experiment
with the image contents w/o regenerating a whole new image tree. This
can save minutes when you don't need to do the installworld /
installkernel, etc.
imp [Mon, 11 Dec 2017 02:43:56 +0000 (02:43 +0000)]
Fix the std-x86 layout to produce a bootable system. Due to
limitations in mkimg we're still not quite to where I'd like to be
(I'd like to put s3 first on the disk, then s1, but mkimg won't allow
that currently). However, the resulting image now boots with qemu using:
We'll need tweaks to create a specialized /etc/rc.d/growfs that can
create a properly grown image for either the simple or ping-pong
cases, but that will be later. Switched to pure serial console (-h)
instead of video or serial (-P) since that fits this usecase better.
ian [Sun, 10 Dec 2017 23:06:45 +0000 (23:06 +0000)]
When building for arm arches, set PKGALIGN to the max cache line size
supported by the arch, to meet u-boot's requirement that I/O be done
in cache-aligned chunks.
ian [Sun, 10 Dec 2017 21:51:27 +0000 (21:51 +0000)]
Save and restore r9 register in arm ubldr. In old gcc 4.2, r9 was a callee-
saved register, but in arm EABI it may be either callee-saved or dedicated
to some special purpose (such as a TLS pointer). It appears clang does not
treat it as a callee-saved register (instead using it as another work
register, similar to r12).
Another important side effect of these changes is that saving an extra
register in the push/pop statements keeps the stack aligned to an 8-byte
boundary during the self_reloc() call, as it always should have been.
As stated in the PR...
Essentially the important caller-saved registers are pushed (r0, r1, r9, lr)
before the relocation call, and popped after. Then r8/r9 are saved as usual
for the syscall trampoline, and lr is stored in r8 (now free) as a
callee-saved value before calling into `main`.
The call to `main` can no longer be a tail call because we must restore r9
especially after main returns (although since we have used r8 to hold lr we
must also restore this).
ian [Sun, 10 Dec 2017 18:55:42 +0000 (18:55 +0000)]
Do not give up if writing to the chip's control and status registers fails
during startup. When a brand new chip leaves the factory, it is in a
special power-saving mode that disables most functions on the chip to
save battery power. The chip is stuck in this mode until the first write
to the time registers, which automatically clears the special power-saving
mode and starts the oscillator.
Also, the day-of-week register in this chip counts 1-7, not 0-6, so write
the values accordingly.
These changes are based on the patch submitted by Brian Scott, but I
elimated warnings since this condition is expected, and added some comments,
and so in general blame me for any mistakes.
cem [Sun, 10 Dec 2017 17:56:03 +0000 (17:56 +0000)]
wc(1): Restore regular file char count fast path
fstat(2) is going to be a lot faster than reading all of the bytes in a
file, if we just need a character count for a regular file. This fast path
was accidentally broken in r326736.
dim [Sun, 10 Dec 2017 16:42:59 +0000 (16:42 +0000)]
Document the existence and precision of the remaining long double
functions for which an imprecise stub implementation was added in
r255294, namely powl(3) and tgammal(3).
jhibbits [Sun, 10 Dec 2017 04:43:27 +0000 (04:43 +0000)]
Retrieve the page outside of holding locks
pmap_track_page() only works with physical memory pages, which have a
constant vm_page_t address. Microoptimize pmap_track_page() to perform one
less operation under the lock.
cem [Sat, 9 Dec 2017 21:55:19 +0000 (21:55 +0000)]
wc(1): Extend non-controversial optimizations to '-c' mode
wc(1)'s slow path for counting words or multibyte characters requires
conversion of the 8-bit input stream to wide characters. However, a faster
path can be used for counting only lines ('-l' -- newlines have the same
representation in all supported encodings) or bytes ('-c').
The existing line count optimization was not used if the input was the
implicit stdin. Additionally, it wasn't used if only byte counting was
requested. This change expands the fast path to both of these scenarios.
Expanding the buffer size from 64 kB helps reduce the number of read(2)
calls needed, but exactly what impact that change has and what size to
expand the buffer to are still under discussion.
rmacklem [Sat, 9 Dec 2017 21:04:56 +0000 (21:04 +0000)]
Define macros used by the pNFS server code.
This commit defines some macros used by the pNFS server code.
They will not be used until the main pNFS server code merge occurs,
which will probably be in April 2018.
karels [Sat, 9 Dec 2017 17:27:36 +0000 (17:27 +0000)]
gifconfig_gif0 no longer works, document replacement
rc.conf(5) documents the gifconfig_<interface> keyword, which is
no longer implemented. Document the replacement, which works with
cloned_interfaces as well.
Reviewed by: dab
Group Reviwers: manpages
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D13130
zeising [Sat, 9 Dec 2017 15:59:10 +0000 (15:59 +0000)]
Improve options and error handling.
Improve options handling and error out if multiple mutually exclusive
options are passed to acpiconf. Switch from using atoi() to strtol() for
argument parsing, and add error checking and handling, instead of blindly
trusting that the integer conversion is OK.
Cange err() to errx() in once case, the errno value was garbage there.
markj [Sat, 9 Dec 2017 15:47:26 +0000 (15:47 +0000)]
Fix the act_scan_laundry_weight mechanism.
r292392 modified the active queue scan to weigh clean pages differently
from dirty pages when attempting to meet the inactive queue target. When
r306706 was merged into the PQ_LAUNDRY branch, this mechanism was
broken. Fix it by scalaing the correct page shortage variable.
markj [Sat, 9 Dec 2017 15:44:30 +0000 (15:44 +0000)]
Provide a sysctl to force synchronous initialization of inode blocks.
FFS performs asynchronous inode initialization, using a barrier write
to ensure that the inode block is written before the corresponding
cylinder group header update. Some GEOMs do not appear to handle
BIO_ORDERED correctly, meaning that the barrier write may not work as
intended. The sysctl allows one to work around this problem at the
cost of expensive file creation on new filesystems. The default
behaviour is unchanged.
trasz [Sat, 9 Dec 2017 15:34:40 +0000 (15:34 +0000)]
Move the DIAGNOSTIC check for lost iSCSI PDUs from icl_conn_close()
to icl_conn_free(). It's perfectly valid for the counter to be non-zero
in the former.
eadler [Sat, 9 Dec 2017 08:21:29 +0000 (08:21 +0000)]
arc lint: Explain linting explain
shell scripts in scripts don't need
to be chmod +x to work. In fact most are not.
Of the tests I found from a simple search:
65 are chmod +x
84 are chmod -x
imp [Sat, 9 Dec 2017 06:52:20 +0000 (06:52 +0000)]
Import Netflix's efibootmgr to help manage UEFI boot variables
efibootmgr manages the UEFI BootXXXX variables that implement the UEFI
Boot Manager protocol defined in the UEFI standards. It is modeled
after the Linux program of the same name with a mostly compatible set
of command line options. Since there's a fair amount of OS specifioc
code due to differeing names and methods of doing things, the
compatibility isn't 100%.
Basic functionality is implemented, though the more advanced next boot
functionality that's been defined elsewhere is unimplemented.
Submitted by: Matt Williams (with unix / efi path xlate by me)
Sponsored by: Netflix
Now that the POSIX working group is going to require that basename(3)
and dirname(3) are thread-safe in future revisions of the standard,
there is even less of a need to provide basename_r(3). Remove this
function to prevent people from writing code that only builds on
FreeBSD and Bionic.
Removing this function seems to break exactly one port: sbruno@'s
qemu-user-static. I will send him a pull request on GitHub in a bit.
__FreeBSD_version will not be bumped, as any value from 2017 can be used
to test for the presence of a thread-safe basename(3)/dirname(3).
shurd [Fri, 8 Dec 2017 18:43:31 +0000 (18:43 +0000)]
Handle read-only mbufs in iflib ether pad function
If ethernet padding is enabled, and a read-only mbuf is passed,
it would modify the mbuf using m_append(). Instead, call m_dup() and
append to the new packet.
jhibbits [Fri, 8 Dec 2017 03:49:53 +0000 (03:49 +0000)]
Remove PTE VA mappings for tracked pages in 64-bit mode
This was done in 32-bit mode, but not duplicated when 64-bit mode was
brought in. Without this, stale mappings can be left, leading to odd
crashes when the wrong VA is checked in XX_PhysToVirt() (dpaa(4)).
nwhitehorn [Fri, 8 Dec 2017 00:57:13 +0000 (00:57 +0000)]
Support mounted boot partitions in the installer. This allows the platform
layer, for example, to specify that the EFI boot partition should be
mounted at /efi and formatted normally with newfs_msdos rather than
splatted to from /boot/boot1.efifat.
This commit adds only the API for this; actual platform use will come later.
tuexen [Thu, 7 Dec 2017 22:19:08 +0000 (22:19 +0000)]
Retire SCTP_WITH_NO_CSUM option.
This option was used in the early days to allow performance measurements
extrapolating the use of SCTP checksum offloading. Since this feature
is now available, get rid of this option.
This also un-breaks the LINT kernel. Thanks to markj@ for making me
aware of the problem.
kib [Thu, 7 Dec 2017 09:05:34 +0000 (09:05 +0000)]
Fix livelock in ufsdirhash_create().
When more than one thread enters ufsdirhash_create() for the same
directory and the inode dirhash is instantiated, but the dirhash' hash
is not, all of them lock the dirhash shared and then try to upgrade.
Since there are several threads owning the lock shared, upgrade fails
and the same attempt is repeated, ad infinitum.
To break the lockstep, lock the dirhash in exclusive mode after the
failed try-upgrade.
bde [Thu, 7 Dec 2017 07:55:38 +0000 (07:55 +0000)]
Move instantiation of msgbufp from 9 MD files to subr_prf.c.
This variable should be pure MI except possibly for reading it in MD
dump routines. Its initialization was pure MD in 4.4BSD, but FreeBSD
changed this in r36441 in 1998. There were many imperfections in
r36441. This commit fixes only a small one, to simplify fixing the
others 1 arch at a time. (r47678 added support for
special/early/multiple message buffer initialization which I want in
a more general form, but this was too fragile to use because hacking
on the msgbufp global corrupted it, and was only used for 5 hours in
-current...)