Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier b6ea04cf89 USB: Transfers should hold references to their Pipes.
This way, the Pipe won't be seen as "idle" when there are still
transfers in flight with references to it.

May help with diagnosing or even outright fix #17549, #18768, #17799
and #17348.
2024-10-11 11:24:11 -04:00
Augustin Cavalier f7325a93db USB: Use BReferenceable for USB objects.
The "busy" counter functionally amounted to a reference count.
So just turn it into a real one, instead.
2024-10-11 10:46:18 -04:00
Augustin Cavalier 50496cd3da BReferenceable: CountReferences() needs to use atomic_get. 2024-10-11 10:22:37 -04:00
Augustin Cavalier 0dfa0e581d kernel/x86: Implement DebugGetReverseMappingInfo for X86VMTranslationMap64Bit.
Change-Id: I57b734dabaf1ed02fc681cb0b957fa7392c2f69f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8367
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2024-10-11 14:19:38 +00:00
Augustin Cavalier d2b9dcde31 kernel/vm: Only print "not implemented" messages in VMTranslationMap under KDEBUG.
Change-Id: I63e3c71b40d3ff5ae4a272fbbb1da96d7d2d8f38
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8443
Reviewed-by: waddlesplash <[email protected]>
2024-10-10 20:07:14 +00:00
Augustin Cavalier 9e3eeba450 bootloader: Actually, don't release the heap just yet.
The EFI loader still needs it inside platform_start_kernel,
unfortunately.
2024-10-10 15:36:52 -04:00
Augustin Cavalier 545ea51c99 bootloader: Actually release the heap.
This avoids leaking the bootloader heap memory into the kernel.
Ideally it'd be dropped automatically, but in seems in many cases
it isn't (even on EFI).

Adjust platform logic to always remove the physical allocated range,
and ignore the return code and reuse the memory anyway if we can.
2024-10-10 15:04:47 -04:00
Augustin Cavalier 875b13d582 bootloader: Overhaul heap region allocation.
Previously, there was only platform_init_heap/platform_release_heap,
which allocated a single static heap region for the heap to use,
and any subsequent heap allocations had to go through the standard
platform_allocate_region, which allocates regions visible both
to the bootloader and the kernel.

But as mentioned in previous changes, it isn't always easy to
release regions allocated that way. And besides, some bootloaders
(like EFI) use a completely separate mechanism to allocate
bootloader-local memory, which will never get "leaked" into
the kernel.

So instead, refactor all platforms to instead provide two
new methods: platform_{allocate,free}_heap_region. On EFI
this is easy to implement; on most other platforms we have
logic based more on the old platform_init_heap or allocate_region.

