Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier 8ecc31ca7b Errors.h: Add ESOCKTNOSUPPORT.
It's in POSIX.1-2024, see
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/errno.h.html

Fixes #19347.
2025-01-08 11:35:35 -05:00
Augustin Cavalier 2a6dd3744d kernel/block_cache: Clean up uses of errno.
Improves another case like the one fixed in the last commit, and
avoids referencing it multiple times in a row unnecessarily.
2025-01-08 01:19:21 -05:00
Augustin Cavalier 0d139d259e kernel/block_cache: Make sure we return an error if block reading fails.
In #19343 it appears that read_pos returned "No error" but 0 bytes read.
We need to return an error code in this case, lest whoever called us
think the block was read in correctly after all.
2025-01-08 01:14:44 -05:00
Augustin Cavalier 1c956c9bf4 bootloader packagefs: Drop fModifiedTime.
Nothing uses it at present. This saves 8 bytes per PackageNode on 32-bit
and 16 bytes on 64-bit (mostly just EFI). We allocate a PackageNode
for every file in haiku.hpkg, so this is a significant savings in
the small bootloader heap.
2025-01-07 17:34:44 -05: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 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
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 <[email protected]>
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
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
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 <[email protected]>
Tested-by: Commit checker robot <[email protected]>
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 <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
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 <[email protected]>
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 <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
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 <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
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 <[email protected]>
Reviewed-by: X512 X512 <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
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
Augustin Cavalier 054ecb9759 kernel/vm: Minor cleanups to vm_page code.
* Add some parentheses for clarity.

 * Remove a comment about unreserving pages. In fact this method is
   always called with pages already reserved, and in the path the comment
   was in, we wouldn't want to unreserve anyway, because we've
   successfully allocated.

 * Use a boolean rather than an int for "useCached".

No functional change intended.
2024-12-27 15:36:51 -05:00
Augustin Cavalier 38210e8510 kernel/team: Minor code cleanup in LockTeamAndParent and LockTeamAndProcessGroup.
Make them look a bit more similar to each other.
No functional change intended.
2024-12-26 22:52:51 -05:00
Augustin Cavalier da880bc23d kernel/vm: Correct check for other waiters.
Since in the case where we're being inserted last, otherWaiter == NULL.
2024-12-26 22:32:42 -05:00
Augustin Cavalier 36dfbcad11 kernel/fs: Set a minimum reserve in the path-name cache.
This cache is used for allocating typically ephemeral KPath buffers
for syscall handlers and the like. Letting it be drained to 0 by
the low resource system will just make future VFS syscalls needlessly
slower, so make sure that doesn't happen.
2024-12-26 21:41:27 -05:00
Augustin Cavalier 84ba9f198e packagefs: Use VM_PRIORITY_USER for reserving cache pages.
If it fails, we just fall back to uncached reading, so it's not
that important.
2024-12-26 21:40:10 -05:00
Augustin Cavalier ef386dfe75 kernel/vm: Fix a race in reserve_pages.
See inline comment: it's possible to race with other threads
and wind up with pages if there are a lot of waiters or lock
contention. Just bail out and retry in that case.

The only other potential way to fix this I can think of would be to add a
read-write locking strategy; however this would still be prone to races,
since we acquire and release the lock in a loop in reserve_pages,
and keep whatever pages we managed to reserve from the last iteration.
2024-12-26 20:34:27 -05:00
Augustin Cavalier f33f17f18e kernel/vm: Cleanups to reserve_pages.
* Rename "count" to "missing", makes clearer what it is and does.

 * Move a comment for clarity.

 * Remove an unnecessary Lock().
2024-12-26 20:34:27 -05:00
Augustin Cavalier 0008c79e56 kernel/vm: Implement AcquireUnreferencedStoreRef in VMAnonymousCache.
This is needed for the page writer to be sure it can do its job.
Fixes swap support after hrev58420 broke it.
2024-12-26 20:34:27 -05:00
Augustin Cavalier 593cb3a54d kernel/vm: Let higher-priority waiters steal lower-priority waiters' reservations.
This way, we don't wind up in a situation where there are dozens of
waiters, each needing a handful of pages, but each also having a
handful of pages already reserved, and everything deadlocks.

