]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agozfsboot: vdev_read_pad2 does allocate buffer with wrong size
tsoome [Wed, 5 Feb 2020 11:02:00 +0000 (11:02 +0000)]
zfsboot: vdev_read_pad2 does allocate buffer with wrong size

vdev_read_pad2() does read VDEV_PAD_SIZE of data, and will copy size bytes
of it, hence, we need buffer of VDEV_PAD_SIZE bytes.

Issue introduced in r357497.

Reported by: se

4 years agovdev_read_pad2: freeing wrong pointer
tsoome [Wed, 5 Feb 2020 05:42:42 +0000 (05:42 +0000)]
vdev_read_pad2: freeing wrong pointer

Shoud free previously allocated tmp buffer instead. Issue introduced in
r357497.

Reported by: rpokala

4 years agoAdd RELNOTES entry for various daemons pulling in environment variables
kevans [Wed, 5 Feb 2020 04:43:58 +0000 (04:43 +0000)]
Add RELNOTES entry for various daemons pulling in environment variables

4 years agocron(8): set the environment variables of the user and/or login class
kevans [Wed, 5 Feb 2020 04:35:54 +0000 (04:35 +0000)]
cron(8): set the environment variables of the user and/or login class

Prior to processing environment variable set in the crontab file as those
should be of higher precedent, pull in the user or login class environment.

This is another supporting feature for allowing one to configure system-wide
settings that may affect both regular cron jobs as well as services.

This is the final part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agoservice(8): set the environment of the "daemon" class before invoking
kevans [Wed, 5 Feb 2020 04:32:49 +0000 (04:32 +0000)]
service(8): set the environment of the "daemon" class before invoking

As mentioned in r357562, this gives the user a single place to configure
environment variables that need to be used for various services -- the
"daemon" class -- for, e.g., configuring a system-wide HTTP proxy.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agoenv(1): grow -L user/class and -U user/class options
kevans [Wed, 5 Feb 2020 04:29:55 +0000 (04:29 +0000)]
env(1): grow -L user/class and -U user/class options

This allows one to set the environment of the specified user either from
login.conf alone (-L) or both login.conf and ~/.login_conf if present (-U).

This is a supporting feature to allow service(8) to pull in the environment
of the "daemon" class before invoking the rc script.

This is a part of D21481.

Submitted by: Andrew Gierth < andrew_tao173.riddles.org.uk>

4 years agoinit(8): set environment variables from the "daemon" class as well
kevans [Wed, 5 Feb 2020 04:27:44 +0000 (04:27 +0000)]
init(8): set environment variables from the "daemon" class as well

Specifically, when running /etc/rc. This allows one to specify via
login.conf(5) an environment that should be used when running services to
ease, e.g., setting up env vars for an HTTP proxy consistently across cron
and services alike.

Future changes will extend cron(8)/service(8) to use environment vars
pecified in login.conf(5) as well to promote a more cohesive experience.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agologin.conf(5): set a default PATH for the daemon class
kevans [Wed, 5 Feb 2020 04:27:08 +0000 (04:27 +0000)]
login.conf(5): set a default PATH for the daemon class

This is a sensible default used by, e.g., cron(8), and useful if one wanted
to honor it.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agologin.conf(5): split MAIL env var out into a "mail" capability
kevans [Wed, 5 Feb 2020 04:17:14 +0000 (04:17 +0000)]
login.conf(5): split MAIL env var out into a "mail" capability

This allows it to be easily suppressed in, e.g., the "daemon" class where it
will not be properly expanded.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agoI doubt anybody in the world uses ng_device, but its write method should
glebius [Wed, 5 Feb 2020 03:07:20 +0000 (03:07 +0000)]
I doubt anybody in the world uses ng_device, but its write method should
also enter the network epoch when sending data from user level to netgraph.

4 years agoEnter the network epoch when ng_socket sends data or control from user
glebius [Wed, 5 Feb 2020 03:06:29 +0000 (03:06 +0000)]
Enter the network epoch when ng_socket sends data or control from user
land to the netgraph and potentially further down the network stack.

4 years agonetgraph(4) callouts need to be executed in the network epoch.
glebius [Wed, 5 Feb 2020 02:53:40 +0000 (02:53 +0000)]
netgraph(4) callouts need to be executed in the network epoch.

4 years agoO_SEARCH tests: plug trivial fd leak
kevans [Wed, 5 Feb 2020 02:30:46 +0000 (02:30 +0000)]
O_SEARCH tests: plug trivial fd leak

Coverity correctly reports this as a resource leak. It's an admittedly minor
one, but plug it anyways.

This has been submitted upstream as misc/54939.

CID: 978288

4 years agofd: always nullify *fdp in fget* routines
mjg [Wed, 5 Feb 2020 00:20:26 +0000 (00:20 +0000)]
fd: always nullify *fdp in fget* routines

