Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier 222c477cf0 docs: Update the VM swap documentation.
It was mostly up-to-date technically; a few details have been
amended where things have changed, and the "personal" stuff
dropped.
2026-03-26 14:54:05 -04:00
Augustin Cavalier 030b7c1426 kernel/vm: Clarify locking of VMArea and drop old documentation.
The documentation file hadn't been updated in a very long time,
and referred to locks and paradigms that have long since been
dropped (e.g. sMappingLock was removed in 2010, in
afed2658f4ef3e3df5ff8390d1d7a51b5b897a9e.)

Add a few "protected by" comments in VMArea to clarify things,
but otherwise this document looks entirely obsolete (I went
through all of it.)
2026-03-26 14:11:23 -04:00
Augustin Cavalier b10415b7cc kernel/fs: Update comments in EntryCache.
Make the concurrency model slightly clearer.
2026-03-26 14:08:57 -04:00
Augustin Cavalier acde38ead3 freebsd_network: Update comment in kernel_malloc.
bus_dmamem_alloc doesn't need this behavior anymore.
2026-03-26 14:01:54 -04:00
Augustin Cavalier eb097f749b kernel/slab: Use (1 << x) to define cache flag bits.
No functional change intended.
2026-03-26 12:26:22 -04:00
Augustin Cavalier bb1c367a6d kqueue: Add a no-op EV_ENABLE definition.
EV_ADD implies ENABLE, so this isn't needed, but a lot of applications
try to specify it anyway. So this extends source compatibility.

If in the future we ever implement EV_DISABLE, we can just add a
real definition for it then, and since ADD implies ENABLE existing
applications shouldn't break.
2026-03-26 12:25:41 -04:00
Augustin Cavalier 5ac1c21e5f kernel/vm: Set the memory type on cloned device cache areas.
If the source area is now mapped write-combining, so will the
target area.

May fix some problems or slowness that occurred after the
framebuffers refactor commits.
2026-03-25 12:50:57 -04:00
Augustin Cavalier 7240f3762f kernel: Add mechanism to replace specific object caches with the guarded heap.
This allows the guarded heap to be used in a much more targeted way,
if it's suspected specific object_caches have problems.

Enabled by default for KDEBUG. The new safemode/kernel option is
"guarded_heap_for_object_caches". This accepts a comma-separated
list of quoted strings, optionally with * at beginning and/or end
(but not middle.) Examples:

mbufs*   # matches caches starting with "mbufs"
*jumbo9*	# matches caches containing "jumbo9"
"*jumbo9 chunks","mbufs*" # matches caches ending with "jumbo9 chunks"
                          # or starting with "mbufs"

This should help with diagnosing #19973, among others, without needing
to compile custom versions of drivers or anything like that.