Significantly improves system responsiveness under high memory usage.
There's still more to be done, however.
2024-12-26 20:34:27 -05: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 2d246d1be0 kernel/vm: Assert in reserve_memory that the amount is a multiple of B_PAGE_SIZE.
It doesn't make sense to reserve memory in other increments.

This would have caught #19295 earlier.

Also use PAGE_ALIGN in VMCache::SetMinimalCommitment.
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 a26220df71 kernel/vm: Use the correct PAGE_STATE for the queue count.
Avoids reserving data in the static area that we won't be using.
Also tweak one bit of coding style.
2024-12-26 20:34:27 -05:00
Augustin Cavalier ec2f7c257b kernel/vm: Unreserve pages in bulk in VMCache::Delete and the MemoryManager.
Avoids extra wakeups when there are page reservation waiters.
Inspired by a patch from Jarek Pelczar, see #19034.
2024-12-26 20:34:26 -05:00
Augustin Cavalier 548202a11e kernel/vm: Actually increment the reservation count in page_free_etc.
The documentation comment claimed this was done but it actually wasn't,
potentially leading to leaks of pages. However, this method appears
to be passed reservation objects only in one rare case in vm_soft_fault
at present. In brief testing, I didn't manage to get that case to
happen.

This method will be used in more cases in future refactors, so it's
important it work correctly.
2024-12-26 20:34:26 -05:00
Augustin Cavalier ce14c3c0f1 build: Remove the profile from the JAM_TARGETS.
The DefineBuildProfile logic implicitly removes it later on
when it replaces JAM_TARGETS entirely. But in some cases it
may not do that, and so if we want it to be removed in all cases,
we have to do that here.

Fixes commands like "jam -q -jN @nightly-anyboot haiku.hpkg"
giving a "don't know how to make @nightly-anyboot" message.
2024-12-23 15:54:49 -05:00
Augustin Cavalier 1aabdb2b8d build: De-indent CommandLineArguments.
If no targets are specified, exit with an error. But this should
never happen, since jam implicitly specifies "all" even if
nothing specific is given.
2024-12-23 15:52:30 -05:00
Augustin Cavalier 8b67e745eb build: Add check that a value was specified in SetConfigVar.
e.g. if one merely has "SetConfigVar DEBUG : HAIKU_TOP src system kernel ;"
this won't actually set a value for DEBUG, and thus it won't use one
of the pre-set debug objects directories, and so all the objects will
wind up in the root of wherever jam is run.
2024-12-23 15:33:03 -05:00
Augustin Cavalier 5ac9e49426 SCSI: Ensure the condition variable is idle before freeing the CCB.
If the completion was just notified by another thread, it's possible
we were awoken and are trying to free this CCB before the other thread
released the condition variable's lock. So, call NotifyAll again
to serialize.

Should fix #17522.
2024-12-21 12:18:22 -05:00
Augustin Cavalier 18443c583a Drivers.h: Add B_SOCKET_IO_BASE declaration.
All the SIO... codes are in the 8900 range.

Change-Id: I7b319877d2430eba2573a0c8fd68cb7fc3b221d8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8693
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-12-21 17:00:00 +00:00
Augustin Cavalier d40db83a6c kernel/vm: Clean up vm_clone_area (and wait_if_address_range_is_wired).
* Put variable declarations near use.

 * Use AreaCacheLocker, which calls vm_area_get_locked_cache for us.

 * De-branchify now that a Locker is being used.

No functional changes intended.
2024-12-20 16:02:05 -05:00
Augustin Cavalier 2f7bf3b339 virtio_net: Don't print a message on SIOCGIFSTATS.
Fixes #19304, reduces syslog spam.

Change-Id: I219709645d516134f0e4948e662bd90ee00ab183
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8692
Reviewed-by: waddlesplash <[email protected]>
2024-12-20 16:22:51 +00: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 46a1eb7da5 btrfs: Drop get_supported_operations.
Nothing ever calls it. The actually important method is the
file_system_module_info's DDM flags.
2024-12-19 16:59:35 -05:00
Augustin Cavalier 2164b5e177 NTFS: Fix new identification logic, and add needed flag to fix initialization. 2024-12-19 16:51:32 -05:00
Augustin Cavalier 59aafb9f3f btrfs: Don't pretend to support initializing or writing, yet.
We always mount read-only for the moment.
2024-12-19 16:39:01 -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 f48a542cf4 file_systems: Split checking of superblock magic and superblock data.
This way, we can avoid printing anything if the superblock magic
doesn't match (i.e. the partition doesn't look like it's of the
filesystem), but print an error if the magic values match but the
rest of the data doesn't.

