Commit Graph

66648 Commits

Author SHA1 Message Date
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
Owen Anderson
edb17c548f Revert "arm64: Use DEVICE_GRE memory when mapping MTR_WC."
This reverts commit 0caf23319c.
This change is not safe because changing MAIR may invalidate
early mappings. It's also not clear if it's needed, as e.g.
FreeBSD does not use Device GRE mappings.

Change-Id: I95a904ee928281d44989ce707ed1ac59985a308d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8268
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: Milek7 Milek7 <me@milek7.pl>
2024-09-10 18:46:23 +00:00
Owen Anderson
4bb796cf9d arm64: Fix issues pointed out in post-commit review.
* Use fInitialLevel throughout
* Fix a mix-up of platform-independent and platform-dependent flags.
* Use break-before-make in Protect()

Change-Id: Idfd69727ca5c438fe89df830d5e61780c3fb6a36
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8258
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Milek7 Milek7 <me@milek7.pl>
2024-09-10 18:46:14 +00: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
Jarosław Pelczar
abc06f6bc2 EntryCache::Add: Avoid potential deadlock when waiting for memory
If system RAM is very low, avoid potentially long waiting for entry
cache to be populated. If entry couldn't be cached, nothing serious
is going to happen.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2024-09-10 12:39:24 -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
Augustin Cavalier
5f8fe75449 freebsd_network: Don't include <vm/vm_page.h> in bus_dma.cpp.
The BSD headers prevent using ASSERT definitions in it if we do,
and one will be added in the next commit. Just declare the one
method we need from it instead.
2024-09-10 12:11:57 -04:00
Augustin Cavalier
fcae3b6674 kernel/thread: Unset user_data only after unblocking the thread.
This amends 352548d0a3.

If the thread was migrated to another CPU after it was blocked with a
timeout and then was unblocked without needing the timeout, this handler
could possibly race with the thread waking up on the other CPU, resulting
in the other thread thinking it doesn't need to cancel the timer when
the timer is still in the process of running.

May fix #18983.
2024-09-10 11:17:38 -04:00
Augustin Cavalier
d8e26ab4d1 HaikuDepot: Switch to using BString::HashValue. 2024-09-09 23:36:39 -04:00
Augustin Cavalier
cfdc362817 pthread_barrier: Actually unlock the barrier lock.
If we just unblock all threads without actually releasing the lock,
then in the case where all threads have performed the atomic_add
but none have actually started waiting, we'll deadlock forever.

