Commit graph

20150 commits

Author SHA1 Message Date
Doug Moore 2a21cfe60f pctrie: avoid typecast
Have PCTRIE_RECLAIM_CALLBACK typecast one function pointer type to
another, to relieve the writer of the call back function from having
to cast its first argument from void* to member type.

Reviewed by:	rlibby
Differential Revision:	https://reviews.freebsd.org/D45586
2024-06-14 02:19:03 -05:00
Doug Moore d19851f002 subr_pctrie: add a word to a comment
No functional changes.
Reported by:	alc
2024-06-13 15:28:15 -05:00
Doug Moore a7f67ebd82 subr_rangeset: use pctrie_reclaim_cb in remove_all
Replace the lookup-remove loop in rangeet_remove_all with a call
to SWAP_PCTRIE_RECLAIM_CALLBACK, to eliminate repeated trie searches.

Reviewed by:	rlibby
Differential Revision:	https://reviews.freebsd.org/D45584
2024-06-13 13:52:25 -05:00
Doug Moore c0d0bc2bed subr_pctrie: add leaf callbacks to pctrie_reclaim
PCTRIE_RECLAIM frees all the interior nodes in a pctrie, but is little
used because most trie-destroyers want to free leaves of the tree
too. Add PCTRIE_RECLAIM_CALLBACK, with two extra arguments, a callback
function and an auxiliary argument, that is invoked on every non-NULL
leaf in the tree as the tree is destroyed.

Reviewed by:	rlibby, kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D45565
2024-06-13 11:48:09 -05:00
Doug Moore 2c10bacdf4 rangeset: add next() iteration
Add a method rangeset_next to find the first range that starts at or
after a given value. Use it to rewrite pmap_pkru_same and
pmap_bti_same to avoid walking a page at a time over pages in no
range.

Reviewed by:	andrew, kib
Differential Revision:	https://reviews.freebsd.org/D45511
2024-06-06 13:42:31 -05:00
Ryan Libby 780666c09b getblk: reduce time under bufobj lock
Use the new pctrie combined insert/lookup facility to reduce work and
time under the bufobj interlock when associating a buf with a vnode.

We now do one lookup in the dirty tree and one combined lookup/insert in
the clean tree instead of one lookup in dirty, two in clean, and then an
insert in clean.  We also avoid touching the possibly unrelated buf at
the tail of the queue.

Also correct an issue where the actual order of the tail queue depended
on the insertion order due to sign issues.

Reviewed by:	kib (previous version), dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45395
2024-06-05 20:21:22 -07:00
Ryan Libby bbf81f4629 pctrie: add combined insert/lookup operations
In several places in code, we do a pctrie lookup followed by a pctrie
insert.  Provide a few flavors of combined lookup/insert.  This may save
a portion of the work from walking a large pctrie twice.

The general idea is that while we walk the trie during insert, we also
do the same kind of tracking work that we do during pctrie_lookup_ge or
pctrie_lookup_le, and we pass out a pctrie node from where such a lookup
may continue.

Reviewed by:	dougm (previous version), kib (previous version), markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45394
2024-06-05 19:17:20 -07:00
Andrew Turner c2e0d56f5e arm64: Support BTI checking in most of the kernel
LLD has the -zbti-report=error argument to check if the BTI note is
present when linking. To allow for this to be used when linking the
kernel and modules:
 - Add the BTI note to the remaining assembly files
 - Mark ptrauth.c as protected by BTI
 - Disable -zbti-report for vmm hypervisor switching code as it's not
   used there.

The linux64 module doesn't build with the flag as it includes vdso code
that doesn't include the note.

Reviewed by:	imp, kib, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45466
2024-06-05 09:23:40 +00:00
Andrew Turner a5affc0c4c stats: Fix the build under gcc
Reviewed by:	brooks, imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45302
2024-06-05 09:23:40 +00:00
Mitchell Horne 5df74441b3 devmap: eliminate unused arguments
The optional 'table' pointer is a legacy part of the interface, which
has been replaced by devmap_register_table()/devmap_add_entry(). The few
in-tree callers have already adapted to this, so it can be removed.

