Commit Graph

6440 Commits

Author SHA1 Message Date
Augustin Cavalier
2c9560581b Debug Kit: Restore support for symbol lookup by remote memory access.
It's been broken since clone_area was changed to block cloning of
areas without B_CLONEABLE_AREA set on them. We here introduce a
B_DEBUG_MESSAGE_CLONE_AREA debug nub message, which clones the areas
of the debugged team for the debugger.

Also fix some bugs in SymbolLookup::_FindLoadedImageAt methods:
they didn't work properly when *next was NULL, so they would
always fail when iterating over the full list.

Note that this technically breaks libdebug.so and the debugger
protocol ABI. However, nothing out-of-tree that I know of uses
the private libdebug.so, and while GDB does use the debugger
protocol, it doesn't actually use any of the messages past
the first block, so it should still work after this.

Fixes #15251.

Change-Id: I71ccbee4afd17dae30d5dacbc7590d1e2175a90e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8821
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-01-13 18:03:52 +00:00
Augustin Cavalier
babcaa3c29 runtime_loader: Resize heap areas instead of creating new ones.
This is more efficient and works most of the time. Additionally,
we can potentially join with a previous free chunk in the allocator,
avoiding extra fragmentation on the heap.

app_server (on x86_64) only has 1 "rld heap" area after this change
with a size of 0x50000 (320KB), whereas previously it had around 7
with a total size of 0x80000 (512KB).
2025-01-07 17:30:29 -05:00
Augustin Cavalier
7137fc03b2 bootloader heap: Actually implement DEBUG_ALLOCATIONS.
The old define was really "check heap integrity", so it's split off.
In the userland test harness, this takes the total time spent in
the allocator from around 1ms to 14ms for all the allocations used
during a boot with "nightly" profile, so it seems acceptable to
enable it under KDEBUG.

Tested with both BIOS and EFI bootloaders, still works.
2025-01-07 17:30:28 -05:00
Augustin Cavalier
9bf3184b3c kernel/util: Merge the bootloader and runtime_loader heap implementations.
They were mostly copies of one another, save for the glue code
and a few other things. Now they're mostly unified, and this allows
the test to be greatly simplified, too, since it can avoid including
any bootloader code at all.

The heap implementation itself should have no behavioral changes
from before. Those will come in future commits.
2025-01-07 17:30:24 -05:00
Augustin Cavalier
6a75e767e6 kernel/team: Convert Team linked-lists into DoublyLinkedLists.
They were hand-rolled singly-linked lists before. This adds 24 bytes
of size to the Team structure, but turns all the removal operations
in parent and process group into O(1) operations instead of O(N) ones.
Realistically, the Thread linked-lists should be converted as well,
but this is trickier due to interdependence on the Team structure.
2025-01-06 23:39:40 -05:00
Augustin Cavalier
2b7da773ed app_server & libbe: Use server_read_only_memory for the colormap.
At present there's only ever one global one, so we don't bother using
an array for multiple screens (and we don't support multiple screens
yet anyway.)

This fixes a very old TODO, and avoids sending a ~32 KB port message
on every application startup.

Note that this breaks the app_server protocol ABI.
2025-01-06 23:39:39 -05:00
Augustin Cavalier
66f51cb3b9 kernel/team: Do not inherit anything from the kernel's IO context.
We already didn't inherit FDs, which meant that the only thing we
did meaningfully inherit was the table size. That meant that basically
no applications actually had a table size of the default 256, but all
were at the kernel's 4096 (except Tracker and anything started by it,
as Tracker resets it to 512), and also that basically all applications
had FD tables allocated with the raw allocator instead of the block
allocator, which isn't very efficient.

Since this reduces the default FD table size, some applications
might encounter problems. However, build systems and other such
tools should already increase this by default as needed, and it's
easy enough to patch in calls to setrlimit() if it turns out
some applications needed a higher default after all.

Also remove a redundant call to vfs_exec_io_context. Calling
vfs_new_io_context with the second argument set to "true"
already skips cloning CLOEXEC FDs.
2025-01-03 12:26:13 -05:00
Augustin Cavalier
d4a1fc648b kernel/vm: Drop VMCacheRef::ref_count.
Nothing touches it at all.
2025-01-02 21:32:44 -05:00
Augustin Cavalier
f44cb411cc Package Kit & packagefs: Allocate scratch buffers for decompression further up.
Zstd wants a ~90 KB scratch buffer to decompress our 64 KB chunks.
Rather than let it allocate that itself every time, pass in a 2*64KB
"scratch" buffer and statically allocate the working memory from it.
Pass it down using iovecs, and pass down the other buffers in the same
way, to reduce parameters.

Further, rework the object_cache used for heap decompression buffers
to contain objects sized as 4x64KB, so we only need to do one allocation
and deallocation for the compression/decompression and scratch buffers.
Set the minimum reserve to 1 so that the low-memory manager doesn't
reclaim this, as we'll need it when reading back data.