Fixes Mesa deadlocking when using our pthread barriers (at present
it's been using its own.)
2024-09-09 23:08:00 -04:00
Augustin Cavalier
151f01c21d Debugger: Remove unused includes.
Missed in prior change.
2024-09-09 22:35:29 -04:00
Augustin Cavalier
f4e0ce8d61 kernel/lock: Fix ABI compatibility between KDEBUG and non-KDEBUG builds.
This breaks kernel ABI on KDEBUG builds (but not non-KDEBUG builds),
but it does so in order to resolve a long-standing incompatibility
between them: until now, any kernel add-ons built against one which
made use of these lock facilities could not be run on the other;
instead you would get hangs and/or crashes.

After this change, kernel add-ons built with a KDEBUG configuration
should work on a non-KDEBUG kernel, while add-ons built with a
non-KDEBUG configuration will fail to load on a KDEBUG kernel
with unresolved symbols, preventing incorrect and broken operation.
2024-09-09 22:35:05 -04:00
Augustin Cavalier
cf5249749d libbsd: Use timespec_to_bigtime for time conversions in kqueue.
The FreeBSD manpage indicates that it will fail with EINVAL if
an invalid timespec is passed.
2024-09-09 17:33:04 -04:00
Augustin Cavalier
6a2d53e723 Debugger: Use BString::HashValue().
Previously BString::HashValue() had an identical hash to the one
in StringUtils::HashValue(), but now it uses hashdjb2, so this
means Debugger will now use that also.

Tested basic Debugger functionality, seems to still work.

Change-Id: Ia341daa56249967a494df46e6e0a69a74c8b5fe2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8266
Reviewed-by: Rene Gollent <rene@gollent.com>
2024-09-09 18:13:29 +00:00
Niklas Poslovski
f589347ebc Tracker: Fix text color in FilePermissionsView
Change-Id: I7bb4ff2529d664ae759b931f51fb26125ce84a83
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8296
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-09-09 17:46:13 +00:00
Augustin Cavalier
c07586a343 kernel/low_resource_manager: Add wait entry before releasing the semaphore.
Otherwise the low_resource thread's run may complete before we
even start waiting, which makes things much slower as we then
have to wait all the way to the timeout.
2024-09-09 13:44:18 -04:00
Augustin Cavalier
54113084a4 kernel/locks: Add another assertion to _mutex_unlock.
We should only get an error return code in this method when the mutex
was destroyed, in which case waiter.thread should be NULL.

Also do some minor code cleanups.

May help with diagnosing #18983.
2024-09-09 13:42:26 -04:00
Augustin Cavalier
67c0b8f2d1 BString, HashString: Replace string hashes with hashdjb2. 2024-09-09 13:39:29 -04:00
Augustin Cavalier
e9254dd79c Package Kit, WebPositive: Standardize string hashes.
Use either HashString or BString::HashValue (both of which currently
use the "modified hashpjw".)
2024-09-09 13:39:28 -04:00
John Scipione
73b4c7a698 HaikuDepot: Prevent crash when hovering over or clicking on conditions
... before the text is loaded by checking that the text document is set.

Remove fMouseDown member and MouseUp() override.
Get mouse button down from the current window message.

Call inherited BView methods.

Fixes #19077

Change-Id: I79edb1860e3bd7864d2362d7f59fb3a583d19053
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8260
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-09-09 16:26:01 +00:00
Jérôme Duval
1754f053a3 pthread: add PTHREAD_MAX_NAMELEN_NP for pthread_setname_np
Change-Id: I52e9e8a672f76048e1ff0c4a6ddeeecb2d134a5a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8259
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2024-09-09 14:41:35 +00:00
Niklas Poslovski
7fe83eb50d Mail: Use mix_color to make quote colors readable in dark mode
Fixes #18968

Change-Id: Ic8a63820ef004fbc0d98a80f4dccde2b90d1fa1a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7951
Reviewed-by: nephele nephele <nep-git@packageloss.eu>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-09-09 08:40:55 +00:00
John Scipione
f657ee8e46 WebPositive: Small corrections to hrev58090
Add missing break statement (and remove curly brackets).
Use FindColor instead of GetColor, no default color on failure.

Change-Id: Ic868a82ec653226a4fbdec57b5fa7d3f58b2bf27
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8244
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: nephele nephele <nep-git@packageloss.eu>
2024-09-09 08:40:01 +00:00
Augustin Cavalier
0d71a44091 mixer: Also delay starting the mixer until the realTime is recent.
If it's more than a second in the past, continue delaying.
May help with #19074 and/or #18981.
2024-09-08 15:22:06 -04:00
Augustin Cavalier
2897b2cc97 Tracker: Rename HashString to not conflict with the HashString class.
Right now, nothing includes both, but when WebPositive is switched to
use <HashString.h> instead of its own HashKeyString, it will.
2024-09-08 15:01:26 -04:00
Augustin Cavalier
1389907570 ramfs: Switch to hash_hash_string.
Remove the now-unused string_hash from String.h.
2024-09-08 15:00:27 -04:00
Augustin Cavalier
006c901891 StringHash: Replace with hashdjb2().
packagefs StringPool on my system had about 380 colliding string hashes
with the old hash_hash_string (out of ~98,000 strings). With this, it has
only 4, and they're all very odd strings (example: "p16c5x.inc" and
"p16c76.inc" collide.)

(This affects more than packagefs, though; other parts of the kernel
also make use of this routine, including the EntryCache.)

Change-Id: I3cf48a28c5c1a1fb5a457cfaf4fff80029ae146c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8243
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-09-07 19:34:21 +00:00
Augustin Cavalier
c0bf008a31 Tracker: Reduce kDirentBufferSize to 2 * B_PAGE_SIZE.
The kernel will never return more than this, so there's no reason
to bother with allocating a larger buffer.
2024-09-07 12:52:15 -04:00
Augustin Cavalier
86fbc36f66 kernel/fd: Reduce kMaxReadDirBufferSize to 2 pages at most.
Standard kernel malloc() only uses the block allocator for allocations
up to size 8192, and anything past that has to do a raw allocation,
which is much slower than going through the object_cache.

libroot's readdir() uses a buffer of size 4096, but BDirectory
invokes the syscall directly and allows using arbitrary buffer sizes.
Tracker's AddPosesTask uses CachedEntryIterator which invokes the
syscall with 10 KB buffers, which thus hits this path.