Reduces syslog spam.
2024-12-19 16:30:29 -05:00
Augustin Cavalier afe86e25ed partitioning_systems/intel: Code cleanup and logging improvements.
* Use more standard TRACE macro setup.

 * Log more errors to the syslog.

 * Log fewer debug messages to the syslog.
2024-12-19 15:19:05 -05:00
Augustin Cavalier f168963c18 Tracker: Clear filtered pose list in ClearPoses().
Fixes #19300.
2024-12-19 14:48:56 -05:00
Augustin Cavalier 4fa1556978 Tracker: Fix build under DEBUG. 2024-12-19 14:48:01 -05:00
Augustin Cavalier 03bec531f9 PowerStatus: Numerous improvements to battery display.
* Remove the "pause" indicator; it adds too much noise at small
   sizes and seems confusing at large ones. Instead, draw the
   battery in a blue color when it's not in use.

 * Reverse the direction of the battery bar. It now has the capacity
   on the right and the empty on the left, the opposite of the way
   regular progress bars are, but more in line with how this is
   displayed on other OSes (and smartphones.)

 * Tweak ratios to make the icon display larger in the deskbar.
   It now displays closer to the size that regular icon views do.

 * Tweak the lightning indicator to be a little larger, also for
   legibility at smaller sizes.

 * Other misc. cleanups.

Change-Id: I229fe120e769e43e17eeb87638b832418f5e7aaf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8690
Reviewed-by: Sen Nordstrom <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2024-12-19 04:20:29 +00:00
Augustin Cavalier ae96a596c1 pkgman: Drop unused ResolvableExpressionComparator. 2024-12-18 21:12:16 -05:00
Augustin CavalierandOscar Lesta aaa81469a5 pkgman: Add "search --not-required".
List only the packages that are not required by any other package.

Most useful then used as "pkgman search --installed-only --non-required",
but works for non-installed packages too.

Based on OscarL's initial version, rewritten by me to use the real
dependency resolution system instead. One tweak from madmax to get
it to actually work properly.

Co-authored-by: Oscar Lesta <[email protected]>
2024-12-18 17:08:23 -05:00
Augustin Cavalier f664cdc7e0 kernel/vm: Allow private mappings beyond the end of files
It appears GCC uses this for precompiled headers.

Update the test expectations to match.