The 'l1pt' argument is already entirely unused within the function.

Reviewed by:	andrew, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45319
2024-06-04 20:17:47 -03:00
Mitchell Horne 191e6a6049 physmem: zero entire array
As a convenience to callers, who might allocate the array on the stack.
An empty/zero-valued range indicates the end of the physmap entries.

Remove the now-redundant calls to bzero() at the call site.

Reviewed by:	andrew
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45318
2024-06-04 20:17:13 -03:00
Gleb Smirnoff a9b55a6644 unix: use m_freemp() when disposing unix socket buffers
The new unix/dgram uses m_nextpkt linkage, while the old unix/stream
uses m_next linkage.  This fixes memory leak.

Diagnosed by:		khng
Reviewed by:		khng, markj
PR:			279467
Fixes:			458f475df8
Differential Revision:	https://reviews.freebsd.org/D45478
MFC After:		1 week
2024-06-03 17:23:06 -07:00
Gleb Smirnoff badf44cc21 mbuf: provide m_freemp()
This function follows both m_nextpkt and m_next linkage freeing all mbufs.
Note that existing m_freem() follows only m_next.

Reviewed by:		khng
Differential Revision:	https://reviews.freebsd.org/D45477
2024-06-03 17:23:06 -07:00
Ryan Libby 3ca6bf7929 db_show_buffer: minor cleanup
Do some light cleanup to make the output format more consistent for
readability.

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45442
2024-06-03 11:35:28 -07:00
Doug Moore 749c249dc3 subr_pctrie: use ilog2(x) instead of fls(x)-1
In three instances where fls(x)-1 is used, the compiler does not know
that x is nonzero and so adds needless zero checks.  Using ilog(x)
instead saves, in each instance, about 4 instructions, including a
conditional, and 16 or so bytes, on an amd64 build.

Reviewed by:    alc
Differential Revision:  https://reviews.freebsd.org/D45330
2024-06-03 13:31:19 -05:00
Doug Moore e3537f9235 Revert "subr_pctrie: use ilog2(x) instead of fls(x)-1"
This reverts commit 574ef65069.
2024-06-03 13:07:42 -05:00
Doug Moore 574ef65069 subr_pctrie: use ilog2(x) instead of fls(x)-1
In three instances where fls(x)-1 is used, the compiler does not know
that x is nonzero and so adds needless zero checks.  Using ilog(x)
instead saves, in each instance, about 4 instructions, including a
conditional, and 16 or so bytes, on an amd64 build.

Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D45330
2024-06-03 12:45:45 -05:00
Mitchell Horne deab57178f Adjust comments referencing vm_mem_init()
I cannot find a time where the function was not named this.

Reviewed by:	kib, markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45383
2024-05-27 18:37:40 -03:00
Bojan Novković da76d349b6 uma: Deduplicate uma_small_alloc
This commit refactors the UMA small alloc code and
removes most UMA machine-dependent code.
The existing machine-dependent uma_small_alloc code is almost identical
across all architectures, except for powerpc where using the direct
map addresses involved extra steps in some cases.

The MI/MD split was replaced by a default uma_small_alloc
implementation that can be overridden by architecture-specific code by
defining the UMA_MD_SMALL_ALLOC symbol. Furthermore, UMA_USE_DMAP was
introduced to replace most UMA_MD_SMALL_ALLOC uses.

Reviewed by: markj, kib
Approved by: markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D45084
2024-05-25 19:24:46 +02:00
Ed Maste 9b1de7e484 vt/sc: retire logic to select vt(4) by default for UEFI boot
We previously defaulted to using sc(4) with a special case to prefer
vt(4) when booted via UEFI.  As vt(4) is now always the default we can
simplify this.

Reviewed by:	imp, kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45356
2024-05-25 11:00:35 -04:00
Ricardo Branco e30621d58f mqueue: Introduce kern_kmq_timedreceive & kern_kmq_timedsend
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1248
2024-05-23 13:40:46 -06:00
Ricardo Branco 289b2d6a79 mqueue: Export some functions to be used by Linuxulator
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1248
2024-05-23 13:40:46 -06:00
Ricardo Branco ddbfb544c6 mqueuefs: Relax restriction that path must begin with a slash
This is needed to support Linux implementation which discards the leading slash when calling mq_open(2)

Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1248
2024-05-23 13:40:46 -06:00
Ricardo Branco acb7a4deb2 mqueue: Add sysctl for default_maxmsg & default_msgsize and fix descriptions
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1248
2024-05-23 13:40:45 -06:00
Konstantin Belousov f0a4dd6d46 mqueuefs: mark newly allocated vnode as constructed, under the lock
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-05-23 01:13:29 +03:00
Konstantin Belousov b6f4a3fa75 mqueuefs: uma_zfree() can be postponed until mqfs sx mi_lock is dropped
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-05-23 01:13:29 +03:00
Konstantin Belousov 63f18b37e0 mqueuefs: minor style pass
Also remove not needed inclusion of sys/cdefs.h.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-05-23 01:13:29 +03:00
Stephen J. Kiernan 56b2742130 Add function to OSD to get values without taking the lock.
There are some cases of OSD use where the value is only initialized once
at a point where successive access of the value can be done so safely
without the need to take the lock.

Reviewed by:	markj
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44631
2024-05-22 15:55:48 -04:00
Pawel Jakub Dawidek 61e3e1776d capsicum: SIGTRAP is delivered also on ECAPMODE error.
Approved by: oshogbo (mentor)
2024-05-21 21:51:50 -07:00
Elliott Mitchell cbcb9778dd kern/rman: mark rman get functions as taking constants
The arguments are left completely unchanged by these functions.  This
allows passing constant pointers for verifying ownership, but not
modifying the contents.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
2024-05-21 17:52:29 -06:00
Elliott Mitchell 996fa9fb4e kern/rman: update rman_make_alignment_flags()
The flsl() function makes use of hardware functionality to compute the
value faster than this loop.  The only deviation from flsl() is at 0.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
2024-05-21 17:52:27 -06:00
Elliott Mitchell 037946dc9b kern/rman: remove rman_reserve_resource_bound(), partially revert 13fb665772
Not once has rman_reserve_resource_bound() ever been used.  There are
though several uses of RF_ALIGNMENT.  In light of this remove this
extra and leave the actually used portion in place.

This partially reverts commit 13fb665772.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
2024-05-21 17:52:24 -06:00
Elliott Mitchell beb1165a01 kern/rman: update debugging lines in subr_rman.c
Rather than hard-code the function name, use __func__ instead.  Apply
some style and adjust indentation as appropriate.  Remove the no longer
required braces.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
2024-05-21 17:52:21 -06:00
Elliott Mitchell 973c32297f kern/rman: update DPRINTF() macro, avoid semicolon swallowing match function
Using a variadic macro allows passing everything properly to printf().
Using the do { } while(0) construct ensures the macro acts like any
other single statement.  This shows just how long some of this has
existed.

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
2024-05-21 17:52:15 -06:00
Mariusz Zaborski 408957613b Regen 2024-05-21 22:03:20 +02:00
Edward Tomasz Napierala 6b7e4254a2 capsicum: allow rfork(2) in capability mode
Reviewed by:	brooks, rwatson
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D45040
2024-05-21 22:02:36 +02:00
Ryan Libby a332ba32d4 getblk: fail faster with GB_LOCK_NOWAIT
If we asked not to wait on a lock, and then we failed to get a buf lock
because we would have had to wait, then just return the error.  This
avoids taking the bufobj lock and a second trip to lockmgr.

Reviewed by:	mckusick, kib, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45245
2024-05-21 10:21:50 -07:00
Ryan Libby b92cd6b294 lockmgr: make lockmgr_disowned public and use it
Reviewed by:	mckusick, kib, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45248
2024-05-21 10:21:50 -07:00
Ricardo Branco 7975f57b7e uipc_shm: Fix double check for shmfd->shm_path
Reviewed by:	emaste, zlei
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1250
2024-05-21 09:39:53 -04:00
Zhenlei Huang 92f2a4c820 compat_freebsd4: Add const qualifier to the local variable s inside function freebsd4_uname()
This local variable s is for iterating characters of global variable
`version`. The content of `version` is not going to be altered by
function freebsd4_uname().

MFC after:	1 week
2024-05-20 12:02:32 +08:00
Warner Losh 97aedd3395 devctl: Disable the boottime optimization of suppressing NOMATCH
The usb bus code (uhub) doens't present the same information to devctl
as it does to the NOMATCH events it generats. As such, devmatch fails to
find USB devices on boot when NOMATCH events are optimized out. Since
the savings of boot time is relatively trivial for all but the most
demanding boot environments, disable it by default until this issue is
fixed.

Fixes: 6437872c1d
MFC After: 1 minute
Sponsored by:		Netflix
2024-05-18 07:07:16 -06:00
Konstantin Belousov 87a1565275 SysV IPC: provide in-kernel helpers to obtain ipcs(8)-like information
PR:	278949
Reviewed by:	markj
Tested by:	Ricardo Branco <rbranco@suse.de>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45175
2024-05-16 20:53:31 +03:00
Konstantin Belousov 53725168e1 SysV SHM: move SHMSEG constants to sys/shm.h
There are planned consumers in linprocfs.

Tested by:	Ricardo Branco <rbranco@suse.de>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45175
2024-05-16 20:53:31 +03:00
Austin Shafer 28a59100b5 linuxkpi: Provide a non-NULL value for THIS_MODULE
THIS_MODULE is used to differentiate modules on Linux. We currently
completely stub out any Linux struct module usage, but THIS_MODULE
is still used to populate the "owner" fields of various drivers.
Even though we don't actually dereference these "owner" fields they
are still used by drivers to check if devices/dmabufs/etc come
from different modules. For example, during DRM GEM import some
drivers check if the dmabuf's owner matches the dev's owner. If
they match because they are both NULL drivers may incorrectly think
two resources come from the same module.

This adds a general purpose __this_linker_file which will point to
the linker file of the module that uses it. We can then use that
pointer to have a valid value for THIS_MODULE.

Reviewed by:	bz, jhb
Differential Revision:	https://reviews.freebsd.org/D44306
2024-05-16 10:36:36 -07:00
Konstantin Belousov 21ccdb4119 vfs_domount_update(): postpone setting MNT_UNION until VFS_MOUNT() is done
The file system that handles updating the mount point might do lookups
during the update, in which case it could find the flag MNT_UNION set on
the mp while mount point is still not updated.  In particular, the
rootvp->v_mount->mnt_vnodecovered is not yet set.

Delay setting MNT_UNION until the mount is performed.

PR:	265311
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	mckusick, olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45208
2024-05-16 04:00:26 +03:00
Konstantin Belousov 5a061a38cd vfs_domount_update(): style, use space instead of tab
Noted by:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-05-16 04:00:26 +03:00
Zhenlei Huang d9f1f0a901 boottrace: Use NULL for SYSINIT's last arg, which is a pointer type
MFC after:	3 days
2024-05-14 12:03:50 +08:00
Mariusz Zaborski 663838451e syscalls: regen
Pointed out by: trasz
2024-05-13 19:29:57 +02:00
Edward Tomasz Napierala 050555e129 syscalls.master: allow vfork(2) in capsicum(4) capability mode
There is no reason not do do this, we already allow fork(2),
and I need vfork(2) for CHERI process colocation.

Reviewed by:	brooks, emaste, oshogbo
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39829
2024-05-13 16:12:29 +02:00
Warner Losh a2409f1737 intr: Document how to get the interrupt frame
Document that the only way to get the interrupt thread is to use
curthread->td_intr_frame, rather than the old-style of having a NULL
pointer for the interrupt thread. As of 38c35248fe, support for that
has been removed. I neglected to update that commit message with these
details.

Suggested by: mhorne
2024-05-10 15:41:36 -06:00