Reducing the buffer size shouldn't be a problem, as applications should
continue calling GetNextDirents() until it returns 0. In case there
are buggy applications, we can simply change GetNextDirents to
call the syscall multiple times if it needs to. Tracker still seems
to behave OK, at least.
2024-09-07 12:50:53 -04:00
Augustin Cavalier
788da26bbc kernel: Let user_debugger take care of tracking syscall runtime.
If we just use the kernel entry time, then the pre-syscall tracing
routine (with a debugger message send) will be counted in the syscall's
runtime.

Makes the output of timing in strace and strace -c much more accurate,
however it won't include the "syscall overhead" (time spent in the
syscall entry routines, etc.) But we already can't account for time
spent in the userland-to-kernel transition, so that should probably
be measured some other way if knowing it is desired.

In fact, on architectures which used the generic syscall dispatcher
(e.g. RISC-V), this is the behavior that already existed. So this just
makes x86 consistent with them.

Change-Id: I8cef6111e478ab49b0584e15575172eea77a8760
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8240
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-09-07 15:31:15 +00:00
Augustin Cavalier
2358db9297 BCollator: Don't crash in SetStrength() if the ICUCollator failed to initialize. 2024-09-07 11:30:27 -04:00
Augustin Cavalier
2c61e38afb packagefs: Include hash table size in StringPool overhead. 2024-09-07 11:29:54 -04:00
Augustin Cavalier
cdb5f73822 packagefs: Add a Compare() method to StringKey.
Returns an int which is -1, 0, or 1, much like strcmp(). Implemented
as part of the work for using an AVLTree to store nodes, which won't
be merged, but this may be useful in the future anyway.
2024-09-07 11:29:33 -04:00
Niklas Poslovski
5ac53f0034 Keymap: Make keyboard buttons use B_CONTROL_BACKGROUND_COLOR and B_CONTROL_TEXT_COLOR
Change-Id: I0967fb10a5fb80a8729c9cd955203026aac69caa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7943
Reviewed-by: John Scipione <jscipione@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2024-09-07 15:18:49 +00:00
Niklas Poslovski
4286b59d29 WebPositive: Use BTextView instead of BStringView for font preferences
Fixes #18997

Change-Id: Ic8bb1ef37ae18af2f2db045ddfa75dd5c7adab03
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7948
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2024-09-07 09:15:22 +00:00
PulkoMandy
58bfdd0cb5 intel_extreme: DPLL configuration for Tiger Lake
The DPLL selection registers have changed again somewhere between
Skylake and Tiger Lake. Our code was trying to read/write the Skylake
registers on hardware where they don't exist anymore.

Introduce the new Tiger Lake registers and implement enough of it to get
things working on my machine (but probably only on my machine). Also
add a bit of specialization of DisplayPort which I think was not done
correctly on previous hardware either: for DisplayPort, the link rate is
selected from a handful of allowed frequencies, instead of closely
matching the pixel clock.

Things left TODO:
- Write a proper PLL allocation system to ensure each display gets
  assigned its own PLL (unless multiple displays use the same timings).
  For now it is hardcoded to what I want on my machine.
- Fix the DisplayPort PLL computation to use the values from Intel
  datasheets, not the ones used by my machine which are somehow
  different.
- Fix the DisplayPort PLL computation to select one of the several
  available frequencies, allowing resolutions higher than Full HD which
  require higher clocks.
- Fix DisplayPort link training or whatever must happen after the PLL is
  set up, since changing the PLL results in a non-working display and we
  don't get it back.

Unfortunately this still isn't enough to bring up both displays to life
at the same time. I think it is not very far, but the secondary display
(as decided by the BIOS) remains off for now even after successfully
setting it all up.

Early testing on other machines is welcome.

Change-Id: I37209bb14f32c99944bdc8ef6eef75e2550e18ed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7367
Reviewed-by: Alexander von Gluck <alex@terarocket.io>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2024-09-07 09:13:31 +00:00
Augustin Cavalier
6d1f6cad34 Package Kit: Allocate attribute handlers with BumpAllocator.
On my development VM, there were over 300,000 calls to malloc()
from EntryAttributeHandler::HandleAttribute() alone, which had
the most out of any AttributeHandler, but the others were still
significant (over another 10,000 at least.) On systems with more
packages and more attributes, there would be of course more calls
to malloc().

