Commit Graph

67299 Commits

Author SHA1 Message Date
Augustin Cavalier
0f843fe15a tests/boot: Add boot_heap_replay_test.
This uses a recorded array of allocation operations and "replays" them.
The included .h with such an array is mostly for demonstration; the
real captures from bootloader logs are very large (half a MB or more)
and so not included here. A small node.js script that can generate these
from such logs is included.
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
c55f4f2698 tests/boot: Make heap_test build again. 2025-01-07 12:33:15 -05:00
Augustin Cavalier
cb2aab8ca7 tests/boot: Cleanup heap_test a bit.
* Rename binary to boot_heap_test and source to heap_test,
   to better match other SimpleTests.
2025-01-07 12:20:04 -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
cc9746dbc6 kernel/thread: Add a check for the current thread in Thread::Get.
This happens rather often, from thread_get_io_priority() and
rename_thread() in particular.
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
digitalbox98
3aa371a285 Icon-O-Matic: Add remove menu on Transformer
Change-Id: I0add19af4bb646215f2945a748eeaae3d875df17
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8762
Reviewed-by: Zardshard Zardshard <0azrune6@zard.anonaddy.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: humdinger humdinger <humdinger@mailbox.org>
Reviewed-by: nephele nephele <nep-git@packageloss.eu>
2025-01-06 18:48:52 +00:00
Humdinger
9eaffd12b0 Web+ bookmark bar: Minor GUI string changes
* Sentence casing
* Sort "Delete" in context menu to the bottom.
* Added BSeparator before "Delete" item to have this destructive
  action stand out.
* As bookmarks often have spaces, put their path/name in quotes.
* A bookmark path can be long, better start it in a new line.
* If the bookmark was successfully deleted, but removing it from
  the bookmark bar failed, we don't need to add the full path to
  the alert text, just use the name (= Leaf()).
* Fixed wording of error text when removing a bookmark from the bar.

Change-Id: Ie3cf32325bf77ca9fa5b60e3a49f02baae268090
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8771
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-01-06 16:04:32 +00:00
Jim906
46b22ab208 nfs4: Make buildable under userlandfs
* Adjust some nfs4 code depending on _KERNEL_MODE / USER.
* Add several functions needed by this driver to kernelland_emu.
* Fixes #15556.

Change-Id: I36c1727d9cff088aa93870806bfe69b46dbdd4e2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8712
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-01-04 14:30:33 +00:00
Autocomitter
0fcac3a411 Update translations from Pootle 2025-01-04 08:09:34 +00:00
Augustin Cavalier
205d2be9e1 kernel/slab: Add block sizes up to 16384.
The size classes between 4096 and 8192 are very infrequently used
on both 32-bit and 64-bit; a total of 25 objects isn't uncommon
to see across all of them (while 4096 had 68 used objects and 8192
had 49.) We might as well consolidate these and add size classes up to
16384, to take some pressure off the raw allocator.

On x86_64, it seems that we wind up allocating a large number (> 1000) of DMABuffer objects that wind up in the class for 10240, so this
probably saves around 2 MB or so vs. using the raw allocator.
The other new classes have more minor usage (6, 5, and 14 respectively.)

During builds, there are a lot of process arguments (+ environs) that
add up to values between 8K and 16K, so this will benefit that too.

The block size classes seem to not have been changed since their
original introduction in hrev20896 (2007).

Change-Id: Ifff73ed97adf01739fad7f70a1129066925d4b4f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8763
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-01-03 22:09:48 +00:00
Augustin Cavalier
8272d53c70 kernel/fs: Use an object_cache for allocating FIFO ring_buffers.
Every shell execution creates and destroys a FIFO, it seems,
so it's good to avoid the raw allocator (and thus the kernel
VM translation map) here.

After this change, the only remaining use of the raw allocator
during a rebuild of HaikuDepot + the mime_db is the flatArgs
malloc(), and the change to increase the block sizes to 16K
will reduce that to a small number of calls.
2025-01-03 17:08:10 -05:00
Augustin Cavalier
936414d23d packagefs: Make sure the parent directory really exists in lookup().
If the package was uninstalled, then it may not.

Fixes #19327.
2025-01-03 15:46:47 -05:00
Augustin Cavalier
11be6ba960 kernel/cache: Add a TODO in VMVnodeCache about needing memory commitments. 2025-01-03 15:42:32 -05:00
Augustin Cavalier
8908bfaeee freebsd_network: Cleanups to device methods.
* Rename function pointers in struct device for consistency,
   and adjust all consumers. Use a switch() in the loop over methods.

 * De-indent some code where possible.

 * Remove an obsolete comment.
2025-01-03 15:41:52 -05:00
Christof Meerwald
def75fa413 libroot: Don't call pipe2 from pipe
Calling pipe2 from pipe is problematic in cases where a program
implements its own pipe2 emulation, see
https://discuss.haiku-os.org/t/emacs-not-starting/16125/13