(On the BIOS loader in particular, we can only fully release
the memory if it's the last thing we allocated in the physical
addresses. If the "large allocation" threshhold is lowered
back to 16 KB, then we are unable to do this enough times
that we will run past the end of the 8 MB identity map and
thus fail to boot. But with the larger threshhold, we don't
leak nearly as much, and don't hit the threshhold.)

This should further reduce the amount of bootloader memory
permanently "leaked" into the kernel's used memory, though
on some platforms it may still be nonzero.

Change-Id: I5b2257fc5a425c024f298291f1401a26ea246383
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8440
Reviewed-by: waddlesplash <[email protected]>
2024-10-10 16:13:11 +00:00
Augustin Cavalier 359a04ba96 bootloader: Cleanup handling of LargeAllocations.
* Remove unused SetTo; clear Address/Size to 0 on init.

 * Free all LargeAllocations in heap_release. (This method isn't
   actually called by default before kernel entry, though, so
   it probably doesn't matter much.)

Change-Id: If038274adcd65adae527235d16860af659ef37b6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8439
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2024-10-10 16:13:11 +00:00
Augustin Cavalier d1ef184af6 bootloader: Add remove_{physical|virtual}_allocated_range methods.
Will be used in following commits.

Change-Id: Ica89d28cbf6980aca8dc347dfdcb200a0e637e9a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8442
Reviewed-by: waddlesplash <[email protected]>
2024-10-10 16:13:11 +00:00
Augustin Cavalier 5e451463d0 kernel/vm: Add assertion for a TODO comment in mark_page_range_in_use.
It should be OK to call this during kernel startup without using
reservations, since it's mostly used for fixed memory ranges
specified by the bootloader.

Also turn a later dprintf into a panic.
2024-10-10 11:39:20 -04:00
Augustin Cavalier 1db0961121 kernel/vm: Remove an obsolete comment.
page_num_t is typedef'd to phys_addr_t, so it's 64-bits on 32-bit
platforms with PAE. In fact it's been so since the introduction
of phys_addr_t, so this comment was obsolete from the start...
2024-10-10 11:20:20 -04:00
Augustin Cavalier cd430b6fe5 kernel/vm: Also try starting new ranges in vm_allocate_early_physical_page.
If the existing allocated ranges are from physical memory ranges that
are just too small, then we'll need to start a new "allocated" range
based on the next-available physical memory range.

Should fix the "PANIC: error allocating early page!" tickets
(i.e. #14659 and friends.)
2024-10-10 00:44:27 -04:00
Augustin Cavalier 27d0a861e0 kernel/vm: Clean up vm_allocate_early_physical_page.
Clean up comments, merge assignments with declarations, etc.
No functional change intended.
2024-10-09 23:42:37 -04:00
Augustin Cavalier b1e579c6f1 kernel/vm: Clean up dump_caches command.
* Declare kCacheInfoTableCount as uint32 and avoid casts.

 * Combine rootCount checks and consolidate + de-indent logic.
2024-10-09 23:41:36 -04:00
Augustin Cavalier 04c9b279cb packagefs: Followups to the directory locking change.
* Fix the build with DEBUG enabled.

 * Add some more read-locks, to be safe.
2024-10-09 23:29:03 -04:00
Augustin Cavalier 38946ff82f bootloader: Increase the "large allocation" threshhold to 128 KB.
Not all platforms can properly release memory allocated via
platform_allocate_region() at present; in particular the BIOS
loader seems to (at least partially) leak it. And due to how the
kernel args ranges are handed off to the kernel, it seems
allocated physical pages that aren't virtually mapped are
leaked at present as well.

That seems like a bug that we should likely fix, and moreover
the heap shouldn't use that facility at all (but instead
request bootloader-local memory if possible; on the BIOS
loader that will ultimately go through similar logic, but
on e.g. EFI it will be entirely separate.)

But in the meantime, we can just increase the size of the
"large allocation" threshhold so that packagefs temporary buffers
(of 64 and 93 KB) stay on the main heap, and don't hit that
facility at all. The "maximum boot loader heap usage" seems
to go up by about ~200 KB with this change (e.g. 588 KB -> 797 KB),
so increase the default heap size by 256 KB to compensate.

This fixes most of the rest of #14831: memory usage after the
boot has finished is down by over 100 MB (!). The remaining
problems and leaks can be dealt with in later changes.
2024-10-09 22:19:45 -04:00
Augustin Cavalier 10bba152b3 bootloader: Set a default heap size for all platforms.
Use the one from the BIOS loader (1.25 MB) and apply it everywhere.
2024-10-09 22:08:36 -04:00
Augustin Cavalier 6dae8511ff kernel/lock: Reinstate ASSERT_UNLOCKED_RW_LOCK in _rw_lock_read_lock.
This reverts commit 13a5c7f91f,
and adds an inline comment explaining why this actually isn't allowed,
despite "working" in most circumstances.

Doesn't affect anything in default builds (KDEBUG_RW_LOCK_DEBUG
is not enabled under KDEBUG.)
2024-10-09 16:23:01 -04:00
Augustin Cavalier bc89edc3c3 kernel/vm: Add some more information to the commitment <= size check.
May help with diagnosing #19155.
2024-10-09 14:56:35 -04:00
Augustin Cavalier 87a66be550 BFS: Optimize the search for the next free block.
We already started at the first-free in the block bitmap, but
after that we would just check individual bits as we went along.

Now we skip forwards to the next free block when encountering a
used block, by comparing to UINT32_MAX (all blocks used) and using
ffs() with a bitwise NOT (to find the first unused block in a chunk.)

This will benefit fragmented partitions more than non-fragmented ones.
I didn't see a significant speedup on my compile benchmark in a VM.

Fixes #18929.

X512 tested this patch and confirmed it reduces CPU usage on a
partition that he saw long times spent in AllocateBlocks on.

Change-Id: If71b5e24c585c2cc08879c8aefc80af8ae7da91f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8186
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2024-10-09 17:59:59 +00:00
Augustin Cavalier 6e690f7d11 drivers/network: Rename "vmx" to "vmxnet" and clean up glue. 2024-10-09 13:40:20 -04:00
Augustin Cavalier b62f05cbe7 kernel/vm: Use CREATE_AREA_DONT_COMMIT_MEMORY in vm_map_physical_memory_vecs.
Should fix an "ASSERT UNREACHABLE" KDL encountered when this method
is used.
2024-10-09 13:35:27 -04:00
Augustin Cavalier 3ac3785347 ICUTimeConversion: Remove special casing in _FillTmValues for GMT.
This basically reverts the changes in this function back to before
5b4d5ef897.

As c686c2216c is left intact, #19047
is still fixed regardless.
2024-10-09 13:34:34 -04:00
Augustin Cavalier 0059775c1d packagefs: Make directory nodes rw_locked instead of child entries.
This saves 40 bytes from the size of Node (on 64-bit architectures.)
UnpackingDirectory is still at 200 bytes, while UnpackingLeafNode
is now 96 instead of 136. This saves ~5MB of memory on my system
(UnpackingLeafNodes go from 16.2MB to 11.2MB.)

The general strategy is for Directories to use their own locks, while
all other nodes read-lock their parent directory during use. There are
a few edge cases around node creation and removal in the case of
non-directory nodes; see inline comments in Volume's
_RemoveNodeAndVNode as well as packagefs_put_vnode.

Since it's now possible for a node's parent to change or be deleted
when we don't have the lock (but only a reference), we need a lock
protecting just that field to hold while we acquire a reference to
the parent. (Right now, this is just one static rw_lock for all Nodes;
this could be changed in the future if necessary, but it seems performant
enough for the moment.)

Tested with basic system functionality, installing/uninstalling packages,
uninstalling packages with files still in use, HaikuPorter builds, and
more. All still seems to work as expected.

Change-Id: I054187316c66b77ea1951c6d1ea8e5b75715c082
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7930
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-10-08 12:13:19 +00:00
Augustin Cavalier 9f07fe52a4 kernel/vm: Don't commit memory for non-private clones in vm_clone_area.
The source area should already have dealt with commitments (or not.)
Fixes cloning of physical map areas and the like (#19143.)
2024-10-03 12:07:35 -04:00
Augustin Cavalier ce2b9f5ec2 kernel/vm: Fix interaction between set_area_protection and set_memory_protection.
* When the page_protections array is allocated, we should clear the
   protections from the area's flags, since they aren't used for
   anything when the page_protections array is activated.

 * When set_area_protection is called and there is a page_protections
   array in use, it should be freed, and we should reset the protections
   on all pages.

 * Add some tests related to these behaviors.
2024-10-02 16:39:36 -04:00
Augustin Cavalier d3b93408f1 kernel/vm: Add ASSERT_UNREACHABLE() in VMCache::Commit.
This should never be invoked; only derived-class implementations
should be.
2024-10-02 16:09:17 -04:00
Augustin Cavalier b11cc78c16 kernel/vm: Add some more AssertLocked()s in VMCache commitment methods.
And remove a now-redundant one.
2024-10-02 16:08:41 -04:00
Augustin Cavalier a0fd8467d9 kernel/vm: Add assertion for a TODO in SetMinimalCommitment. 2024-10-02 16:08:04 -04:00
Augustin Cavalier 0a4a06eee3 kernel/vm: Change cache commitment at end of Resize().
If we change it at the top, then we shrink the commitment before
we actually have released the relevant pages.
2024-10-02 15:57:42 -04:00
Augustin Cavalier 7f6fe7b354 kernel/cache: Add VMVnodeCache::Commit().
Does nothing, as Vnode (file) caches don't need to commit memory
at present.
2024-10-02 15:41:10 -04:00
Augustin Cavalier f940c524eb ramfs: Add missing lock of VMCache in DataContainer. 2024-10-02 15:40:42 -04:00
Augustin Cavalier c2aac52c17 packagefs: Just set cache->virtual_end rather than using Resize().
Resize() has extra logic to deal with shrinking the cache and
adding commitments, neither of which we need here.
2024-10-02 15:40:32 -04:00
Augustin Cavalier 502591624e kernel/vm: Don't commit memory for null and physical map areas.
The implementation does nothing at present besides change the
committed_size value of the cache, and in future commits will ASSERT.
2024-10-02 15:39:40 -04:00
Augustin Cavalier 4b15d71999 BMessage: Clean up properly when reading the stream fails.
Otherwise we leave things in an inconsistent state and could
wind up crashing later.

Fixes #18088.
2024-10-02 14:23:41 -04:00
Augustin Cavalier 69899fa72e kernel/vm: Truncate swap files when disabling or starting with swap disabled.
Fixes #4843.
2024-10-02 13:28:16 -04:00
Augustin Cavalier 12f69070c6 broadcom570x: Actually use MSIs.
We don't need to enable or disable interrupts when using them,
which should fix the TODO that lead to them being disabled always.
2024-10-02 11:09:44 -04:00
Augustin Cavalier 95d8739f18 kernel/x86: Allow overlapping of memory types with physical memory ranges in MTRRs.
Otherwise, all RAM that has a more specific type than the physical range
will hit the assertion below. We also don't want to return the type
set here, so put this check before the effectiveType check.

Change-Id: I703242221771732c69accce66380b5a0efdc77e3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8345
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-10-01 20:54:08 +00:00
Augustin Cavalier 5ea41d287c kernel/vm: Check the page's cache in the "supposed to be free page" panic.
Change-Id: I8db000723f67023c845b79721385a9e1ebc6cef7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8368
Reviewed-by: waddlesplash <[email protected]>
2024-09-25 21:18:51 +00:00
Augustin Cavalier b665a3ab2a kernel/vm: Use DebugGetReverseMappingInfo() in dump_page_long.
Iterating over every single page in a 64-bit address space is far
too expensive. Instead, use DebugGetReverseMappingInfo(), which
iterates over the page translation map's page tables.

(The only thing that implements this at present, however, is
X86VMTranslationMapPAE, so it won't be too useful on 64-bit
just yet. But at least we won't hang for very long periods
of time on 64-bit at least.)
2024-09-25 11:49:53 -04:00
Augustin Cavalier 718918a70a kernel/vm: Dump page information with the "supposed to be free page" panic.
May help with diagnosing #19126.
2024-09-25 11:46:05 -04:00
Augustin Cavalier d0ff5bacff ArchitectureRules: Reinstate the -fno-builtin-fork for 32-bit x86 only. 2024-09-24 14:47:27 -04:00
Augustin Cavalier c289d46cf1 ArchitectureRules: Cleanups to base flags.
* Trim down comment about fno-delete-null-pointer-checks.

 * Remove -fno-builtin-fork -fno-builtin-vfork, they don't seem
   to be needed with GCC 13.

 * Remove legacy-GCC settings from kernel flags, as we don't use
   legacy-GCC there anymore. Also drop fno-builtin as ffreestanding
   implies this.
2024-09-24 13:51:22 -04:00
Augustin Cavalier 79d79dd592 ramfs: Change a usage of strncpy to strlcpy. 2024-09-24 13:42:52 -04:00
Augustin Cavalier 1daf2293d9 ipv6: Change a usage of sprint to snprintf. 2024-09-24 13:42:41 -04:00
Augustin Cavalier 90b9af1ddd kernel/x86: More fixes following integer type changes. 2024-09-24 13:42:02 -04:00
Augustin Cavalier 754742fa7f agp_gart, bfs: Don't build kernel_cpp independently.
The kernel includes it.
2024-09-24 13:15:27 -04:00
Augustin Cavalier 05c972c77f pxe_ia32: Fix another format string. 2024-09-24 13:13:55 -04:00
Augustin Cavalier 0f350f05d1 bootloader: Adjust format strings following change to type definitions. 2024-09-24 12:28:41 -04:00
Augustin Cavalier b28ed9e04a HaikuConfig: Don't define __HAIKU_BEOS_COMPATIBLE_TYPES in kernel mode.
This breaks kernel C++ ABI.

This mostly just changes the definition (not the size) of string types,
but in at least one case (daddr_t) it does change the size (from 32-
to 64-bit.)
2024-09-24 12:10:35 -04:00
Augustin Cavalier b47e8b0cad build: Unify BeOS ABI compatibility ifdefs around __HAIKU_BEOS_COMPATIBLE.
_BEOS_R5_COMPATIBLE_ was defined in ArchitectureRules while
__HAIKU_BEOS_COMPATIBLE is defined in HaikuConfig.h (which is
in the include path for sys/types, SupportDefs, and other
base headers.)
2024-09-24 12:09:33 -04:00
Augustin Cavalier caaee6cc6e kernel/fs: Remove unused list_link field from advisory_lock.
The DoublyLinkedListLink is used instead.
2024-09-21 12:05:24 -04:00
Augustin Cavalier a0658fbc88 kernel/vm: Consolidate logic in vm_cache_acquire_locked_page_cache.
The don't-wait and do-wait logic was very similar except for the
actual acquisition of the lock in the middle, so now they're combined.
This fixes another (minor) regression from 9e89f7c068
in that if a page's cache changed before we acquired its lock and
don't-wait was set, we would wind up waiting anyway.
2024-09-21 12:03:23 -04:00
Augustin Cavalier eb26bd6c47 kernel/vm: Fix copy/paste bug in vm_cache_acquire_locked_page_cache.
This fixes a regression from 9e89f7c068.

Even if SwitchFromReadLock fails, the original read lock has been released,
and so we need to re-acquire the lock before continuing.

Should fix a KDL reported by X512.
2024-09-21 11:47:21 -04:00
Augustin Cavalier ce561013e5 ps2: Code cleanup in standard_command_timeout.
No functional change intended.
2024-09-19 13:41:59 -04:00
Augustin Cavalier f2cb18d3f0 ps2: Lock the controller for the full duration of the command.
This way we can't race with some other command using the results
semaphore or flags fields.

May help with various PS/2 tickets.
2024-09-19 13:41:59 -04:00
Augustin Cavalier 805208b667 ps2: Use a real mutex for the controller lock rather than a semaphore. 2024-09-19 13:41:59 -04:00
Augustin Cavalier ad4f2d20a1 ps2: Code cleanup in probe_keyboard.
* Put disabled code behind #if 0 instead of comments, as per style guide.

 * Clean up comments.

 * Errors should be ERROR not INFO (but both are printed anyway
   at the moment.)

No functional change intended.
2024-09-19 13:41:59 -04:00
Augustin Cavalier 1c4821ae8b BTimeSource: Assert that drift is not < 0 as well as != 0.
May help with diagnosing #19074.
2024-09-19 12:53:08 -04:00
Augustin Cavalier 90dca2bc8e headers: Change most remaining include guards to _DEFAULT_SOURCE.
We automatically enable _DEFAULT_SOURCE if _GNU_SOURCE is defined.
Rather than having even more optional methods undefined unless
_GNU_SOURCE manually is, just change all remaining guarts to
use _DEFAULT_SOURCE instead.

Fixes #19095.

Change-Id: I5c7baf40b7fb37913e24279589fc1ae706448a45
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8330
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2024-09-19 16:43:31 +00:00
Augustin Cavalier 5c1f231967 Rename B_MTR_* constants to "something more meaningful".
The names chosen (e.g. "B_UNCACHED_MEMORY") follow the existing naming
conventions for memory-related constants, of putting the type at the end
of the name: B_KERNEL_BLOCK_ADDRESS, B_FULL_LOCK, B_READ_AREA, etc.

Resolves a very old TODO. No functional change intended.

Change-Id: I31491f6b3abc1e95f915aa302b9f2fb2af14774c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8316
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-09-19 16:43:24 +00:00
Augustin Cavalier e323bc248c bootloader: Add a missed check for "BlockedEntries" in the package settings file.
And remove the logic to append the option with the legacy name,
now that enough time has passed.

See comments on #19081.
2024-09-19 12:24:33 -04:00
Augustin Cavalier 6c26c5b01d kernel/x86: Whitespace and comment cleanup in add_memory_type_range.
No functional change.
2024-09-17 20:09:01 -04:00
Augustin Cavalier 734556cb96 kernel/vm: Don't unset VMArea::id in delete_areas.
It's needed in delete_area for arch_vm_unset_memory_type at least.
Instead just add a parameter indicating the area is already removed
from the areas map.
2024-09-17 20:00:28 -04:00
Augustin Cavalier a706a92d65 hda: Fix build with DEBUG enabled.
We need the kernel debug macros defined so that hmulti_audio doesn't
try to use the userland ones.
2024-09-17 18:50:09 -04:00
Augustin Cavalier 89235ee967 DebugAnalyzer: Fix build after SinglyLinkedList API change. 2024-09-17 17:54:06 -04:00
Augustin Cavalier 99d2d975a4 BCollator: Avoid more crashes when the ICUCollator fails to initialize. 2024-09-17 17:51:53 -04:00
Augustin Cavalier 5a8a2b5066 package_repo: Add -f argument to "list" mode to print filenames.
This way, users of package_repo don't have to reassemble the
canonical filenames themselves.
2024-09-17 10:53:21 -04:00
Augustin Cavalier 8728f4797f libroot: Move malloc implementations to their own subdirectory.
No functional change intended.
2024-09-16 16:12:01 -04:00
Augustin Cavalier f6313044f1 kernel/vm: Add "unimplemented" messages in VMTranslationMap::Debug methods.
This way, when certain KDL commands don't work on architectures that
don't implement these methods, it won't be a mystery as to why.
2024-09-16 16:00:01 -04:00
Augustin Cavalier d29c0e6ee5 libroot: Fix shared unnamed semaphore acquisition with timeouts.
We set flags above the timeout check, so we need to use |= and
not lose the SHARED flag we already set.

Fixes some testcases in the POSIX testsuite, and the shared
semaphore code in Gecko/Firefox.
2024-09-16 15:38:29 -04:00
Augustin Cavalier 2eb83002c5 strace: Add FlagsTypeHandler for the mutex option flags.
So that MUTEX_SHARED etc. are displayed in strace output.
Also fix indentation, and the name of the "toFlags" parameter
in syscall definitions.
2024-09-16 15:36:12 -04:00
Augustin Cavalier e1d0a30ed4 bin: Link launch_roster against libshared. 2024-09-16 14:48:54 -04:00
Augustin Cavalier 532c5e75d3 TextTable: Ignore ANSI escape codes when counting text width.
Otherwise the launch_roster table will be misaligned.
2024-09-16 14:39:31 -04:00
Augustin Cavalier 33ce9b1b5c runtime_loader: Remove -fno-builtin from compiler options.
Except on kernel_cpp.cpp. We don't use it for most of libroot, so
we don't need it for most of runtime_loader either. The two preceding
changes were all that's necessary to fix things with builtins enabled.

Very slight performance improvement (the "run 1000 shells" benchmark
seems to decrease by about 0.4 seconds out of 16.5 or so.)
2024-09-16 13:23:46 -04:00
Augustin Cavalier 6a519848d8 runtime_loader: Add cast in ELF TLS to appease GCC.
Otherwise when builtins are enabled, we get class-memaccess warnings.
2024-09-16 13:19:47 -04:00
Augustin Cavalier 6863cd3038 runtime_loader: Add calloc() to heap implementation.
Taken from the bootloader's version, which this heap is based on.
2024-09-16 13:18:57 -04:00
Augustin Cavalier fbf5967e67 packagefs: Restore accidentally removed rw_lock initializations.
Incorrect rebase from the change that removes these from Node.
2024-09-11 15:23:40 -04:00
Augustin Cavalier 088e0628c2 packagefs: Acquire some more write locks to fix assertion failures. 2024-09-11 15:20:35 -04:00
Augustin Cavalier dfb09e12b1 packagefs: Set and unset node parents in Directory rather than Node::Init.
This way we can ASSERT() that the node doesn't belong to some other
directory.
2024-09-11 15:20:35 -04:00
Augustin Cavalier cb29c48dfa packagefs: Add more write-locked assertions.
Also fix a memory leak on failure in mount().
2024-09-11 15:20:35 -04:00
Augustin Cavalier 57bc041d4b packagefs: Add CountReferences method to InlineReferenceable. 2024-09-11 15:20:35 -04:00
Augustin Cavalier a5dbc9f81c HaikuPorts: Synchronize. 2024-09-10 23:21:22 -04:00
Augustin Cavalier 70b84c8aa2 kernel/locks: Assert that rwlocks have no readers on destruction.
Previously only whether there were active waiters was checked.
2024-09-10 23:02:18 -04:00
Augustin Cavalier 2d07400f07 nvme_disk: Unlock the ReadLocker before notifying the IORequest.
SetStatusAndNotify might call us back for more I/O, and we don't
need (or want) to hold a read-lock for that. It will be acquired
anew if necessary.
2024-09-10 18:13:32 -04:00
Augustin Cavalier 13a5c7f91f kernel/lock: Remove ASSERT_UNLOCKED_RW_LOCK from _rw_lock_read_lock.
It's valid to read-lock the same rwlock twice, of course.

(Only affects KDEBUG_RW_LOCK_DEBUG builds, the assertions do
nothing on any other.)
2024-09-10 18:12:20 -04:00
Augustin Cavalier dd45194d37 kernel/lock: Adjust KDEBUG_RW_LOCK_DEBUG logic in _rw_lock_read_unlock.
We need to always decrement the count by 1 even if we own the lock.
Seems to fix some intermittent hangs with KDEBUG_RW_LOCK_DEBUG.
2024-09-10 17:24:57 -04:00
Augustin Cavalier 1705e9761a kernel/x86: Don't disable the CPUID/MSR TSC frequency read on hypervisor.
It was disabled when adding the hypervisor CPUID leaf reading to
the bootloader, but that's not really necessary. This way, if
a hypervisor does not provide that CPUID leaf but does provide
the value in the standard CPUID or MSR, we will still read it
correctly anyway.
2024-09-10 17:07:10 -04:00
Augustin Cavalier 1e13801271 kernel/locks: Add another assertion to _rw_lock_unset_read_locked.
This method is only used when KDEBUG_RW_LOCK_DEBUG is enabled,
which it isn't by default (even when KDEBUG is.)
2024-09-10 17:05:12 -04:00
Augustin Cavalier 0d931e6321 registrar: Use BMessage::MakeEmpty().
Shouldn't be a functional change, but more idiomatic.
2024-09-10 17:04:21 -04:00
Augustin Cavalier f7c5998eb0 kernelland_emu: Include <debug.h> and set defines before <lock.h>. 2024-09-10 17:04:02 -04:00
Augustin Cavalier f5f11192a1 kernel/slab: Add some more information to slab_object KDL command. 2024-09-10 17:03:43 -04:00
Augustin Cavalier bfc4b17442 kernelland_emu: Fix build following kernel mutex ABI changes. 2024-09-10 16:13:25 -04:00
Augustin Cavalier 65f942aada WebPositive: Add missed conversion from BString to HashString. 2024-09-10 15:48:16 -04:00
Augustin Cavalier ab4fc43458 EntryCache: Cache the entry's hash value.
EntryCacheEntry was padded out to 40 bytes, so this doesn't increase
its size (on 64-bit platforms).

Also increase entriesSize to actually be a power of 2.

This saves us a string comparison when the hashes don't match.
It saved around ~1400 such string comparisons during a boot, and then
rebuilding HaikuDepot, it saved around ~10,000 (both numbers after
factoring in the hashes that compared equal but the directory
values differed, as we skip the string comparisons in that case too.)

Time to compile HaikuDepot seems slightly improved, on average.
2024-09-10 14:07:37 -04:00
Augustin Cavalier 1af0198a7d EntryCache: Unify hash computation logic and use uint32 for it.
Some methods returned uint32 and others returned size_t. We always
set only the lower 32 bits of the value, so just use uint32 everywhere.
2024-09-10 13:43:18 -04:00
Augustin Cavalier b8a2c90991 EntryCache: Use memcpy to copy the strings.
We already use strlen() once, we might as well cache that result
and then use memcpy() instead of strcpy().
2024-09-10 12:40:00 -04:00
Augustin Cavalier f3a9981f9f kernel/vm: Add dangling-reference assertions to AddressSpace{Read,Write}Locker.
Inspired by a change from jpelczar.
2024-09-10 12:35:41 -04:00
Augustin Cavalier b4798ac6a7 kernel: Add assertions to ensure vm_page_reservation is destroyed with a count of 0.
Inspired by some of jpelczar's changes.
2024-09-10 12:13:38 -04:00