Since the Handlers are allocated and freed in a "stack"-like
configuration, we can use a simple "bump" allocation strategy
with the AttributeHandlerContext to avoid calling malloc() at all.
In my testing, the most memory that was used appeared to be around
2 KB or so (and the smallest was 216 bytes), so a single slab
should suffice for this.

AttributeHandlerContext seems to be created/destroyed around 530 times
during the boot process on my test machine; allocating and freeing the
allocator's slab page that many times should be negligible (allocations
that large still go through the block allocator.)

Performance-wise, the total time we spend with AttributeHandlerContext
objects "alive" goes from around ~172ms to ~156ms. So, not as much an
improvement as one might hope, but that just goes to show that our
kernel malloc() is pretty efficient. And this change will also keep
short-lived objects off the heap during a period when we are allocating
many long-lived objects, anyway.

Change-Id: I810888434aad788511f2af30143335009b34ee78
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8230
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-09-06 19:15:42 +00:00
Augustin Cavalier
3be79a33b0 kernel/util: Introduce BumpAllocator.
A basic bump allocator that can handle arbitrary amounts of allocations,
so long as all are allocated and freed in a "stack"-like manner.

(Actually it could be extended to support non-stack-like operation,
but that would require more logic that isn't needed at the moment.)

Change-Id: I47077146ea282600130778d312f7d86bd8c032e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8238
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Michael Lotz <mmlr@mlotz.ch>
2024-09-06 19:15:42 +00:00
Augustin Cavalier
ace43da6f9 kernel/thread: Account for current run in fill_thread_info's CPU time handling.
Otherwise, if the thread is currently running, its runtime won't
be included in the returned statistics.
2024-09-06 14:22:40 -04:00
Augustin Cavalier
4e392e7f44 AboutSystem Credits: Move a number of people from Current to Past maintainers.
Anyone I've moved, I didn't see any signs of code contributions
or reviews, tickets, or forum posts in the last year and a half
at least. They may still be around and reachable, but I don't think
that suffices to be a "Haiku maintainer".

I've also moved Alexander up in the list of maintainers; the "Past"
list doesn't seem to count "von" for the alphabetical sort.
There was also one mis-sort in the past list which I've fixed.

Change-Id: If6763372be6a23b24bc0f781243e198d1734a849
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8239
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-09-06 15:14:01 +00:00
Augustin Cavalier
65f80c14fc packagefs: Declare more classes as "final". 2024-09-06 00:32:07 -04:00
Augustin Cavalier
41b4817e4c packagefs: Break out the inline Referenceable from PackageNode and use it for Node.
We unfortunately have to define its methods in the .cpp and not fully
inline them, because otherwise GCC chokes in some places thinking
that the class can be NULL (where it can't be) and thus generating
overrun -Werrors.

This reduces the size of Node and all subclasses (like UnpackingLeafNode)
by 8 bytes. (Not 16 as with PackageNode, as it doesn't eliminate a
virtual table pointer.)
2024-09-06 00:10:49 -04:00
Augustin Cavalier
76985513d6 packagefs: Use an inline reference count in PackageNode.
BReferenceable has a vtable, so it's aligned on sizeof(void*) and thus
has 4 bytes of padding on 64-bit systems. We also had 4 bytes of padding,
and so if we just inline an int32 and add Acquire/Release methods,
then we save 16 bytes (again on 64-bit systems) of object size.

Since this isn't so obvious, add an inline comment explaining the
situation.

This makes sizeof(PackageFile) go from 112 to 96 bytes, and so on.
2024-09-05 23:06:24 -04:00
Augustin Cavalier
837d9b4776 packagefs: Store PackageNode modified time in bigtime_t, not timespec.
We don't really need nanosecond resolution here, microseconds will do.
We can thus fit the value into bigtime_t and use the standard converters.

Reduces the size of PackageNode by another 8 bytes on 64-bit,
saving another ~2.5 MB of memory (or so) on my test VM.

Change-Id: I1232aa8aa22fbf84a6a70af0129183f297961f03
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8237
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-09-06 02:36:02 +00:00
Augustin Cavalier
90eb65c956 mbuf: Rename "page size chunks" cache.
To better align KDL "slabs" output.
2024-09-05 22:25:37 -04:00
Augustin Cavalier
5331db0abd packagefs: PackageNode UID/GID are never actually set.
Perhaps in the future they will be, but for now we don't need
to waste 8 bytes per package node in storing them.
2024-09-05 15:22:32 -04:00