Change-Id: I317946fd95b98671d382c09ccd6fff2600f9e75b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8768
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2025-01-03 20:20:14 +00:00
omesh-barhate
855fbbc3a6 WebPositive: Add context menu to bookmarkbar items
Allows to rename and delete bookmarks

Fixes #10963.

Change-Id: I21cbc34291f1f564c92ce2dcb4d76098823987bb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6082
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2025-01-03 19:50:41 +00:00
Augustin Cavalier
b487eec70b freebsd_network: Skip add_child_device before probe().
This isn't the BSD behavior, but it saves a lot of time in allocating
large softcs (many larger than the block allocator can handle) as
well as method lookups.

Only one in-tree driver actually seems to try and use the softc
during probe: broadcom570x. We can just add a small patch for it
to skip that set when sc == NULL, as nothing in the method
dereferences it.

Tested with ipro1000, rtl81xx, realtekwifi (USB), all still work (and
of course all other drivers' probe() are called every boot, so
those at least don't have problems when the devices aren't present.)
2025-01-03 14:10:42 -05:00
Augustin Cavalier
c8cd20aeff freebsd_network: Resolve methods by ID instead of name.
The IDs were introduced for iflib support, but we can make use of them
in here as well.

Also expose the "resolve_method" function for internal use.

Shouldn't break anything; BSD drivers still seem to work.
2025-01-03 14:01:28 -05:00
Augustin Cavalier
12d6ecf0df kernel/fs: Allocate FD tables separately instead of in one malloc().
This way, we significantly increase the FD table sizes that can
be allocated without needing a "raw" allocation: previously
an FD table size of 512 would've been too large (on x86_64),
while now, tables of up to size 1024 will fit (so long as the
largest block allocator size is 8192, anyway.)
2025-01-03 12:40:13 -05:00
Augustin Cavalier
5911165316 kernel/fs: Consolidate allocation of FD tables.
Adjust vfs_resize_fd_table to support allocating tables when
none have been allocated before, and then just use it in
vfs_new_io_context rather than doing the same calculations
and allocations.

No behavioral change intended.
2025-01-03 12:28:25 -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
9479a57c4e kernel/slab: Organize block-sizes array by size increment.
This way the patterns are clearer.
No functional change.
2025-01-02 23:22:38 -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
0bd8ba1b9e kernel/vm: Convert sAvailableMemoryLock into an rw_spinlock.
In most cases, we just need a read spinlock and then atomics
when updating this value, significantly reducing lock contention.
But this also paves the way for the use of these methods in
page-related hot paths, e.g. for reserving memory as well as pages
when mapping page tables.
2025-01-02 16:01:33 -05:00
Augustin Cavalier
c05dec40eb kernel/vm: Allow reserving more memory than system RAM has.
Now that we don't wait the full timeout in most cases, this "optimization"
isn't really necessary; and it was also preventing reserving amounts
of memory that would require both RAM and swap, which is suboptimal
but there's not really much reason to prevent it.
2025-01-02 15:36:52 -05:00
Augustin Cavalier
74012f55ed kernel/vm: Fail reserving memory more rapidly based on a retry count.
Previously, we would run the low resource manager continously in
a loop until reaching the timeout. This used up a lot of CPU
needlessly, because if the manager fails to release the memory
we need in the first few runs, it's unlikely to do so later.

We could add another waiting mechanism here, but ultimately
it seems to make more sense to just fail early before reaching the
timeout at all, in this case.

Improves system responsiveness under high memory pressure.
2025-01-02 15:35:33 -05:00
Augustin Cavalier
f27c94e4d3 kernel/fs: Don't hold the hot-vnodes lock too long in free_unused_vnodes.
vnode_used also acquires it, and acquiring a read-lock recursively
is illegal and can lead to deadlocks. Holding it across a vnode
lock acquisition isn't a good idea either. We only need it to hold it
before acquiring the unused-vnodes lock, and we can actually skip
acquiring that a second time altogether.

Should fix a deadlock observed by PulkoMandy.
2025-01-02 12:28:45 -05:00
Augustin Cavalier
802fa4afae kernel/arch: Add missing handling for _flags == NULL in the PAE UnmapPage.
This was missed in 7651b97c0a.
2025-01-01 17:10:01 -05:00
Humdinger
8aec27565f Rename notification sound names
Having "Notification" at the beginning of the sound names makes
sure their entries in the Sounds preferences are always next to each
other.

Change-Id: Ia47431ecd4c5e8c346f1417a4d29a151c06217cf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8737
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
2024-12-31 07:37:02 +00:00
Augustin Cavalier
e6a4a197e2 PowerStatus: Quit if asked to install in Deskbar when already installed.
We don't want to open a window in this case.
2024-12-30 21:33:31 -05:00
Augustin Cavalier
faf884663e kernel: Use CPUCLOCK_SPECIAL in user_timer_get_clock.
CPUCLOCK_TEAM is 0 so the last comparison was actually tautological.
Add a final branch for unrecognized flags.
2024-12-30 20:39:00 -05:00
Augustin Cavalier
b6b0fb529d kernel/stack: Fix lookup of chains for SOCK_RAW in put_domain_protocols.
If we fail to look up the chain, we won't uninitialize the protocols,
causing a memory leak (or even dangling references.) Add an ASSERT
that would have caught this problem.