Some consumers depend on the pointer being NULL if an error is returned.

The guarantee got broken in r357469.

Reported by: https://syzkaller.appspot.com/bug?extid=0c9b05e2b727aae21eef
Noted by: markj

4 years agocxgbe(4): Add a knob to allow netmap tx traffic to be checksummed by
np [Wed, 5 Feb 2020 00:13:15 +0000 (00:13 +0000)]
cxgbe(4): Add a knob to allow netmap tx traffic to be checksummed by
the hardware.

hw.cxgbe.nm_txcsum=1

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Allow nm_black_hole and nm_cong_drop to be set at any time.
np [Wed, 5 Feb 2020 00:08:58 +0000 (00:08 +0000)]
cxgbe(4): Allow nm_black_hole and nm_cong_drop to be set at any time.

The cong_drop setting will apply to queues created after the setting is
changed and not to existing queues.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Report accurate rx_buf_maxsize to netmap.
np [Tue, 4 Feb 2020 23:55:21 +0000 (23:55 +0000)]
cxgbe(4): Report accurate rx_buf_maxsize to netmap.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agouma: multipage chicken switch
rlibby [Tue, 4 Feb 2020 22:40:45 +0000 (22:40 +0000)]
uma: multipage chicken switch

Add a switch to allow disabling multipage slabs, in order to facilitate
measuring memory usage and performance effects.  The tunable
vm.debug.uma_multipage_slabs defaults to 1 and can be set to 0 to
disable.  The name may change soon.