Improves packagefs I/O performance (and thus boot speeds at least a bit,
it appears.)

Change-Id: Id51f6f598b33b9d757a283184c533bb97049529f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8717
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-30 19:04:10 +00:00
Augustin Cavalier
7651b97c0a kernel/vm: Consolidate implementations of VMTranslationMap::UnmapArea.
This adds some new parameters to UnmapPage and UnmapPages. The important
one is a "_flags" pointer to UnmapPage, which if specified will be
filled with the page flags instead of PageUnmapped() being called
(and Flush() won't be invoked, either.)

This removes the remaining PAGE_STATE_* changes from VM architecture code.

Change-Id: Iacbc424dd8a75a79986edcd7f04d15a10f773c87
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8728
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-30 18:50:10 +00:00
Augustin Cavalier
fccefbf347 kernel/vm: Use allocate_early instead of passing a get_free_page method to early_map.
Simplifies things significantly.
No functional change intended.

Change-Id: Ia14c2ec72038ad6f8b56a14974dca78e1877063c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8725
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-28 14:47:32 +00:00
Augustin Cavalier
c5874ee428 kernel/vm: Make use of VMTranslationMap::PageUnmapped in UnmapPages.
An extra argument is added to allow the VMAreaMappings objects to
be added to a queue instead of freed directly (and the lock unlocked,
and so on.)

All architectures adjusted.

This means there is now only one place in each TranslationMap that
the page state and other data is directly adjusted (in UnmapArea).

Change-Id: I3ed2d6d969d1b1e235144a1035c90c750779af27
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8716
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: X512 X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-27 22:07:34 +00:00
Augustin Cavalier
c9fe6a1441 kernel/user_debugger: Remove declaration for _user_get_stack_trace.
The method itself was removed in 8f9d4cad45.
2024-12-26 20:34:27 -05:00
Augustin Cavalier
8bb382decf kernel/vm: Drop vm_page_num_available_pages.
Nothing uses it, and it isn't correct anyway: vm_page_num_free_pages()
now includes cached pages, too, while vm_available_memory() includes
not just available memory pages but also swap.
2024-12-26 20:34:27 -05:00
Augustin Cavalier
01e97ff280 KPartition: Drop SetParent().
A comment indicated it "must" only be called in Add/RemoveChild only.
So the field is just modified there now.
2024-12-19 17:21:04 -05:00
Augustin Cavalier
74ae79fed9 kernel/fs: Don't store the mount cookie in the KPartition.
Nothing uses it. If needed, it can be retrieved through the volume
(mount) ID.
2024-12-19 17:17:18 -05:00
Augustin Cavalier
04c8e27efa BDiskSystemAddOn: Remove the Flags field.
Nothing used it. Instead the kernel addons' flags are used instead,
except in the case of PartitionDelegate, which calls SupportedOperations().
2024-12-19 16:34:16 -05:00
Augustin Cavalier
87eae1e3c8 bootloader: Properly enable __PRINTFLIKE for the boot stdio.
No new warnings or errors, it appears.
2024-12-17 19:49:23 -05:00
Augustin Cavalier
f836917f47 kernel/vm: Rework ordering of _RemoveConsumer and drop "unmergeable" flag.
This reverts a8877df135.

Previously, the "unmergeable" flag was necessary for the RAMFS,
because if the last vnode reference was released while there
was still a consumer (as the old ordering of _RemoveConsumer
had), then the release of the cache reference when the vnode
was removed would result in the cache trying to merge with
its now-only consumer and sole referrer.

Now, instead, we remove the consumer before releasing the store
reference, so that there's no chance the cache will be merged
inside this method.

mmap_cut_tests still pass, web browsers using ramfs shared_memory
still seem to work.
2024-12-17 19:12:40 -05:00
X512
8ea4167e8b kernel/vm: use DoublyLinkedList for VMCache areas list
Change-Id: I0c6a231f245fa542f5d90959755de1e6ba39eb8e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8685
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-17 17:53:47 +00:00
Jérôme Duval
04c90835ac POSIX: add pthread_getcpuclockid()
fix #15615

Change-Id: I6b34f97464fac97d0b339fa338cfc5df34536080
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8681
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-17 09:45:13 +00:00
Augustin Cavalier
d4d55c1fbb kernel/vm: Rename _FreePageRange "discarded" argument to "freedPages".
Clarifies things. No functional change.
2024-12-16 22:06:06 -05:00
Augustin Cavalier
e52dd571d9 bootloader: Make releasing the heap the platform loader's responsibility.
Otherwise, platform loaders couldn't make heap allocations inside
platform_start_kernel(), which some loaders (e.g. EFI) do.

Implement calling heap_release() for the BIOS loaders at least.
This gets us back the ~1.5MB of bootloader heap memory there.
2024-12-16 13:36:39 -05:00
Augustin Cavalier
038d9b44d1 kernel/listeners: Use an rw_spinlock for the gWaitObjectListenerLock.
When the system profiler is in use, this spinlock is used very often.
Internally there's another spinlock which isn't (yet) rw, though.
2024-12-13 17:17:43 -05:00
Augustin Cavalier
5a39b9f82f kernel/vm: Remove unused "no_cache_change" member from VMArea. 2024-12-13 17:14:46 -05:00
Augustin Cavalier
d00cb444a6 kernel/vm: Decommit discarded pages of overcommitted caches.
Overcommitted caches should only have commitments equal to the
number of pages they actually contain, so we should decommit
whenever pages are discarded.

This changes the API of VMCache::Discard to return an ssize_t
of the size of pages that were discarded (or a negative error on
failure.) Nothing checked the return value besides things in VMCache
itself, it appears; but it apparently never fails, so that's fine.

Also add asserts to Commit() that the new commitment at least
encompasses all pages the cache actually contains.
2024-12-13 15:08:45 -05:00
Augustin Cavalier
e7af1dd2e0 kernel/vm: Introduce VMCache::CanOvercommit().
Allows the Anonymous caches to report overcommitting status.
2024-12-13 14:25:40 -05:00
Augustin Cavalier
be88b511d7 kernel/vm: Remove an unneeded and misplaced include.
VMArea.h is already included at the top of the file.
2024-12-11 14:13:36 -05:00
Augustin Cavalier
254894210c LinkedLists: Rename MoveFrom method to TakeFrom.
"Move" now sounds like it has 'move' semantics (i.e. replaces this
structure's data with the other structure's data), while MoveFrom()
really had 'move+append' semantics (appends the other list's elements
to this list, and clears the other list.) To make this clearer, it's
here renamed to "TakeFrom".

This should reduce confusion with the other move-related APIs that
are starting to show up in the Haiku tree (e.g. "MoveFrom" in BRegion.)

Change-Id: Ib0a61a9c12fe8812020efd55a2a0818883883e2a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8634
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: X512 X512 <danger_mail@list.ru>
2024-12-11 19:09:25 +00:00
Augustin Cavalier
c4a59a7a5f file_systems/QueryParser: Don't try to read the key size of invalid indexes.
Fixes a rare corner case.
2024-12-10 16:28:28 -05:00
Augustin Cavalier
cd730cbd7c kernel/vm: Drop an actually obsolete comment.
This was introduced in hrev27179 to refer to the member "merge_swap",
which is now gone. The "busy_writing" field isn't used in Merge().
2024-12-05 17:13:26 -05:00
Augustin Cavalier
5cf7633a39 Revert "kernel/vm: Remove an obsolete comment."
This reverts commit 1db0961121.

It turns out the comment is not obsolete; what it refers to isn't
PAE systems but true 32-bit ones. I'm not sure we should use
64-bit cache offsets even there, but that's a decision for another
time.
2024-12-05 17:05:44 -05:00
Augustin Cavalier
896f7fdb75 kernel/disk_device_manager: Cleanup code style, fix some minor TODOs. 2024-12-03 12:31:20 -05:00
Augustin Cavalier
bb1f240594 file_systems: Invert query equation scoring values.
Previously, lower was better, and higher was worse. But really we want
the scores to be based primarily around the index sizes, which can
grow to be very large, so a maximum score is hard to determine.

Instead, start with the index size, and then divide to make it smaller
based on how "useful" the equation terms will be in searching it.

Improves the performance of queries like those in #19080; according
to humdinger's testing, the query with the most expensive term first
went from ~2.0s execution time down to ~0.7s, same as the query with
the least expensive term first.

Change-Id: Id71fa21c95cfe3d8d0019ff356bdf4935446411f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8593
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-26 17:13:29 +00:00
Augustin Cavalier
9708b08060 KPath: Use a default buffer size of B_PATH_NAME_LENGTH without + 1.
B_PATH_NAME_LENGTH == PATH_MAX, and PATH_MAX is inclusive of the final
NULL terminator, so we don't need a + 1 here.

The original KPath default was to not use + 1, but that was changed in
42e3c6f978 due to all the consumers that did.

But all those consumers are wrong, it appears; they should just be
using the default length instead. So now we do that.
2024-11-22 16:56:15 -05:00
Augustin Cavalier
cc9ea55c59 file_systems/QueryParser: Coerce types up front, and handle B_TIME_TYPE better.
* If we coerce types inside the switch(), then the "type already converted"
   check at the beginning will fail every time, causing us to reconvert,
   which is surely bad for performance.

 * B_TIME_TYPE should be INT32 or INT64 depending on what its size is.

May help with #19080.
2024-11-21 23:19:09 -05:00
Augustin Cavalier
f72d1684e5 kernel/debug: Initialize the frame buffer console much earlier, if possible.
Previously it was not initialized until "post-VM", but there are
a number of ways VM initialization can go wrong that it would
be nice to know about without needing a serial port.

On arches which map the whole physical memory into the kernel
address space (x86_64, at least), we can get the bluescreen facility
initialized using KERNEL_PMAP_BASE. On other architectures, we
just fail to init then, and do the usual setup later on.

A slight bit of extra code cleanup in blue_screen_init_early:
we now just call module->info.std_ops() rather than a
frame-buffer-console specific method.
2024-11-19 21:35:31 -05:00
Augustin Cavalier
a9b5f684f1 kernel/fs: Make io_context rw_lock'ed.
Applications that don't call open() or like functions too often,
and call many FD-related methods across multiple threads at once
(like "git status") now don't wait on the context lock as much.

("git status" performance isn't much improved because threads just
hit the "unused vnodes" lock instead.)
2024-11-18 13:25:43 -05:00
Jim906
9bb1816c14 block_cache: enable prefetching
* Allocate blocks and add them to the hash table so they are
  available for a future block_cache_get call.
* Make use of prefetching in FAT driver.
* A client filesystem may request to prefetch a block run that
  contains some blocks that are already cached.  The request will
  be truncated at the first such block in the run.
* Fixes #19186.

Change-Id: I8d2e3cff15e5b46569438e0dc085e2b391aa57a5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8525
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-16 18:26:21 +00:00
Augustin Cavalier
de8d5cfb5f bootloader & kernel: Unify computation of splash logo and icons placement.
Removes some more code duplication.

Change-Id: I9423be740015bef996b77bf2c30652fdadbd8a50
2024-11-12 23:51:52 -05:00
Augustin Cavalier
029e447bde bootloader & kernel: Unify bitmap blitting routines.
They were more-or-less duplicated between the two.
2024-11-12 23:44:31 -05:00
X512
2b0aa4245b BShape: use BShape::Private class to access private methods.
Avoid declaring random friend classes in public header. Allow to access
private methods from arbitrary source if needed.

Change-Id: Iac2cf0ca59e483aa0657e3fe1fc47080c661cf8b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8534
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-11 16:56:19 +00:00
Augustin Cavalier
36708e6ab8 network: Let modules process all ancillary data at once, and adjust UNIX.
This way, modules can decide to do different things based on having
all the ancillary data available. In particular, the UNIX module will
now post only one message header for all the FDs, even if they came
from multiple sets of ancillary data.

This should fix "Message needs unreceived descriptors" from the Chromium
IPC code (which is used by Firefox).
2024-11-05 15:23:24 -05:00
Augustin Cavalier
e9c9b2e448 kernel/condition_variable: Make the debug type fetcher a static function.
No behavioral change intended.
2024-11-05 13:46:53 -05:00
Jérôme Duval
6beff0d163 kernel/libnetwork: add accept4() from POSIX.1/2024
* add SOCK_NONBLOCK and SOCK_CLOEXEC
* also extends the type parameter on socketpair() and socket()

Change-Id: I73570d5bfb57c2da00c1086149c9f07547ba61ce
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8515
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-04 17:55:40 +00:00
Jérôme Duval
966076b273 kernel/libroot: add dup3() from POSIX.1-2024
this adds a parameter to the dup2 syscall. Adjust strace.

Change-Id: Icc2d0e054365865d38e5d596843a47c95100ca59
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8514
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-04 17:55:40 +00:00
Jérôme Duval
11cd4af6e1 kernel/libroot: add pipe2() from POSIX.1-2024
this adds a parameter to the create_pipe syscall. Adjust strace.

Change-Id: I83e9f039eb28c862458654b66c03e2e21a258822
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8513
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-04 17:55:40 +00:00
John Scipione
406f30c616 Tracker: Commands.h (and tracker_private.h) updates
* Add kDeleteSelection command alias in Commands.h, keep kDelete.
* Add kMoveSelectionToTrash and use it in place of kMoveToTrash.
  - kMoveToTrash in kept in tracker_private.h for use outside.
* Create a new constant kRestoreSelectionFromTrash for Tracker.
  - Move kRestoreFromTrash to tracker_private.h

Change-Id: I3cdefe97e8359fb53bacfc3319b046b051c6f7db
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8225
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-10-17 16:21:51 +00:00
Augustin Cavalier
8fbb862695 fs_shell: Adjust following block_cache API change. 2024-10-17 12:15:11 -04:00
Augustin Cavalier
086f997e50 kernel/vm: Move most kernel debugger routines to a new vm_debug.cpp.
Reduces the size of vm.cpp by over 800 lines.
No behavioral change intended.
2024-10-16 14:43:20 -04:00