Fixes a memory leak when using raw sockets.
2024-12-30 15:39:56 -05:00
Augustin Cavalier
4c29a795ad network/stack: Clean up hashing logic a bit.
No functional change intended.
2024-12-30 15:38:53 -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
Humdinger
783347df2b Sounds prefs: "pre-hear" button in file panel
* Using "SndFilePanel" from Be Sample Code by Todd Thomas with only
  small changes.

* Removed check for audio file in B_REFS_RECEIVED, because the file
  panel uses a BRefsFilter.

* Reset file panel location in case the panel was canceled.

* Use entry.IsDirectory() instead of entry.GetStat() for simplicity.

Change-Id: Ibb4a4cb8e3c4b60c85a9ba0b2e5287416bbc4b44
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8736
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-30 18:01:18 +00:00
Devin Gillman
6a9e72b0d3 BuildSetup: Added HomeBrew Apple Silicon paths.
Addresses issue here: https://discuss.haiku-os.org/t/building-on-macos-cannot-find-zstd-h/14489/4

And the differences are called out on the install page here: https://docs.brew.sh/Installation

Cleanups by waddlesplash: put the new paths in their own 'block'
and adjust comments.

Change-Id: Ie00fbc07abae141d8ac0580dd661a2fc3cf7a216
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8732
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-30 17:06:31 +00:00
Jim906
7020e10ab8 userlandfs: Fix file_cache_read
* Prevent the userlandfs server from calling clone_area on an area
  that might have already been deleted.
* _HandleRequest(FileCacheReadRequest*) waits for a reply from the
  server when bytesRead > 0.  This ensures that the server has time to
  use the area holding the returned data, before that area is deleted
  when the RequestAllocator goes out of scope in the kernel add-on.
  However, if bytesRead is 0, the server will still call clone_area,
  even though by that time the area has probably been deleted.  This
  leads to a B_BAD_VALUE error when the FS tries to use the emulated
  file_cache_read at the end of a file, which differs from the
  normal behavior of file_cache_read.
* _HandleRequest(ReadFromIORequestRequest*) has similar logic in that
  it waits for a server reply, but not if size == 0.  It's possible
  that a similar problem could occur here. This test can be
  dropped if no requests with size 0 are ever sent from the server to
  begin with.
* For other _HandleRequest overrides, the kernel never waits for a
  server reply, and this causes no problems.  This could be because the
  size of data returned fits in the port buffer, so no external area
  needs to be created by RequestAllocator::AllocateAddress.

Change-Id: If070901c25d446e00e67a74a7883808d8a38dae2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8721
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-30 17:00:48 +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
0c2ad1411f kernel/vm: Unreserve memory as well as unreserving pages.
In a basic test, I only saw one page of memory unreserved this way,
though.

Change-Id: I153bea280e26bee0d5b3159b24719f549b7b5178
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8724
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-28 14:47:32 +00:00
Augustin Cavalier
b1a913c3aa kernel/vm: Free pages via vm_page_free only, not vm_page_set_state.
All consumers of this API should be adjusted here.

This partially paves the way for use of committed pages for page tables.

Change-Id: Id6fc2edc86fbd80e929c413e23cf8de1509a8215
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8723
Reviewed-by: X512 X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-28 14:47:32 +00:00
Autocomitter
bd0f4983c8 Update translations from Pootle 2024-12-28 08:08:56 +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
6f786da5f7 kernel/slab: Unreserve pages just before unreserving memory.
This makes the tails of _MapChunk and _UnmapChunk look more similar to
each other.
2024-12-27 16:21:00 -05:00
Augustin Cavalier
597097ae03 SCSI: Do not wait for memory in the critical path.
As swap can be written out this way.
2024-12-27 16:20:28 -05:00
Augustin Cavalier
2bc6f2846e kernel/vm: Increment missing before returning reservations.
Otherwise the next loop won't reserve all the pages we actually need.

Fixes "PANIC: Had reserved page, but there is none!" after yesterday's
changes.
2024-12-27 15:36:51 -05:00
Augustin Cavalier
0e898f694f kernel/vm: Decrement missing after stealing pages from the next waiter.
This isn't that important, as the only thing we do with "missing" in
this case is to report it to the low_resource manager.
2024-12-27 15:36:51 -05:00
Augustin Cavalier
0e63914d02 kernel/vm: Add an assert that we got as many pages as requested.
This is a cheap test to ensure we weren't woken up spuriously.
2024-12-27 15:36:51 -05:00