Reviewed by: markj (previous version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23487

4 years agouma: grow slabs to enforce minimum memory efficiency
rlibby [Tue, 4 Feb 2020 22:40:34 +0000 (22:40 +0000)]
uma: grow slabs to enforce minimum memory efficiency

Memory efficiency can be poor with awkward item sizes (e.g. 1/2 or 1
page size + epsilon).  In order to achieve a minimum memory efficiency,
select a slab size with a potentially larger number of pages if it
yields a lower portion of waste.

This may mean using page_alloc instead of uma_small_alloc, which could
be more costly.

Discussed with: jeff, mckusick
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23239

4 years agouma: convert mbuf_jumbo_alloc to UMA_ZONE_CONTIG & tag others
rlibby [Tue, 4 Feb 2020 22:40:23 +0000 (22:40 +0000)]
uma: convert mbuf_jumbo_alloc to UMA_ZONE_CONTIG & tag others

Remove mbuf_jumbo_alloc and let large mbuf zones use the new uma default
contig allocator (a copy of mbuf_jumbo_alloc).  Tag other zones which
require contiguous objects, even if they don't use the new default
contig allocator, so that uma knows about their constraints.

Reviewed by: jeff, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23238

4 years agouma: add UMA_ZONE_CONTIG, and a default contig_alloc
rlibby [Tue, 4 Feb 2020 22:40:11 +0000 (22:40 +0000)]
uma: add UMA_ZONE_CONTIG, and a default contig_alloc

For now, copy the mbuf allocator.

Reviewed by: jeff, markj (previous version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23237

4 years agouma: pcpu_page_free needs to startup_free pages from startup_alloc
rlibby [Tue, 4 Feb 2020 22:39:58 +0000 (22:39 +0000)]
uma: pcpu_page_free needs to startup_free pages from startup_alloc

After r357392, it is apparent that we do have some early-boot PCPU
zones.  Make it so we can safely free pages from them if they are
actually used during early boot.

Reviewed by: jeff, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23496

4 years agoObsoleteFiles: Update after simple_httpd removal
kevans [Tue, 4 Feb 2020 21:43:39 +0000 (21:43 +0000)]
ObsoleteFiles: Update after simple_httpd removal

There should have perhaps been an entry in OptionalObsoleteFiles for it
before, but alas- let it be removed now with `make delete-old` if it was
installed.

Reported by: Oliver Pinter

4 years agosrc.conf(5): regen after r357543, HTTPD removal
kevans [Tue, 4 Feb 2020 21:28:04 +0000 (21:28 +0000)]
src.conf(5): regen after r357543, HTTPD removal

4 years agoRemove simple_httpd
kevans [Tue, 4 Feb 2020 21:27:39 +0000 (21:27 +0000)]
Remove simple_httpd

simple_httpd was granted a reprieve from the picobsd removal based on having
some reported user; it turns out this user isn't actually using the version
in base and merging their changes would be difficult at this point, so the
version in base will simply continue to rot. Retire it now, it may make a
comeback to ports with the improved version.

No notice issued because its current visibility has only been for ~3
months, and a notice has been previously issued about picobsd removal.

4 years agoreadelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.
markj [Tue, 4 Feb 2020 21:18:56 +0000 (21:18 +0000)]
readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

CID: 1292493
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoreadelf: Fix the check for an error from realloc().
markj [Tue, 4 Feb 2020 21:18:37 +0000 (21:18 +0000)]
readelf: Fix the check for an error from realloc().

Use err() instead of errx() while here, since realloc() sets errno.

CID: 1401326
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoreadelf: Fix a double close of the input file.
markj [Tue, 4 Feb 2020 21:18:16 +0000 (21:18 +0000)]
readelf: Fix a double close of the input file.

The caller of dump_object() is responsible for opening the file, let it
be responsible for closing too.

CID: 1411588
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agosize: Avoid returning a stack pointer from xlatetom().
markj [Tue, 4 Feb 2020 21:17:59 +0000 (21:17 +0000)]
size: Avoid returning a stack pointer from xlatetom().

The callers only check whether the returned pointer is non-NULL, so this
was harmless in practice, but change the return value to guard against
the issue.

CID: 1411597
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoelfcopy: Avoid leaking dst's fd when we fail to copy a file.
markj [Tue, 4 Feb 2020 21:16:56 +0000 (21:16 +0000)]
elfcopy: Avoid leaking dst's fd when we fail to copy a file.

We should really create the output file in the same directory as the
destination file so that rename() works.  This will be done in a future
change as part of some work to run in capability mode.

CID: 1262523
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoelfcopy: Handle multiple data descriptors properly.
markj [Tue, 4 Feb 2020 21:16:41 +0000 (21:16 +0000)]
elfcopy: Handle multiple data descriptors properly.

The code clearly meant to resize the buffer in the case where a section
was backed by multiple data descriptors.

In practice this shouldn't have been a problem since libelf would return
a single data descriptor for each section in a newly opened file.

CID: 1262522
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibelftc: Add a missing check for an error from vector_str_init().
markj [Tue, 4 Feb 2020 21:16:16 +0000 (21:16 +0000)]
libelftc: Add a missing check for an error from vector_str_init().

While here consistently use the same spelling for such checks.

CID: 1376769
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibelftc: Fix memory leaks in the C++ demanglers.
markj [Tue, 4 Feb 2020 21:15:52 +0000 (21:15 +0000)]
libelftc: Fix memory leaks in the C++ demanglers.

CID: 1262518126251912625201262529
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Fix a memory leak in _dwarf_frame_section_init().
markj [Tue, 4 Feb 2020 21:15:29 +0000 (21:15 +0000)]
libdwarf: Fix a memory leak in _dwarf_frame_section_init().

If frame length validation failed we would leak memory.

CID: 1193366
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.
markj [Tue, 4 Feb 2020 21:15:11 +0000 (21:15 +0000)]
libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.

All callers pass a non-NULL pointer, and otherwise it was possible to
leak memory if the abbrev was not added to a CU.

CID: 1193365
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().
markj [Tue, 4 Feb 2020 21:14:53 +0000 (21:14 +0000)]
libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().

CID: 1193364
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Remove unnecessary NULL checks.
markj [Tue, 4 Feb 2020 21:14:34 +0000 (21:14 +0000)]
libdwarf: Remove unnecessary NULL checks.

All callers of _dwarf_add_expr() and _dwarf_expr_into_block() pass a
non-NULL expr pointer, and these functions assume that expr is non-NULL
anyway.

CID: 11933051193306
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoRemove unneeded assert for curproc. Simplify.
kib [Tue, 4 Feb 2020 21:02:08 +0000 (21:02 +0000)]
Remove unneeded assert for curproc.  Simplify.

Reported by: syzkaller by markj
Sponsored by: The FreeBSD Foundation

4 years ago[PowerPC] Fix VSX context handling
bdragon [Tue, 4 Feb 2020 20:40:45 +0000 (20:40 +0000)]
[PowerPC] Fix VSX context handling

In r356767, memcpy/memmove/bcopy optimizations were added to libc to
improve performance.

This exposed an existing kernel issue in VSX handling. The PSL_VSX flag was
not being excluded from the psl_userstatic set, which meant that any thread
that used these and then called swapcontext(3) would get an EINVAL error.

Fixing this exposed a second issue - in r344123, the FPU was being forced
off in set_mcontext(). However, this was neglecting to ensure VSX was turned
off at the same time.

While here, add some code comments to explain what's going on.

Reviewed by: jhibbits, luporl (earlier rev), pkubaj (earlier rev)
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D23497

4 years agoAdd an explicit busy state for free pages. This improves behavior with
jeff [Tue, 4 Feb 2020 20:33:01 +0000 (20:33 +0000)]
Add an explicit busy state for free pages.  This improves behavior with
potential bugs that access freed pages as well as providing a path
towards lockless page lookup.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23444

4 years agoUse literal bucket sizes for smaller buckets rather than the rounding
jeff [Tue, 4 Feb 2020 20:28:06 +0000 (20:28 +0000)]
Use literal bucket sizes for smaller buckets rather than the rounding
system.  Small bucket sizes already pack well even if they are an odd
number of words.  This prevents any potential new instances of the
problem fixed in r357463 as well as making the system easier to
understand.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D23494

4 years agoCorrect the malloc tag used when freeing the temporary semop(2) buffer.
markj [Tue, 4 Feb 2020 20:00:45 +0000 (20:00 +0000)]
Correct the malloc tag used when freeing the temporary semop(2) buffer.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoRevert r357201: downgrade sqlite3 from sqlite3-3.31.0 (3310000) to
cy [Tue, 4 Feb 2020 19:45:51 +0000 (19:45 +0000)]
Revert r357201: downgrade sqlite3 from sqlite3-3.31.0 (3310000) to
sqlite3-3.30.1 (3300100), as it causes svnlite segfaults on PowerPC,
resulting in corruption.

Reported by: Mark Millard <marklmi at yahoo.com>
Francis Little <oggy at farscape.co.uk>

4 years agotmpfs: add nomtime mount option,
kib [Tue, 4 Feb 2020 19:05:58 +0000 (19:05 +0000)]
tmpfs: add nomtime mount option,

which disables tracking mtime updates due to writes through the shared
mapped areas backed by tmpfs files.  This removes periodic scans which
downgrades rw mapped pages to ro to note the writes.

Suggested by: mjg
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23432

4 years agoEnable vm_object_mightbedirty() and vm_object_page_clean() for swap
kib [Tue, 4 Feb 2020 19:03:37 +0000 (19:03 +0000)]
Enable vm_object_mightbedirty() and vm_object_page_clean() for swap
objects backing tmpfs vnodes data.

The clean scan is limited to only remove write permissions from the
mapped pages of the objects.  This fixes the issue that tmpfs vnode
mtime is not updated from writes to the mmaped area after the initial
page-in.

Noted by: mjg
Reviewed by: markj
Discussed with: jeff
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23432

4 years agoAdd sys/systm.h to several places that use vm headers.
kib [Tue, 4 Feb 2020 18:56:26 +0000 (18:56 +0000)]
Add sys/systm.h to several places that use vm headers.

It is needed (but not enough) to use e.g. KASSERT() in inline functions.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agotmpfs_mount update: simplify, cache the value of VFS_TO_TMPFS() calculation.
kib [Tue, 4 Feb 2020 18:52:25 +0000 (18:52 +0000)]
tmpfs_mount update: simplify, cache the value of VFS_TO_TMPFS() calculation.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agopsm: use make_dev_s instead of make_dev
kevans [Tue, 4 Feb 2020 18:45:28 +0000 (18:45 +0000)]
psm: use make_dev_s instead of make_dev

This most importantly reduces duplication, but it also removes any potential
race with usage of dev->si_drv1 since it's now set prior to the device being
constructed enough to be accessible.

4 years agopsm: release resources on attach failure
kevans [Tue, 4 Feb 2020 18:29:06 +0000 (18:29 +0000)]
psm: release resources on attach failure

In exactly 1/3 cases we'll release resources on failure; touch up the other
two to do so as well.

4 years agoRegen after r357503.
trasz [Tue, 4 Feb 2020 16:02:04 +0000 (16:02 +0000)]
Regen after r357503.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoAdd missing linux(4) syscall entries. This fixes missing debug
trasz [Tue, 4 Feb 2020 16:01:06 +0000 (16:01 +0000)]
Add missing linux(4) syscall entries.  This fixes missing debug
messages for some of the unimplemented syscalls, in particular
the AIO-related ones.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23231

4 years agoFew microoptimizations to dbuf layer.
mav [Tue, 4 Feb 2020 15:53:51 +0000 (15:53 +0000)]
Few microoptimizations to dbuf layer.

Move db_link into the same cache line as db_blkid and db_level.
It allows significantly reduce avl_add() time in dbuf_create() on
systems with large RAM and huge number of dbufs per dnode.

Avoid few accesses to dbuf_caches[].size, which is highly congested
under high IOPS and never stays in cache for a long time.  Use local
value we are receiving from zfs_refcount_add_many() any way.

Remove cache_size_bytes_max bump from dbuf_evict_one().  I don't see
a point to do it on dbuf eviction after we done it on insertion in
dbuf_rele_and_unlock().

Reviewed by: mahrens, Brian Behlendorf
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoRemove unused timer.
tuexen [Tue, 4 Feb 2020 14:01:07 +0000 (14:01 +0000)]
Remove unused timer.

Submitted by: Taylor Brandstetter

4 years agoImprove numbering of debug information.
tuexen [Tue, 4 Feb 2020 12:34:16 +0000 (12:34 +0000)]
Improve numbering of debug information.

Submitted by: Taylor Brandstetter
MFC after: 1 week

4 years agoPrint useful debug data on unhandled kernel fault on arm64
andrew [Tue, 4 Feb 2020 12:33:00 +0000 (12:33 +0000)]
Print useful debug data on unhandled kernel fault on arm64

When panicing because of an unhandled data abort from the kernel it is
useful to know the register state and faulting address to aid debugging.
Print these registers before calling panic.

Sponsored by: DARPA, AFRL

4 years agoBump __FreeBSD_version to 1300077 for r357455
imp [Tue, 4 Feb 2020 09:12:12 +0000 (09:12 +0000)]
Bump __FreeBSD_version to 1300077 for r357455

sparc64 was removed, bump to reflect that.

Pointy-hat-to: imp
Noticed by: linimon@

4 years agoloader: rewrite zfs reader zap code to use malloc
tsoome [Tue, 4 Feb 2020 07:37:55 +0000 (07:37 +0000)]
loader: rewrite zfs reader zap code to use malloc

First step on removing zfs_alloc.

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D23433

4 years agoFix libmemstat_uma build after r357485.
jeff [Tue, 4 Feb 2020 05:27:45 +0000 (05:27 +0000)]
Fix libmemstat_uma build after r357485.

Submitted by: cy

4 years agoFix clock_gettime() and clock_getres() for cpu clocks:
dchagin [Tue, 4 Feb 2020 05:27:05 +0000 (05:27 +0000)]
Fix clock_gettime() and clock_getres() for cpu clocks:
- handle the CLOCK_{PROCESS,THREAD}_CPUTIME_ID specified directly;
- fix thread id calculation as in the Linuxulator we should
  convert the user supplied thread id to struct thread * by linux_tdfind();
- fix CPUCLOCK_SCHED case by using kern_{process,thread}_cputime()
  directly as native get_cputime() used by kern_clock_gettime() uses
  native tdfind()/pfind() to find proccess/thread.

PR: 240990
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23341
MFC after: 2 weeks

4 years agoFor code reuse in Linuxulator rename get_proccess_cputime()
dchagin [Tue, 4 Feb 2020 05:25:51 +0000 (05:25 +0000)]
For code reuse in Linuxulator rename get_proccess_cputime()
and get_thread_cputime() and add prototypes for it to <sys/syscallsubr.h>.

As both functions become a public interface add process lock assert
to ensure that the process is not exiting under it.

Fix whitespace nit while here.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23340
MFC after 2 weeks

4 years agolinux_to_native_clockid() properly initializes nwhich variable (or return error),
dchagin [Tue, 4 Feb 2020 05:23:34 +0000 (05:23 +0000)]
linux_to_native_clockid() properly initializes nwhich variable (or return error),
so don't initialize nwhich in declaration and remove stale comment from r161304.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D23339
MFC after: 2 weeks

4 years agoImplement a deferred write advancement feature that can be used to further
jeff [Tue, 4 Feb 2020 02:44:52 +0000 (02:44 +0000)]
Implement a deferred write advancement feature that can be used to further
amortize shared cacheline writes.

Discussed with: rlibby
Differential Revision: https://reviews.freebsd.org/D23462

4 years agoFix a recursion on the thread lock by acquiring it after call rtp_to_pri().
jeff [Tue, 4 Feb 2020 02:42:54 +0000 (02:42 +0000)]
Fix a recursion on the thread lock by acquiring it after call rtp_to_pri().

Reported by: swills
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D23495

4 years agoUse STAILQ instead of TAILQ for bucket lists. We only need FIFO behavior
jeff [Tue, 4 Feb 2020 02:41:24 +0000 (02:41 +0000)]
Use STAILQ instead of TAILQ for bucket lists.  We only need FIFO behavior
and this is more space efficient.

Stop queueing recently used buckets to the head of the list.  If the bucket
goes to a different processor the cache coherency will be more expensive.
We already try to encourage cache-hot behavior in the per-cpu layer.

Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D23493

4 years agocxgbe(4): Add pfil(9) hooks to the driver's rx.
np [Tue, 4 Feb 2020 01:09:02 +0000 (01:09 +0000)]
cxgbe(4): Add pfil(9) hooks to the driver's rx.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Treat NIC rx as special and run its handler directly and not
np [Tue, 4 Feb 2020 01:01:35 +0000 (01:01 +0000)]
cxgbe(4): Treat NIC rx as special and run its handler directly and not
via the t4_cpl_handler dispatch table.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Retire the allow_mbufs_in_cluster optimization.
np [Tue, 4 Feb 2020 00:51:10 +0000 (00:51 +0000)]
cxgbe(4): Retire the allow_mbufs_in_cluster optimization.

This simplifies the driver's rx fast path as well as the bookkeeping
code that tracks various rx buffer sizes and layouts.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoSet the LMA of the riscv kernel to the OpenSBI jump target by default
arichardson [Tue, 4 Feb 2020 00:06:16 +0000 (00:06 +0000)]
Set the LMA of the riscv kernel to the OpenSBI jump target by default

This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line
options. When using that option, QEMU maps the kernel ELF file to the
addresses specified in the LMAs in the program headers.

Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows
booting FreeBSD using the following command line:
qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt

Without this change the -kernel option cannot be used since the LMAs start
at address zero and QEMU already maps a ROM to these low physical addresses.

For targets that require a different kernel LMA the make variable
KERNEL_LMA can be overwritten in the config file. For example, adding
`makeoptions KERNEL_LMA=0xc0200000` will create an ELF file that will be
loaded at 0xc0200000.

Before:
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000
  DYNAMIC        0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R   0x4

After:

There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000
  DYNAMIC        0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R   0x4

Reviewed By: br, mhorne (earlier version)
Differential Revision: https://reviews.freebsd.org/D23436

4 years agocxgbe(4): Avoid ext_arg2 in rxb_free.
np [Mon, 3 Feb 2020 23:50:29 +0000 (23:50 +0000)]
cxgbe(4): Avoid ext_arg2 in rxb_free.

ext_arg2 is the only item in the third cacheline in an mbuf and could be
cold by the time rxb_free runs.  Put the information needed by rxb_free
in the same line as the refcount, which is very likely to be hot given
that rxb_free runs when the refcount is decremented and reaches 0.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoports.7: Update examples with install-missing-packages
0mp [Mon, 3 Feb 2020 23:40:27 +0000 (23:40 +0000)]
ports.7: Update examples with install-missing-packages

The ports framework recently grew support for installing dependencies with
a dedicated target called "install-missing-packages". Let's retire the
carefully constructed one-liner that was used for getting dependencies so
far and use the official ports target instead.

Reviewed by: bcr
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D23485

4 years agoReplace *-out with star-out to ease legibility
0mp [Mon, 3 Feb 2020 23:30:47 +0000 (23:30 +0000)]
Replace *-out with star-out to ease legibility

"*-out" is a complex way of phrasing the fact, and it causes
confusion for people.

Submitted by: debdrup
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D23482

4 years agocxgbe(4): Do not use pack boundary > 512B unless it is explicitly
np [Mon, 3 Feb 2020 23:30:39 +0000 (23:30 +0000)]
cxgbe(4): Do not use pack boundary > 512B unless it is explicitly
requested.

This is a tradeoff between PCIe efficiency during large packet rx and
packing efficiency during small packet rx.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Initialize the rx buffer's metadata on first-use and not on
np [Mon, 3 Feb 2020 23:25:12 +0000 (23:25 +0000)]
cxgbe(4): Initialize the rx buffer's metadata on first-use and not on
allocation.

refill_fl doesn't touch any part of a freshly allocated cluster after
this change.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Only checksummed TCP should be considered for LRO.
np [Mon, 3 Feb 2020 23:06:42 +0000 (23:06 +0000)]
cxgbe(4): Only checksummed TCP should be considered for LRO.

This avoids the per-packet nanouptime in tcp_lro_rx for traffic that's
not even TCP.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoFix the !SMP case in sched_add() after r355779.
markj [Mon, 3 Feb 2020 22:49:05 +0000 (22:49 +0000)]
Fix the !SMP case in sched_add() after r355779.

If the thread's lock is already that of the runqueue, don't recurse on
the queue lock.

Reviewed by: jeff, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23492

4 years agofd: partially unengrish the previous commit
mjg [Mon, 3 Feb 2020 22:34:50 +0000 (22:34 +0000)]
fd: partially unengrish the previous commit

4 years agofd: streamline fget_unlocked
mjg [Mon, 3 Feb 2020 22:32:49 +0000 (22:32 +0000)]
fd: streamline fget_unlocked

clang has the unfortunate property of paying little attention to prediction
hints when faced with a loop spanning the majority of the rotuine.

In particular fget_unlocked has an unlikely corner case where it starts almost
from scratch. Faced with this clang generates a maze of taken jumps, whereas
gcc produces jump-free code (in the expected case).

Work around the problem by providing a variant which only tries once and
resorts to calling the original code if anything goes wrong.

While here note that the 'seq' parameter is almost never passed, thus the
seldom users are redirected to call it directly.

4 years agofd: remove the seq argument from fget_unlocked
mjg [Mon, 3 Feb 2020 22:27:55 +0000 (22:27 +0000)]
fd: remove the seq argument from fget_unlocked

It is almost always NULL.

4 years agofd: remove the seq argument from fget routines
mjg [Mon, 3 Feb 2020 22:27:03 +0000 (22:27 +0000)]
fd: remove the seq argument from fget routines

It is almost always NULL.

4 years agoseqc: provide seqc_read_any
mjg [Mon, 3 Feb 2020 22:26:29 +0000 (22:26 +0000)]
seqc: provide seqc_read_any

4 years agoktrace: provide ktrstat_error
mjg [Mon, 3 Feb 2020 22:26:00 +0000 (22:26 +0000)]
ktrace: provide ktrstat_error

This eliminates a branch from its consumers trading it for an extra call
if ktrace is enabled for curthread. Given that this is almost never true,
the tradeoff is worth it.

4 years agoCouple protocol drain routines (frag6_drain and sctp_drain) may send
glebius [Mon, 3 Feb 2020 20:48:57 +0000 (20:48 +0000)]
Couple protocol drain routines (frag6_drain and sctp_drain) may send
packets.  An unexpected behaviour for memory reclamation routine.
Anyway, we need enter the network epoch for doing that.

4 years agoMinor cleanups to allow handing vast datasets.
phk [Mon, 3 Feb 2020 20:46:31 +0000 (20:46 +0000)]
Minor cleanups to allow handing vast datasets.

Submitted by: dds

4 years agoFix a stray 'e'from my last commit.
imp [Mon, 3 Feb 2020 19:36:24 +0000 (19:36 +0000)]
Fix a stray 'e'from my last commit.

4 years agoDisable the smallest UMA bucket size on 32-bit platforms.
markj [Mon, 3 Feb 2020 19:29:02 +0000 (19:29 +0000)]
Disable the smallest UMA bucket size on 32-bit platforms.

With r357314, sizeof(struct uma_bucket) grew to 16 bytes on 32-bit
platforms, so BUCKET_SIZE(4) is 0.  This resulted in the creation of a
bucket zone for buckets with zero capacity.  A more general fix is
planned, but for now this bandaid allows 32-bit platforms to boot again.

PR: 243837
Discussed with: jeff
Reported by: pho, Jenkins via lwhsu
Tested by: pho
Sponsored by: The FreeBSD Foundation

4 years agoaddr2line: Avoid a name collision.
markj [Mon, 3 Feb 2020 19:08:35 +0000 (19:08 +0000)]
addr2line: Avoid a name collision.

The RB_ macros define functions with a parameter named head, and gcc
warns about this.

MFC with: r357450

4 years agonamei: preserve errors from fget_cap_locked
kevans [Mon, 3 Feb 2020 18:59:07 +0000 (18:59 +0000)]
namei: preserve errors from fget_cap_locked

Most notably, we want to make sure we don't clobber any capabilities-related
errors. This is a regression from r357412 (O_SEARCH) that was picked up by
the capsicum tests.

PR: 243839
Reviewed by: kib (committed form recommended by)
Tested by: lwhsu
Differential Revision: https://reviews.freebsd.org/D23479

4 years agoDynamically select LSE-based atomic(9)s on arm64.
markj [Mon, 3 Feb 2020 18:23:50 +0000 (18:23 +0000)]
Dynamically select LSE-based atomic(9)s on arm64.

Once all CPUs are online, determine if they all support LSE atomics and
set lse_supported to indicate this.  For now the atomic(9)
implementations are still always inlined, though it would be preferable
to create out-of-line functions to avoid text bloat.  This was not done
here since big.little systems exist in which some CPUs implement LSE
while others do not, and ifunc resolution must occur well before this
scenario can be detected.  It does seem unlikely that FreeBSD will
ever run on such platforms, however, so converting atomic(9) to use
ifuncs is probably a good next step.

Add a LSE_ATOMICS arm64 kernel configuration option to unconditionally
select LSE-based atomic(9) implementations when the target system is
known.

Reviewed by: andrew, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation, Amazon (hardware)
Differential Revision: https://reviews.freebsd.org/D23325

4 years agoAdd LSE-based atomic(9) implementations.
markj [Mon, 3 Feb 2020 18:23:35 +0000 (18:23 +0000)]
Add LSE-based atomic(9) implementations.

These make use of the cas*, ld* and swp instructions added in ARMv8.1.
Testing shows them to be significantly more performant than LL/SC-based
implementations.

No functional change here since the wrappers still unconditionally
select the _llsc variants.

Reviewed by: andrew, kib
MFC after: 1 month
Submitted by: Ali Saidi <alisaidi@amazon.com> (original version)
Differential Revision: https://reviews.freebsd.org/D23324

4 years agoAdd wrappers for arm64 atomics.
markj [Mon, 3 Feb 2020 18:23:14 +0000 (18:23 +0000)]
Add wrappers for arm64 atomics.

Add a _llsc suffix for the existing LL/SC-based implementations and add
trivial wrappers.  This is in preparation for supporting LSE-based
atomic(9) implementations.

No functional change intended.

Reviewed by: andrew, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation, Amazon (hardware)
Differential Revision: https://reviews.freebsd.org/D23323

4 years agoProvide a single implementation for each of the arm64 atomic(9) ops.
markj [Mon, 3 Feb 2020 18:22:59 +0000 (18:22 +0000)]
Provide a single implementation for each of the arm64 atomic(9) ops.

Parameterize the macros by type width as well as acq/rel semantics.
This makes modifying the implementations much less tedious and
error-prone and makes it easier to support alternate LSE-based
implementations.  No functional change intended.

Reviewed by: andrew, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation, Amazon (hardware)
Differential Revision: https://reviews.freebsd.org/D23322

4 years agoWith INVARIANTS, track all softdep dependency structures centrally
chs [Mon, 3 Feb 2020 17:47:14 +0000 (17:47 +0000)]
With INVARIANTS, track all softdep dependency structures centrally
so that we can find them in dumps.

Approved by: mckusick (mentor)
Sponsored by: Netflix

4 years agoRemove sparc64 kernel support
imp [Mon, 3 Feb 2020 17:35:11 +0000 (17:35 +0000)]
Remove sparc64 kernel support

Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs

4 years agoRemove sparc64 support from the boot loader.
imp [Mon, 3 Feb 2020 17:34:57 +0000 (17:34 +0000)]
Remove sparc64 support from the boot loader.

Remove all the sparc64 specific bits, both files and ifdefs.

4 years agoUnblock kstat.zfs.misc.dbufstats sysctls.
mav [Mon, 3 Feb 2020 17:10:40 +0000 (17:10 +0000)]
Unblock kstat.zfs.misc.dbufstats sysctls.

It is not so much broken to hide it after we wasted time to collect it.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agocapsicum: faster cap_rights_contains
mjg [Mon, 3 Feb 2020 17:08:11 +0000 (17:08 +0000)]
capsicum: faster cap_rights_contains

Instead of doing a 2 iteration loop (determined at runeimt), take advantage
of the fact that the size is already known.

While here provdie cap_check_inline so that fget_unlocked does not have to
do a function call.

Verified with the capsicum suite /usr/tests.

4 years agotmpfs: inline tmpfs_update
mjg [Mon, 3 Feb 2020 17:06:21 +0000 (17:06 +0000)]
tmpfs: inline tmpfs_update

It was generated to be just a jumping off point to tmpfs_itimes.

While here provide a dedicated variant for getattr since we normally don't
expect to need to the update from that caller.

4 years agoaddr2line: Cache CU DIEs upon a successful address lookup.
markj [Mon, 3 Feb 2020 16:41:40 +0000 (16:41 +0000)]
addr2line: Cache CU DIEs upon a successful address lookup.

Previously, addr2line would sequentially search all CUs for each input
address.  For some uses, notably syzkaller's code coverage map generator,
this was extremely slow.  Add a CU cache into which entries are added
following a successful lookup, and search the cache before falling back
to a scan.  When translating a large number of addresses this yields
slightly better performance than GNU addr2line.

Garbage-collect an unused hash table which appears to have been intended
for the same purpose.  A hash table doesn't seem particularly suitable
since each CU spans a range of addresses.

Submitted by: Tiger Gao <tig@freebsdfoundation.org>
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23418

4 years agounits(1): Refactor the manual page and update usage information
0mp [Mon, 3 Feb 2020 15:22:46 +0000 (15:22 +0000)]
units(1): Refactor the manual page and update usage information

Changes to units.1:

- Change the description to a more descriptive "conversion calculator".
- Sort options.
- Split the description into sections to make it easier to navigate the
  manual page.
- Improve the description of various options.
- Document the default value of the output format.
- Use more mdoc macros for better readability.
- Document the behavior of the PATH environmental variable.
- Improve examples.
- Add sections: EXIT STATUS, DIAGNOSTICS, and HISTORY.
- Document that units(1) cannot convert negative values and it handles long
  unit lists poorly.
- Update the documentation of the -V flag to match the implementation.
  units(1) prints its version and the units data file instead of its
  version and usage information.

Changes to units.c:

- Update usage information.
- Sort longopts elements.

This commit does not attempts to change the current behavior of units(1).
What's left to do is probably defining a better versioning (at the moment
units(1) always reports "FreeBSD units" as its version) and changing the
behavior of the -V flag to only print version.

Reviewed by: allanjude (earlier version), bcr
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D18977

4 years agoRemove the GICv3 ITS irq and replace it with an ID
andrew [Mon, 3 Feb 2020 14:38:19 +0000 (14:38 +0000)]
Remove the GICv3 ITS irq and replace it with an ID

In r357324 most of the use of gi_irq was moved to gi_lpi. Complete this
with the last few places we need the IRQ value and create gi_id for the
per-device value we need.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL