Commit Graph

267467 Commits

Author SHA1 Message Date
Dmitry Chagin
a9bb1b1c18 linux(4): Handle FUTEX_LOCK_PI2 oeration.
FUTEX_LOCK_PI2 was added to support clock selection as FUTEX_LOCK_PI uses a
CLOCK_REALTIME based absolute value since it was implemented, but it does not
require that the FUTEX_CLOCK_REALTIME bit is set, because that was introduced
later.

MFC after:		2 weeks
2021-07-29 12:55:02 +03:00
Dmitry Chagin
bd25bf092a linux(4): Use variable name not type for sizeof() to calculate storage size.
MFC after:		2 weeks
2021-07-29 12:54:32 +03:00
Dmitry Chagin
49a5c0409b linux(4): Move len variable initialization to the appropriate place.
MFC after:		2 weeks
2021-07-29 12:54:16 +03:00
Dmitry Chagin
c8e9d2b7eb linux(4): Use linux_tdfind() in get_robust_list.
In the Linux emulation layer linux_tdfind() has a special purpose to
handle glibc specific TID mangling and we should use it instead of tdfind().

MFC after:		2 weeks
2021-07-29 12:53:59 +03:00
Dmitry Chagin
f88d3c522f linux(4): Eliminate unnecessary error initialization.
MFC after:		2 weeks
2021-07-29 12:53:41 +03:00
Dmitry Chagin
6b68e8af1f linux(4): Eliminate unnecessary head initialization.
MFC after:		2 weeks
2021-07-29 12:53:25 +03:00
Dmitry Chagin
971b53fa04 linux(4): style, wrap too long line.
MFC after:		2 weeks
2021-07-29 12:53:07 +03:00
Dmitry Chagin
edd44176aa linux(4): Eliminating remnants of futex sdt.
MFC after:		2 weeks
2021-07-29 12:52:36 +03:00
Dmitry Chagin
741f80df53 linux(4): Eliminating an accidental comment.
MFC after:		2 weeks
2021-07-29 12:51:56 +03:00
Dmitry Chagin
b59cf25eac linux(4): Handle special case for regular futex in handle_futex_death().
Handle some races in handle_futex_death() which can prevents a wakeup of
potential waiters which can cause these waiters to block forever.

Differential Revision:	https://reviews.freebsd.org/D31280
MFC after:		2 weeks
2021-07-29 12:51:39 +03:00
Dmitry Chagin
dad1077056 linux(4): Futex address must be 32-bit aligned.
Linux futex documentation explicitly states that EINVAL is returned if
the futex is not 4-byte aligned. Check futex alignment as a Linux do
and return EINVAL.

Differential Revision:	https://reviews.freebsd.org/D31279
MFC after:		2 weeks
2021-07-29 12:50:58 +03:00
Dmitry Chagin
b33e469027 linux(4): Finish cf8d74e3fe.
Add forgotten val3_compare initialization in case of time64 futex.

MFC after:		2 weeks
2021-07-29 12:50:43 +03:00
Dmitry Chagin
4f34dc6453 linux(4): Replace casuword32 by casueword32.
Follow the r349951 (30b3018d), add check to react to stops and requests
to terminate between retries.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31254
MFC after:		2 weeks
2021-07-29 12:50:11 +03:00
Dmitry Chagin
7a718f293a linux(4): Implement pi futexes using umtx.
Differential Revision:	https://reviews.freebsd.org/D31240
MFC after:		2 weeks
2021-07-29 12:49:42 +03:00
Dmitry Chagin
cb01cc4a10 linux(4): Replace copyin() by fueword32() in handle_futex_death().
According to fetch(9) fueword facility designed to fetch atomically
small amount of data from user space.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31239
MFC after:		2 weeks
2021-07-29 12:48:59 +03:00
Dmitry Chagin
20979f38c1 umtx: Add new pi_futex type.
Differential Revision:	https://reviews.freebsd.org/D31250
MFC after:		2 weeks
2021-07-29 12:48:34 +03:00
Dmitry Chagin
9e32efa79b umtx: Split do_unlock_pi on two counterparts.
The umtx_pi_frop() will be used by Linux emulation layer.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31238
MFC after:		2 weeks
2021-07-29 12:47:39 +03:00
Dmitry Chagin
09f55e6002 umtx: Expose some of the pi umtx structures and API to the rest of the kernel.
Differential Revision:	https://reviews.freebsd.org/D31237
MFC after:		2 weeks
2021-07-29 12:46:58 +03:00
Dmitry Chagin
b9c89fa39e linux(4): Eliminate unused includes.
MFC after:		2 weeks
2021-07-29 12:46:35 +03:00
Dmitry Chagin
0dc38e3303 linux(4): Reimplement futexes using umtx.
Differential Revision:	https://reviews.freebsd.org/D31236
MFC after:		2 weeks
2021-07-29 12:43:48 +03:00
Dmitry Chagin
8e4d22c01d umtx: Add umtxq_requeue Linux emulation layer extension.
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31235
MFC after:		2 weeks
2021-07-29 12:43:07 +03:00
Dmitry Chagin
7caa29115b umtx: Add bitset conditional wakeup functionality.
The bitset is a Linux emulation layer extension. This 32-bit mask, in which at
least one bit must be set, is used to select which threads should be woken up.

The bitset is stored in the umtx_q structure, which is used to enqueue the waiter
into the umtx waitqueue. Put the bitset into the hole, that appeared on LP64 due
to data alignment, to prevent the growth of the struct umtx_q.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31234
MFC after:		2 weeks
2021-07-29 12:42:49 +03:00
Dmitry Chagin
1fdcc87cfd umtx: Expose some of the umtx structures and API to the rest of the kernel.
Differential Revision:	https://reviews.freebsd.org/D31233
MFC after:		2 weeks
2021-07-29 12:42:17 +03:00
Dmitry Chagin
307a3dd35c umtx: Expose struct abs_timeout to the rest of the kernel.
Add umtx_ prefix to all abs_timeout facility and add declaration for it.
For consistency with others abs_timeout mark inline abs_timeout_init2.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31249
MFC after:		2 weeks
2021-07-29 12:41:58 +03:00
Dmitry Chagin
af29f39958 umtx: Split umtx.h on two counterparts.
To prevent umtx.h polluting by future changes split it on two headers:
umtx.h - ABI header for userspace;
umtxvar.h - the kernel staff.

While here fix umtx_key_match style.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31248
MFC after:		2 weeks
2021-07-29 12:41:29 +03:00
Dmitry Chagin
7cf06e075d freebsd32: Remove the unnecessary spaces.
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31247
MFC after:		2 weeks
2021-07-29 12:40:36 +03:00
Dmitry Chagin
3c886cb691 freebsd32: Remove unused umtx.h include.
Differential Revision:	https://reviews.freebsd.org/D31246
MFC after:		2 weeks
2021-07-29 12:40:08 +03:00
Dmitry Chagin
32a18e9abd freebsd32: Eliminate spaces at end of line.
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31245
MFC after:		2 weeks
2021-07-29 12:39:30 +03:00
Wojciech Macek
fe8ce390b8 Fix mac_veriexec version mismatch
mac_veriexec sets its version to 1, but the mac_veriexec_shaX modules which depend on it expect MAC_VERIEXEC_VERSION = 2.
Be consistent and use MAC_VERIEXEC_VERSION everywhere.
This unbreaks loading of mac_veriexec modules at boot time.

Authored by: 		Kornel Duleba <mindal@semihalf.com>
Obtained from: 		Semihalf
Sponsored by: 		Stormshield
Differential Revision: 	https://reviews.freebsd.org/D31268
2021-07-29 11:05:13 +02:00
Andrew Turner
2d6d5f88d1 Add missing arm64 ID registers
These may contain values we export to userpsace.

Sponsored by:	The FreeBSD Foundation
2021-07-28 19:01:30 +00:00
Andrew Turner
c3f2fcf5b9 Sort the arm64 ID_AA64* user registers
Sponsored by:	The FreeBSD Foundation
2021-07-28 19:01:30 +00:00
David Malone
fd309107e9 Minor language improvements. Note that they can't be changed
by sysctl (I think they can be changed as a tuneable.)
2021-07-29 09:26:19 +01:00
Luiz Otavio O Souza
5afe81a7b2 virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.
ALTQ only works on network drivers which use if_start (rather than
if_transmit). vtnet uses if_start if built with VTNET_LEGACY_TX. Default
to that the kernel is built with ALTQ enabled, to reduce user surprise.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-29 07:54:39 +02:00
Kristof Provost
728958fb1b UPDATING: document if_bridge MTU changes
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-29 09:36:52 +02:00
Dmitry Chagin
f337940144 linux(4): Fix gcc buld.
gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by:		jhb
MFC after:		2 weeks
2021-07-29 09:52:33 +03:00
Poul-Henning Kamp
272144ab41 hexdump: Flush stdout after '*' (repeat) lines.
The canonical annoying example being:   hexdump < /dev/zero | less
2021-07-29 06:40:57 +00:00
Conrad Meyer
7f8f79a5c4 libc qsort(3): Eliminate ambiguous sign comparison
The left side of the MIN() expression is the (signed) result of pointer
subtraction (ptrdiff_t).  The right hand side is the also the (signed)
result of pointer subtraction, additionally subtracting the element size
('es'), which is unsigned size_t.  This coerces the right-hand
expression into an unsigned value.  MIN(signed, unsigned) triggers
-Wsign-compare.

Sorting elements of size greater than SSIZE_MAX is nonsensical, so we
can instead treat the element size as ssize_t, leaving the right-hand
result the same signedness as the left.

Reviewed by:		arichardson, kib
Differential Revision:	https://reviews.freebsd.org/D31292
2021-07-28 20:59:20 -07:00
Kyle Evans
e3707726c1 kern: remove deprecated makesyscalls.sh
makesyscalls was rewritten in Lua and introduced in d3276301ab.  In the
time since, no objections have risen and a warning was introduced long
ago on invocation of makesyscalls.sh that it would be removed before
FreeBSD 13. Belatedly follow through on that.
2021-07-28 22:22:23 -05:00
Warner Losh
6b51baf6a8 cli.lua.8: make the command match the code
It's disable-device, not device-disable

Spotted by:		jrtc27
Sponsored by:		Netflix
2021-07-28 20:54:14 -06:00
Alexander Motin
aefe0a8c32 Refactor/optimize cpu_search_*().
Remove cpu_search_both(), unused for many years.  Without it there is
less sense for the trick of compiling common cpu_search() into separate
cpu_search_lowest() and cpu_search_highest(), so split them completely,
making code more readable.  While there, split iteration over children
groups and CPUs, complicating code for very small deduplication.

Stop passing cpuset_t arguments by value and avoid some manipulations.
Since MAXCPU bump from 64 to 256, what was a single register turned
into 32-byte memory array, requiring memory allocation and accesses.
Splitting struct cpu_search into parameter and result parts allows to
even more reduce stack usage, since the first can be passed through
on recursion.

Remove CPU_FFS() from the hot paths, precalculating first and last CPU
for each CPU group in advance during initialization.  Again, it was
not a problem for 64 CPUs before, but for 256 FFS needs much more code.

With these changes on 80-thread system doing ~260K uncached ZFS reads
per second I observe ~30% reduction of time spent in cpu_search_*().

MFC after:	1 month
2021-07-28 22:00:29 -04:00
Bryan Drewery
7cbf1de38e debugnet: Fix false-positive assertions for dp_state
debugnet_handle_arp:
  An assertion is present to ensure the pcb is only modified when the state is
  DN_STATE_INIT. Because debugnet_arp_gw() is asynchronous it is possible for
  ARP replies to come in after the gateway address is known and the state
  already changed.

debugnet_handle_ip:
  Similarly it is possible for packets to come in, from the expected
  server, during the gateway mac discovery phase.  This can happen from
  testing disconnects / reconnects in quick succession.  This later
  causes some acks to be sent back but hit an assertion because the
  state is wrong.

Reviewed by:	cem, debugnet_handle_arp: markj, vangyzen
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D31327
2021-07-28 16:34:14 -07:00
Warner Losh
07c4b78d0a lua loader: Add disable-device to disable a device.
disable-device fooX will set hint.foo.X.disabled=1 as a way to easily
disable a device attaching during boot.