Unfortunately it is not possible to use this mechanism to selectively
replace parts of the slab malloc. The slab malloc free() relies on
the MemoryManager to figure out what cache an object belongs to, which
doesn't work if objects of some size classes aren't known to the
MemoryManager at all.
2026-03-24 18:10:10 -04:00
Augustin Cavalier 90ac9e6538 kernel/vm: Overhaul swap cache commitments.
Before this commit, swap space was committed entirely orthogonally
from memory commitments. This was not handled at all correctly
when cutting areas (the area cutting logic tries to migrate commitments
between caches, but in the case of swapping caches, it didn't,
and couldn't, take the separate fCommittedSwapSize into account.)

Even without that problem, totally separate swap and memory commitments
caused other problems. For instance, suppose a setup with 4GB of RAM
and 4GB of swap. Many caches are created, and all 4GB of swap gets
reserved, but the caches with this swap reserved have no or few pages
in them. Then, all 4GB of RAM gets used up. The page daemon runs, and
looks for things to swap out, but it can't find anything because all
our swappable caches with pages have no swap reservations, so all it
can do is flush out cached pages, which just degrades performance.

Or, consider what would happen if the 4GB of swap was released, but
the 4GB of RAM was still in use, and then the kernel tried to
allocate memory. It would get OOM errors, because none of the
caches have swap commitments and so nothing can be written out.

Under this new system, the specific swap space reservation only happens
just before the page is first written out, so both these cases should
be handled smoothly, and swap should be used in a much more sensible
fashion overall.

This change seems to be more in line with what other OSes do (Windows
Task Manager's "Committed" clearly is RAM+swap, for instance.)

The only potential downside to this change is that swappable caches
may temporarily go over their commitment when reading or writing
out pages to swap, before the page daemon has a chance to come by
and free the page or the swap space. But as that is a temporary state
and should always be resolved by the page daemon, I think it's
probably an acceptable trade-off.

Change-Id: I928f4b4cacbec26ed6315179476eaff1a7f626c8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10305
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-24 14:02:52 +00:00
Augustin Cavalier 9be0e148a2 vesa & framebuffer: Clone the framebuffer instead of having it be user-accessible.
This begins paving the way for removal of user access to kernel
address space.

After the previous commits, BDirectWindow and BWindowScreen
still function properly.

Part of #19990.

Change-Id: I8477e43cd517ba67383755a4cb60b00bc117f5d7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10559
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier 95ace7f374 kernel/vm: Introduce methods to change the cache of all an area's clones.
This will be useful in the case of cloned device caches based
around physical memory, e.g. for framebuffers.

Change-Id: If2b864208e86f436e91379b73c4b866b0bd5e1d7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10558
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier 861f644f19 app_server & BWindowScreen: Do away with AS_GET_FRAME_BUFFER_CONFIG.
It can't work if the framebuffer is mapped per-application.
Instead, use the accelerant hook to get the framebuffer.

The BScreen methods this disables were deprecated and marked
private already, so no Haiku applications should be affected.
(If really necessary they could be reimplemented with BWindowScreen.)

Remove first _GetCardInfo in BWindowScreen; we invoke it
later, closer to where the buffer is actually used.

Tested with ParticlesII (which uses BWindowScreen) on VESA
with the new user-only-mapping accelerant.

Change-Id: I405bcfa8cb1eb2d0c346fafbc6233bef15196134
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10572
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier f6be811473 BDirectWindow: Clone the framebuffer from app_server, if necessary.
This paves the way for accelerants to map the framebuffer in
user memory, not kernel memory. It uses the ServerMemoryAllocator
in order to avoid mapping the framebuffer multiple times in
client applications.

While at it, clean up some names.

Tested with DirectWindowStars and GLTeapot, both work.

Change-Id: I4e0c003fae99891044af0a5e6e1d6a4506da6430
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10571
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-24 14:01:11 +00:00
Augustin Cavalier ede14380e5 kernel/slab: Run slab_object automatically when the 0xdeadbeef assert fails. 2026-03-23 23:11:40 -04:00
Augustin Cavalier a277043c1f kernel: Overhaul debug heaps system.
Instead of the kernel heap being a compile-time parameter, make it
a runtime parameter (if DEBUG_HEAPS is specified, at least; otherwise
we're hardwired to the slab heap as before.)

This is similar to what's done in userland: there LD_PRELOAD and
MALLOC_DEBUG control the heaps, here "kernel_malloc" and then
"guarded_heap_options" kernel settings control the heap.

While at it, apply fixes to the guarded and debug heaps to ensure
a minimum alignment of sizeof(void*), if no specific alignment
is requested.

Tested with a lot of build configurations (DEBUG_HEAPS 0, 1;
DEBUG_HEAPS_DEFAULT slab, guarded; USE_DEBUG_HEAPS_FOR_OBJECT_CACHE
0, 1) and with various parameters specified in the bootloader.
2026-03-23 23:01:26 -04:00
Augustin Cavalier 4fd16356e0 kernel: Move the debug heap to a separate file in the debug directory. 2026-03-23 23:01:26 -04:00
Augustin Cavalier 0e5639ad74 L2CAP: Remove dependency on userland bdaddrUtils.h.
And do some other code cleanup too.
2026-03-23 14:35:09 -04:00
Augustin Cavalier 7e813b6181 bluetooth: Drop unused int128.
This should be done using __int128 if necessary.
2026-03-23 14:34:25 -04:00
Augustin Cavalier 3c05f06edb kernel/user_mutex: Add missing get after allocating contexts.
Fixes a potential KDL.
2026-03-23 14:34:10 -04:00
Augustin Cavalier 54ad26255c kernel/vm: Fix set_memory_protection syscall.
check_protection adds kernel flags, so we need to do that after
checking the already-set flags.

Fixes #19988.
2026-03-23 14:31:51 -04:00
Augustin Cavalier 935941e772 kernel/vm: Drop team argument from vm_set_area_protection.
It's not needed and just creates confusion. Permissions checks
are done with the current team and the "kernel" parameter.
2026-03-23 14:31:00 -04:00
Augustin Cavalier c977e8a221 libroot/locale: Handle current_locale() being called early in initialization.
Fixes #19954.
2026-03-23 14:24:32 -04:00
Augustin Cavalier 89c3592b51 BBlockCache: Initialize the mutex unconditionally.
Otherwise we may get assertion failures under the debug heaps.
2026-03-23 14:07:18 -04:00
waddlesplash 4660bcfbab Revert "ImageRules: do not include catalogs from .so in dependencies"
This reverts commit 368cac3c9d.

Actually excluded catalogs for .so in all cases, not just
dependencies.

Change-Id: I6f8997073c71a6a9fa3fa875e971242bc8487666
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10562
Reviewed-by: waddlesplash <[email protected]>
2026-03-22 02:14:02 +00:00
Augustin Cavalier cafe26877f kernel: Actually fix call_all_cpus to invoke the method with interrupts disabled.
sICIEnabled is never set if sNumCPUs == 1.

Actually fixes #19983.

Change-Id: I3c50d118bb44ba4a2289586d4305d663a3a7900a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10561
Reviewed-by: waddlesplash <[email protected]>
2026-03-22 01:48:40 +00:00
Augustin Cavalier d3c2dd6c14 kernel/vm: Commit changes missed in previous commit. 2026-03-21 13:47:13 -04:00
Augustin Cavalier e13a6e6ec2 kernel/lock: Assert that a write lock isn't held in switch_from_read_lock. 2026-03-21 13:37:13 -04:00
Augustin Cavalier 5811e4bf6f kernel/vm: Pass the kernel parameter down in transfer_area() properly. 2026-03-21 13:18:28 -04:00
Augustin Cavalier 5fffbbfc48 kernel/vm: Minor API changes for consistency in VMCache.
* Insert/Remove can't fail, so drop status_t return values.

 * "TransferAreas" is really "TakeAreasFrom", so rename it. This
   avoids confusion with the "transfer_area" API call, which moves
   an area to another address space (keeping the same cache.)
2026-03-21 12:30:02 -04:00
Augustin Cavalier 05f1182cca kernel/vm: Overhaul protection checks and fixup.
* Give arch_vm_supports_protection a team_id argument (primarily
   to allow the kernel address space to be more restricted than
   user ones.)

 * Move invocation of arch_vm_supports_protection to a static method,
   and also call fix_protection from there.

 * Consolidate protection checks.
2026-03-21 09:26:44 -04:00
Augustin Cavalier a01f1a3da8 usb_asix: Delete.
Now provided by asix88xxx instead.
2026-03-18 13:54:26 -04:00
Augustin Cavalier 231ecae98b kernel/scheduler: Skip setting invoke_scheduler in scheduler_reschedule_ici.
It isn't needed now that it's set before sending the ICI. Saves
a lot (hundreds, in some basic testing of compile jobs) of
unnecessary scheduler invocations.
2026-03-17 20:25:53 -04:00
Augustin Cavalier 87e0daf0a1 kernel: Include <smp.h> in VMTranslationMap.
RISC-V at least doesn't implicitly include it.
2026-03-17 14:49:13 -04:00
Augustin Cavalier 1b6efe284a kernel/smp: Avoid calling cpu_pause() if test-and-set works on first try. 2026-03-17 14:48:53 -04:00
Augustin Cavalier 14b78e205c kernel/smp: call_all_cpus should run with interrupts disabled.
For consistency. And so should call_single_cpu.

Fixes #19983.
2026-03-17 14:23:58 -04:00
Augustin Cavalier 89c81c2ac1 kernel: Fix copy/paste error from previous commit. 2026-03-17 13:37:04 -04:00
Augustin Cavalier cf2179fa35 kernel: Add invalidation utility routines to VMTranslationMap.
These allow us to move a lot of the basic logic out of the
TranslationMaps. In the process, it extends the fix applied
to x86 in the previous commit to all the other maps.
2026-03-17 13:30:11 -04:00
Augustin Cavalier b4546a49f0 kernel/x86: Don't spuriously set the current CPU bit in Flush().
We may be called from the page daemon, which may be running on
a different CPU than the one this map is active on. So don't
bother flushing unnecessarily if we can avoid it.
2026-03-17 13:19:31 -04:00
Augustin Cavalier d4817afe36 kernel/smp: Use a single-CPU ICI if multicasting to only one CPU.
This avoids the broadcast mailbox (and the incrementing of
other CPU's counters) entirely in this case.

As this is used for TLB invalidation, processes that are only
running two threads at once will benefit immensely from this.
It also seems to be triggered by the kernel's "idle_scan_active_pages"
logic, which sometimes sends invalidations to CPUs besides its own.

On the VM setup, this path was hit around 200 times during boot,
around 600 times during a rebuild of HaikuDepot + mime_db, and
50,000+ times while running Iceweasel (Firefox). On bare metal,
it was hit around 300 times during boot, 300 times during a rebuild,
and 90,000+ times while running Iceweasel (over a different length
of time, though.)
2026-03-17 13:06:35 -04:00
Augustin Cavalier 9c08c836bf kernel/smp: Use read spinlocks when prepending broadcast messages.
Some brief testing shows that concurrency is unlikely here, but
we might as well.
2026-03-17 12:08:59 -04:00
Augustin Cavalier b6447046fc kernel/smp: De-indent smp_send_ici.
No functional change intended.
2026-03-17 11:54:27 -04:00
Augustin Cavalier 19bcb3be0a kernel/scheduler: Make invoke_scheduler atomic to skip unnecessary ICIs.
Following upon a KDL reported by atomozero, on wait-for-free-SMP-messages
on an unblock occurring with interrupts disabled.

In changing cpu_ent, move disabled to the beginning to avoid
enlarging the structure unncessarily.

On a 4-core VM, this skips around 200 sends during boot, and
over 3000 during a rebuild of HaikuDepot + mime_db (cold). On
bare metal (i3, 2x2), it skips around 150 during boot, and a bit
below 3000 during a rebuild of HaikuDepot + mime_db (over a much
longer time than in the VM, as the hardware is slower.)

Performance in the VM doesn't look much different. But this might
help in VirtualBox, or other situations where ICI latency is far
above what it should be.
2026-03-17 11:25:36 -04:00
Augustin Cavalier d5a5f22579 pegasus: Replace with the upstream FreeBSD version.
Fixes #19745.

Change-Id: Ie540beecbf9f0a998f016f015357a38d1fa95bfd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9599
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2026-03-16 21:30:32 +00:00
Augustin Cavalier 924599c310 L2CAP: Change from SOCK_STREAM to SOCK_SEQPACKET.
This is the same as what FreeBSD does.
2026-03-16 13:21:46 -04:00
Augustin Cavalier 7512053757 kernel/smp: Refactor ICI broadcast/multicast to invoke the current CPU too.
Since the methods now don't just "send", the names are changed
also (which is fitting since they're now API-incompatible.)

The changes in the TranslationMaps to adopt this fixes a correctness
issue: previously TLB invalidations would be done either with or
without interrupts enabled depending on how they were invoked.
Now, they'll always be done with interrupts disabled. (This is
the same fix that was recently done to x86.)

The idea with processing the ICIs on the current CPU too is
that presumably the other CPUs will take just as much, if not
more, time processing the ICI than the sending CPU. So, we might
as well do the processing while we wait, rather than before or after.

Testing shows this to indeed be the case. On a bare metal i3, kernel
map invalidations (with global invalidations always forced) across
a boot-to-desktop go from around ~60.8ms cumulative before,
to ~51.8ms cumulative after this change.

Change-Id: Icd0343d462de7cf11043e6438f47b02f6b88bb8b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10472
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-03-16 13:41:00 +00:00
Augustin Cavalier 000c32a568 asix88xxx: Import drivers from FreeBSD to replace usb_asix.
The homegrown usb_asix was partially based on the upstream FreeBSD
driver anyway, and hasn't seen much maintenance in recent years.
We might as well replace it with the FreeBSD version. In the process,
also add the "axge" driver, supporting the Gigabit version of this
hardware.

Tested by smrobtzz with the AX88179A: "it seems to work perfectly".

Change-Id: I37fdfc2cef6100916d6034817f117286f7f443b2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9600
Reviewed-by: waddlesplash <[email protected]>
2026-03-16 13:17:57 +00:00
Augustin Cavalier 9936387223 freebsd_network: Add everything needed for USB ethernet drivers.
Change-Id: I152d3fcdb50b9473f06c2164b9abb38b7c9d7e40
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9598
Reviewed-by: waddlesplash <[email protected]>
2026-03-16 13:17:57 +00:00
Augustin Cavalier d59105d001 freebsd_network: Synchronize some mbuf routines with upstream FreeBSD.
Also delete an OpenBSD compatibility section that isn't used.

This includes a fix to mbufq_full (made in 2019 in FreeBSD)
to allow for mbufqs of unlimited size, apparently needed by
some drivers, found by @smrobtzz while testing USB ethernet
drivers.
2026-03-16 08:50:43 -04:00
Augustin Cavalier 913f501fbd kernel: Use uint64 for seconds in datetime conversion routines. 2026-03-16 08:35:51 -04:00
Augustin Cavalier a2e4f9f75f kernel/x86: Use call_single_cpu_sync in get_cpuid.
Sends a more targeted ICI than a broadcast.
2026-03-10 17:55:12 -04:00
Augustin Cavalier 1d740a6700 kernel/smp: find_free_message expects interrupts enabled.
Use thread_pin instead of disable_interrupts in the call_*
methods.
2026-03-10 17:54:33 -04:00
Augustin Cavalier e867e95538 kernel/smp: Deduplicate call_*_cpu.
* Rename call_single_cpu for consistency.

 * Combine call_all_cpus implementations into one, like call_single_cpu.
2026-03-10 15:33:33 -04:00
Augustin Cavalier 334e90a2ac kernel/smp: Just return free messages using a write spinlock.
There isn't much value in using extra atomics here.
2026-03-10 15:21:27 -04:00
Augustin Cavalier 3c28d298f7 kernel: Don't fail if the private string.h is included under GCC2. 2026-03-10 13:10:25 -04:00
Augustin Cavalier 918b2dfaab BMessage: Eliminate UsePrivateHeaders kernel. 2026-03-10 13:10:25 -04:00
Augustin Cavalier b350405e06 kernel/smp: Refactor smp_msg structure allocation.
The SMP_MAX_CPUS * 4 fixed pool size apparently goes all the way
back to NewOS, which supported only 4 CPUs max. As ours is now
64, this means the fixed pool size was very large even on systems
with only a few cores. So, instead, allocate 4 messages per CPU
(though often more, due to rounding up to the page size; e.g.
on x86_64, 1 page fits 56 smp_msgs.)

Also, put them a dedicated area, to keep them a bit more segmented
from the kernel heap, in case of problems.
2026-03-10 13:04:46 -04:00
Augustin Cavalier 10d0685a9e EFI: Fix some more instances of memcpy on other architectures. 2026-03-10 12:20:00 -04:00
Augustin Cavalier 69499b0e00 kernel: Use compiler-builtin memset, memcpy, memmove, memcmp.
Since the kernel is built with -ffreestanding, and thus -fno-builtin,
the compiler ignores the function names and doesn't perform optimizations
(e.g. inlining for small values) that it otherwise could. So, here,
we add a string.h that supplements the default, and uses #define to
reinstate the builtins, and thus the optimizations.

Linux and FreeBSD at least apparently do the same. A quick compile
benchmark in a VM doesn't show much difference, maybe a slight
decrease in sys time.
2026-03-10 12:00:59 -04:00
Augustin Cavalier ff861e0ea3 kernel, lib, drivers: Prepare for use of builtin string.h operations.
This fixes various -Werror=class-memaccess that are triggered
when using the builtins.
2026-03-10 12:00:59 -04:00
Augustin Cavalier 2adbc5705a Eliminate "UsePrivateHeaders kernel" from most of userland.
Now that the DoublyLinkedList and other classes are in a "util"
directory, this isn't needed.
2026-03-10 12:00:58 -04:00
Augustin Cavalier 103ca61228 bluetooth: Eliminate the need for kernel headers in userland. 2026-03-10 12:00:57 -04:00
Augustin Cavalier 18c93b9569 PPP: Eliminate the need for kernel headers in userland.
Also fix some -Werrors.
2026-03-10 12:00:57 -04:00
Augustin Cavalier dd2eeb7dff kernel/smp: Style fixes.
No functional change intended.
2026-03-09 21:08:52 -04:00
Augustin Cavalier dd24eecac1 kernel/smp: Distinguish CPUSet::GetBit from GetBitAtomic.
I checked all invocations of GetBit; as far as I can tell,
only the two adjusted here in smp.cpp are done while the Set
may be concurrently modified, and even then I don't know
that they really need to be atomics, anyway.
2026-03-09 20:58:54 -04:00
Augustin Cavalier 97a65a027d kernel/smp: Use rw_spinlocks for ICI locks.
This allows read spinlocks to be used in check_for_message
and return_free_message.

On a 4-core VM, there don't seem to often be concurrent readers
(a counter I setup got only about 400-500 hits for booting up
and starting a web browser, at most.) But on bare metal (i3,
2 cores x 2 hyperthreads) we get it a lot more: 30,000+ times
during boot alone.

Kernel map invalidation (with a hack to invalidate all every time)
across boot-to-desktop takes a cumulative ~68.0ms before this change,
and ~61.0ms after, on the bare metal system. (On the VM it's also lower
after this change.)

Presumably on systems with more CPUs it will get hit even more
often still. So this optimization seems worth it.
2026-03-09 20:58:54 -04:00
Augustin Cavalier de74304510 kernel/x86: Always call arch_cpu_global_tlb_invalidate with interrupts disabled.
Fixes a race. Discovered by SED4906.

Change-Id: I2b267312e9f3ff32bafa2ac2784f5d4a9905e24e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10416
Reviewed-by: waddlesplash <[email protected]>
2026-03-09 17:37:05 +00:00
Augustin Cavalier 767d7cf9fa libroot & kernel: Replace strchr, strcpy with musl's versions.
They call out to other library functions, which are better optimized
than the old naive implementations.

Add -fno-builtin to the musl strings Jamfile, otherwise GCC
generates infinite recursion in strcpy, apparently.
2026-03-05 17:31:30 -05:00
Augustin Cavalier fb0556ae2b BFS: Remove the inode from the Removed list with the transaction lock held.
Fixes #19953.
2026-03-05 15:58:28 -05:00
Augustin Cavalier 26f8f18b1c BFS: Assert in RemovedInodes(), don't just have a comment.
This would've caught the cause of #19953.
2026-03-05 15:56:48 -05:00
Augustin Cavalier 11280e1b51 kernel/device_manager: Remove unnecessary includes of Locker.h. 2026-03-05 13:35:14 -05:00
Augustin Cavalier a3fe30c940 kernel/fs: Rename create_vnode to file_create_vnode.
Matches dir_create_vnode. As discussed on the review
for the previous commit.
2026-03-05 13:00:18 -05:00
Augustin Cavalier 585ac6895e kernel/user_mutex: Let single-threaded applications sleep on mutexes.
It seems some single-threaded applications do use them, which doesn't
result in a deadlock because they use timeouts (or maybe wait on
signals, too.)
2026-03-05 12:46:31 -05:00
Augustin Cavalier 7ef695df5c kernel: Allocate user_mutex_contexts when adding the second thread to a team.
This allows us to gracefully fail if memory allocation fails,
rather than panic()ing. If a single-threaded application tries
to wait on a non-shared user_mutex in single-threaded mode, it
will now be dropped into the debugger.
2026-03-04 21:42:03 -05:00
Augustin Cavalier e6569ec320 kernel: Add an AssertLocked() to Team.
The mutex member is private, so this is necessary for other methods
to assert the team mutex is locked.
2026-03-04 21:38:43 -05:00
Augustin Cavalier f1425c9e61 freebsd_network: Include <thread.h> first, to avoid ASSERT incompatibilities. 2026-03-04 21:35:11 -05:00
Augustin Cavalier ff0cd4274c SoftwareUpdater: Move "complete" logic to ProgressApplyingChangesDone.
This is more like how pkgman does it. Behaviorally, users should
not notice a difference.
2026-03-03 17:45:42 -05:00
Augustin Cavalier 61c7d7e4ee Package Kit: Move a number of headers into the source directory.
These classe aren't used, and probably shouldn't be used, outside
Package Kit itself.

Also drop some files from libpackage_build that are not needed.
2026-03-03 17:45:28 -05:00
Augustin Cavalier 5f0f0b02b4 Package Kit, pkgman, SoftwareUpdater: Offer to delete old state directories.
This adds a new job to the Package Kit, and an invocation
in pkgman after changes are applied. The job takes a time_t before,
and an int32 minToKeep, and (after confirmation) deletes all state
directories which were last modified before that time, but also
keeps at least the minimum specified.

pkgman defaults to calling it with (now - 30 days, minimum 10).
SoftwareUpdater does the same, but without bothering the user
and just defaults to doing the cleanup.

Change-Id: I15f5232b11daba5955e7fa07f696ad7785507931
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10404
Reviewed-by: waddlesplash <[email protected]>
2026-03-03 22:14:57 +00:00
Augustin Cavalier 79ab5081b2 Package Kit: Rename InstallationLocationInfo::OldState to ActiveState.
It doesn't refer to some random old state, but the currently active
one. (If the currently active state is the default one, then it will
return nothing.) So, this should make things clearer.

Change-Id: Ib3fe842f5fb51eaf2ef2f31bad8b292b47a3fb36
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10403
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2026-03-03 22:14:57 +00:00
Augustin Cavalier 418769d64b BResources: Mark deprecated methods _DEPRECATED. 2026-03-02 21:11:39 -05:00
Augustin Cavalier dc4a606f5e Clock: Use BResources::LoadResource instead of FindResource.
The latter is deprecated.
2026-03-02 21:11:23 -05:00
Augustin Cavalier f071ee419d BMimeType: Use the new _DEPRECATED to mark SetType deprecated.
This is the first use of this new macro.
2026-03-02 21:03:25 -05:00
Augustin Cavalier a3be73a455 BTokenSpace: Add cast to appease GCC2. 2026-03-02 20:35:01 -05:00
Augustin Cavalier 9e3e304057 BLocale: Name the BLocker. 2026-03-02 20:22:14 -05:00
Augustin Cavalier b6441edfac BLooperList: Use rw_lock.
Improves efficiency, as some functions can use a read lock
instead of a write lock.

Eliminates another statically-created BLocker.
2026-03-02 20:17:51 -05:00
Augustin Cavalier 5eef2f1d00 BTokenSpace: Use pthread_mutex instead of BLocker.
This header gets included in the build platform, so we can't use
the private recursive_lock.

Eliminates another statically created BLocker, due to gDefaultTokens.
2026-03-02 20:16:32 -05:00
Augustin Cavalier f9850b561c kernel/user_mutex: Panic instead of failing due to OOM.
This is not an expected failure condition for most applications,
so try to avoid propagating it to userspace.

(If necessary, it should be possible to avoid even the possibility
of this by just allocating necessary datastructures upfront
instead of "lazily". But that seems unnecessary at the moment.)
2026-03-02 19:38:26 -05:00
Augustin Cavalier ae70142168 BBlockCache: Use a pthread_mutex instead of BLocker.
The lighter "struct mutex" is in a private header, so we can't
inline it in a public one, so just use pthread_mutex here.

By adjusting padding, the class size stays the same (72 bytes
on 32-bit, 96 bytes on 64-bit; confirmed via static_assert.)

A quick benchmark running "new/delete BMessage" in a loop on 4
threads at once goes from 30-36 seconds before this commit
to around 13-17 seconds, sometimes as low as 3 seconds, afterwards,
so clearly this is a significant improvement.

This also eliminates another BLocker allocated on application startup.
2026-03-02 19:37:13 -05:00
Augustin Cavalier 184b57aa71 BBlockCache: Rewrite header for style. 2026-03-02 18:01:56 -05:00
Augustin Cavalier 8cc48bf580 QueryParser: Don't divide by zero on empty attributes.
Fixes a KDL.
2026-02-28 22:16:43 -05:00
Augustin Cavalier f3fd885731 Game & Media Kits: Avoid some usages of static BLockers.
Saves some semaphores.
2026-02-28 22:16:15 -05:00
Augustin Cavalier 4d055d982a BGameSoundDevice: Cleanup.
* Use new-style header comments.

 * Put globals inside class or make static, instead of exporting
   unnecessarily.
2026-02-28 21:52:05 -05:00
Augustin Cavalier 6a4a02907a EHCI: Disable the physical buffers logic, at least for now.
It seems it may have caused serious regressions on some hardware,
see #19949 and #19945.
2026-02-28 20:34:12 -05:00
Augustin Cavalier 4d9bb0a399 LaunchBox: Style cleanup after previous change. 2026-02-28 20:31:30 -05:00
Augustin Cavalier aa939503b6 AppServerLink: Use the correct static initializer for recursive_lock.
Interestingly, the modern GCC accepted the "wrong" one, only GCC 2 didn't.
2026-02-27 10:26:25 -05:00
Augustin Cavalier 66d85d702b Terminal & Expander: Replace exit() with _exit() in fork+exec failure path.
This is necessary to avoid destructors being called in the child,
potentially messing up parent state.
2026-02-27 10:17:40 -05:00
Augustin Cavalier 1380d03a42 time_stats: Replace fork+exec with posix_spawn. 2026-02-27 10:16:51 -05:00
Augustin Cavalier 8cf5bd97a2 launch_daemon: Replace fork+exec with posix_spawn. 2026-02-27 10:16:35 -05:00
Augustin Cavalier 23ef8b89c6 net_server: Replace fork+exec with posix_spawn.
Uses POSIX_SPAWN_SETSID, so needs the previous commit to work.
2026-02-27 10:16:21 -05:00
Augustin Cavalier 27e95c346a posix_spawn: Fix implementation of POSIX_SPAWN_SETSID.
setsid() returns -1 in case of error, and a pid_t in case of success.
2026-02-27 10:13:46 -05:00