Fixes #19296.
2024-12-18 13:58:12 -05:00
Augustin Cavalier c95edc2ba1 app_server: Get rid of RenderingBuffer::IsGraphicsMemory().
It was introduced in 778706215d
for DrawingEngine's sake, but it actually isn't needed even there
and was removed in the previous commit.
2024-12-18 12:28:26 -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
Augustin Cavalier 7eeb28152e kernel/vm: Commit up-front in the middle-cut case.
This way, if the Resize() is supposed to take care of the commitment,
it will (and will fail early if it can't), while if we are the ones
responsible for adjusting the commitment, map_backing_store won't
commit at all (avoiding committing far more than will be necessary),
and we can just steal the commitment from the first cache for the second.
2024-12-17 18:33:34 -05:00
Augustin Cavalier 3280d3c47d kernel/vm: Rework cutting areas with source caches.
This reverts 3a81e9446d (2022).

That commit fixed #17556 by just checking if the area had an
underlying cache that wasn't a RAM cache. But there are cases
where there will be RAM source caches that we have to take
into account, too, not just vnode caches or the like. The
most common example of that would be all areas of a team
after a fork(); the original pages will be in a read-only
source cache.

This commit fixes the real underlying problem: if the first area
has a source cache, then the new second cache needs to have that
as its source, too; and furthermore must have the correct offsets
in order to access its pages correctly.

The test for #17556 that was added in 9ed77019b6
still works as before, as do all the applications I tested that
use cut_area. Some assertion failures that the cut tests triggered
(related to commitment sizes) are fixed by this, as well.

This also seems to fix the remaining instability on fork() in the
boehm-gc's "gctest".
2024-12-17 18:32:11 -05:00
Augustin Cavalier e5b76ada08 kernel/vm: Don't re-protect pages in cut_area.
The page_protections aren't changed at all, so all pages that exist
should already have the same protections as are specified in the array.
The only thing different is what cache and area they now belong to, but
the VMTranslationMap does not care about that.

So we don't need to loop over the pages and re-protect them in this case.
We already didn't for all cases where no page_protections were involved.

(It seems this logic was introduced in bdcc293fa8
along with general page_protections support in cut_area.)
2024-12-17 18:31:05 -05:00
Augustin Cavalier c59db548ab kernel/vm: More fixes to commitment handling in cut_area.
When the area has no page_protections but isn't writable,
we also want to use a smaller-than-default commitment.
So, adjust compute_area_page_commitment to handle that case,
and then use it in cut_area where appropriate.
2024-12-17 17:53:27 -05:00
Augustin Cavalier e0854909b2 kernel/vm: Fix an area/cache offset mixup in discard_area_range.
cache->virtual_base is the cache's start address, which no pages will
be found before. area->cache_offset on the other hand is the area's
offset into the cache (i.e. offset 0 in the area will be offset
0 + area->cache_offset in the cache.) These addresses may well be
the same (even if they're not 0), and in many situations they are,
but in situations with shared or cut areas, they may not be.

The only thing that uses this method is madvise(MADV_FREE), which
probably not many things besides the guarded_heap use at present.
2024-12-17 17:39:43 -05:00
Augustin Cavalier a8adb675e6 tests/kernel/vm: Add munmap calls and fix comments in map_cut_compare_test.
Makes it easier to debug in KDL, especially.
2024-12-17 17:10:40 -05:00
Augustin Cavalier feac1ed72d kernel/vm: Add assertion in VMCache::AddConsumer that source == NULL. 2024-12-17 17:05:37 -05:00
Augustin Cavalier a6938ffd24 kernel/riscv64: Drop unimplemented ProtectPage/ProtectArea.
These are implemented in the base class instead.
2024-12-17 17:04:54 -05:00
Augustin Cavalier 0bfdddcc75 userlandfs: Sort files in the libuserlandfs_haiku_kernel Jamfile.
Alphabetical order, proper sections, etc.
No functional change intended.
2024-12-17 14:04:21 -05:00
Augustin Cavalier 0cffc2aab9 userlandfs: Add AVLTreeBase to libuserlandfs_haiku_kernel.so.
Not sure why this wasn't needed before, but it seems to be now.
2024-12-17 13:58:06 -05:00
Augustin Cavalier 94eafb3b5b kernel/vm: Commitment sizes must be rounded up to the page size.
As the virtual_base and virtual_size may not be page aligned.

Fixes #19295.
2024-12-17 13:06:46 -05:00
Augustin Cavalier 1ad6193d82 kernel/vm: Default AcquireUnreferencedStoreRef() to B_ERROR.
We shouldn't return B_OK here, because then the page writer will
assume it's acquired a store ref and can write pages from this
cache, when of course it's done nothing of the sort.
2024-12-16 23:29:46 -05:00
Augustin Cavalier f69d8200cd kernel/vm: Add assertion that a VMCache being destroyed really is empty. 2024-12-16 23:08:50 -05:00
Augustin Cavalier 74c037e938 kernel/vm: Fix problems in merging caches of differing sizes.
Previously, we'd wind up adding pages from the source to the consumer
that were potentially or actually outside the consumer's bounds.
Now we check the consumer's size and ignore any pages that we don't
want or need; they'll just be freed along with the source cache.

While at it, drop VMAnonymousCache::_MergePagesSmallerSource; it
was the same as the base class's implementation of Merge preceding
this commit; and add a comment to _MergePagesSmallerConsumer noting
that some of the pages may be busy (indeed, I manage to trigger an
assert related to copy-on-write in here at least once.)

I discovered this problem because the page commitment size ASSERT()s
triggered inside Resize() and Rebase(); but the out-of-range pages
already existed in the cache before those functions were called. So,
I've also added an ASSERT to MovePage() that would have caught this
problem more directly.
2024-12-16 22:52:59 -05: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 47dbff983a iprowifi4965: Add NULL check for data->ni and data->m.
Workaround for #19289.
2024-12-16 16:35:11 -05:00