Reviewed by:		tsoome
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D31297
2021-07-28 16:53:00 -06:00
Rick Macklem
efea1bc1fd nfscl: Cache an open stateid for the "oneopenown" mount option
For NFSv4.1/4.2, if the "oneopenown" mount option is used,
there is, at most, only one open stateid for each NFS vnode.
When an open stateid for a file is acquired, set a pointer to
the open structure in the NFS vnode.  This pointer can be used to
acquire the open stateid without searching the open linked list
when the following is true:
- No delegations have been issued for the file.  Since delegations
  can outlive an NFS vnode for a file, use the global
  NFSMNTP_DELEGISSUED flag on the mount to determine this.
- No lock stateid has been issued for the file.  To determine
  this, a new NFS vnode flag called NMIGHTBELOCKED is set when a lock
  stateid is issued, which can then be tested.

When this open structure pointer can be used, it avoids the need to
acquire the NFSCLSTATELOCK() and searching the open structure list for
an open.  The NFSCLSTATELOCK() can be highly contended when there are
a lot of opens issued for the NFSv4.1/4.2 mount.

This patch only affects NFSv4.1/4.2 mounts when the "oneopenown"
mount option is used.

MFC after:	2 weeks
2021-07-28 15:48:27 -07:00
Rick Macklem
54ff3b3986 nfscl: Set correct lockowner for "oneopenown" mount option
For NFSv4.1/4.2, the client may use either an open, lock or
delegation stateid as the stateid argument for an I/O operation.
RFC 5661 defines an order of preference of delegation, then lock
and finally open stateid for the argument, although NFSv4.1/4.2
servers are expected to handle any stateid type.

For the "oneopenown" mount option, the lock owner was not being
correctly generated and, as such, the I/O operation would use an
open stateid, even when a lock stateid existed.  Although this
did not and should not affect an NFSv4.1/4.2 server's behaviour,
this patch makes the behaviour for "oneopenown" the same as when
the mount option is not specified.

Found during inspection of packet captures.  No failure during
testing against NFSv4.1/4.2 servers of the unpatched code occurred.

MFC after:	2 weeks
2021-07-28 15:23:05 -07:00
Ed Maste
4dbac528db pkgbase: improve pkg --version parsing
In some cases `pkg --version` might produce unexpected or additional
output.  Use a regex /^[0-9.]+$/ to match only the line containing the
version number.

Reported by:	Michael Butler on freebsd-current@
Fixes:		4e224e4be7 ("pkgbase: accommodate pkg < 1.17")
Sponsored by:	The FreeBSD Foundation
2021-07-28 17:14:33 -04:00
Alexander Motin
5a49f19141 Do not expose to scheduler caches of single CPU.
Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels
or topology (root, package/L3 and core/L2).  But with SMT disabled
core/L2 matches thread, so additional topology level only causes more
traversal work.  With this change SMT case is reported same as before,
while non-SMT is reported with only 2 much more simple levels.

MFC after:	2 weeks
2021-07-28 16:38:01 -04:00
Dimitry Andric
cc55ee8009 compilert-rt: build out-of-line LSE atomics helpers for aarch64
Both clang >= 12 and gcc >= 10.1 now default to -moutline-atomics for
aarch64. This requires a bunch of helper functions in libcompiler_rt.a,
to avoid link errors like "undefined symbol: __aarch64_ldadd8_acq_rel".

(Note: of course you can use -mno-outline-atomics as a workaround too,
but this would negate the potential performance benefit of the faster
LSE instructions.)

Bump __FreeBSD_version so ports maintainers can easily detect this.

PR:		257392
MFC after:	2 weeks
2021-07-28 22:30:04 +02:00
Kristof Provost
441d15a482 bridge tests: verify that we can't change MTU of bridge member interfaces
Reviewed by:	donner
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31305
2021-07-28 22:03:38 +02:00
Kristof Provost
01ad0c0079 net: disallow MTU changes on bridge member interfaces
if_bridge member interfaces should always have the same MTU as the
bridge itself, so disallow MTU changes on interfaces that are part of an
if_bridge.

Reviewed by:	donner
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31304
2021-07-28 22:03:30 +02:00
Kristof Provost
6e43950640 bridge tests: test changing the bridge MTU
Changing the bridge MTU will now also change all of the member interface
MTUs. Test this.

Reviewed by:	donner
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31289
2021-07-28 22:01:12 +02:00