* Immediately free chunks that are from areas below a size threshold
and which cover the whole area, or are in that area's head or tail.
* Avoid unmapping just-freed chunks and any in the last area,
if we can, while releasing memory. This should force smaller
or not-needed chunks out of the caches more rapidly.
* Drop the "single page cache clear" logic, as it isn't needed now;
the "immediately free small areas" logic takes care of the same case
in a more general way than for single pages.
Running a query for all files in Tracker, letting memory usage go
up to 200+MB, and then closing the query results window seemed to
test this logic pretty well. area_for+get_area_info were invoked
without a subsequent unmap ~12,000 times, vs. around ~3,600 that
the unmap path was taken. Other cases (web browsers) have lower
counts than that, at least in any given short window, from the
(admittedly brief) testing I did.
Hopefully will help with the huge amounts of areas seen in #19514.
Unlike glibc's, these don't take the current locale into account.
The POSIX specification says: "In other than the C and POSIX locales,
other implementation-defined subject sequences may be accepted."
Not accepting any other than the default seems to be more consistent
regardless.
This also makes things consistent between wchar_t and char, as we
were using the BSD implementations of strto*l for regular chars
but glibc's for wcsto*l before.
We can't rely on it not changing between calls, especially as
MaxUpdateTextWidth() changes the value and re-gets it, and
that's called at the end of this method always. So we need to
keep our own copy rather than using the one that's owned by
the subclass.
Fixes a use-after-free uncovered by the guarded heap in VolumeSlider,
reported in #19493.
It accesses values through macros, so just write functions that
fetch the appropriate value from Haiku's structures.
Note that the values for multibyte digit characters are hardcoded.
As far as I can tell, we never set or updated these in glibc's
locale structures, so it always just used the default, so this
should not be a behavioral change from before.
We define these as __builtins in math.h, but the compiler might
use out-of-line versions, and we need to export the symbols anyway.
musl implements the __fpclassify routines, so just use them.
Otherwise it needs to use libio internals to implement these,
which we don't want. musl also exports all these methods for
the same reason.
Implementations taken from glibc 2.15, current gnulib (5077f67), and
in a few cases tweaked for better Haiku support.
Should fix#19479.
* Take it from upstream glibc 2.15, much closer to the version we use.
* Drop fpurge from stdio.h, it's nonstandard. Keep it around for
ABI compatibility for now (BeOS didn't have it.) __fpurge is left
in stdio_ext.h.
Same upstream commit as the mktemp file came from. Some modifications
to integrate better with Haiku.
FreeBSD has no tmpnam_r, so a new version implemented here
(inspired by FreeBSD's tmpnam implementation) that is fully
thread-safe.
From upstream dc36d6f9bb1.
Methods not declared for Haiku removed, and the old randomization
code is retained for now (but with getentropy() at least.)
See inline comment: otherwise we could deadlock waiting for busy pages.
At the same time, make page_faults_allowed just an int16 and drop
atomics and extra checks, they aren't needed.
Fixes#19441.
Change-Id: I1b7cc06f66b44c3520fa36497c076ee5a6320706
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9120
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
* Make PositionToolTip update even when not attached to a window.
* Always use the "hover" message to update the tooltip,
never SetPosition.
* Use BControl::Invoke so that hover messages are sent instantly.
* Position the tooltip above the slider always.
Combined with the fixes to the Interface Kit, this provides a much
nicer experience for slider time tooltips.
Change-Id: Ib7f884ca91c253ed7e6639946fd2378166137d80
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9122
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Ideally we would only hide our own tooltip and nobody else's, so
a TODO is added for that case.
This method is called for all mouse events if we get B_OUTSIDE_VIEW
or B_EXITED_VIEW as their "transit", but since tooltips themselves
get all mouse events and thus B_OUTSIDE_VIEW, this had the effect
of hiding all tooltips immediately instead of after the delay.
It was previously ignored if the tooltip was already open.
Note that, combined with the previous commit, this means that
the "where" passed in will basically always be used (except for
"sticky" tooltips.) Applications or classes that use this private
API but pass in wrong or bogus positions will now need to be fixed.
Instead of re-fetching the mouse position. This avoids tooltips "jumping"
when they may have resized by only a few pixels and don't need to be
repositioned.
It's in POSIX-2024. Remove the libgnu implementation and just import
the changes from latest FreeBSD (dc36d6f9bb1753f3) instead.
While at it, put the non-standard sort functions behind
_DEFAULT_SOURCE.
Unfortunately there are some marked "public" that also use it,
so we can't just move the remainder to an internal file and then
drop libio.h from public consumption.
Delete all the unused portions of the public libio.h while at it.
Adjust the two legacy stdc++ headers that still included it;
it seems they didn't themselves depend on any of the definitions it
contained. However, streambuf.h actually did, so put that definition in
libio.h so that it's always present.
(The stdc++ implementation will get the 'real' _G_config.h from
libroot glibc.)
It's set in _G_config.h, but this file doesn't include that,
so in many cases the "unlocked" function was called instead.
(Most of the stdc++ .cc files did have it set, though.)
It's needed by GCC2 stdc++, but we shouldn't be including it
for all consumers of <stdio.h>, which we were. Drop it,
and adjust all the things that were relying on <stdio_pre.h>'s
definition of __PRINTFLIKE to use the _PRINTFLIKE defined
in BeBuild.h instead.
Hopefully should not cause any breakage; the libroot
implementation of __freading depended on this, but
I didn't see anything else which did.
With how we currently use virtual address spaces, the old and
new computations should produce identical results even on LA57,
but this should be more correct if we ever do use more than just
48 bits of the address space.
Change-Id: I61915fceff8e7998032e0a9895010ef9c26b7b94
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9121
Haiku-Format: Haiku-format Bot <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
* Check if the area is a stack, and panic() if so.
* Check names before accessing any area, and don't try
to do anything with areas that we didn't create.
Makes frees pointing to stack data have much more useful
diagnostics than just "generic segfault".
Without this, we will fail to free the last level of page tables.
This bug has apparently been present since LA57 was originally
introduced years ago, however it was likely not a problem before
now because only the BIOS bootloader has support for it, while
systems that support LA57 are more likely to be booted via EFI.
While at it, fix the address mask for non-LA57 in
DebugGetReverseMappingInfo.
Should fix#19460.
The MemoryManager maps and unmaps pages manually, so this isn't
strictly necessary, but it helps with memory accounting in e.g.
ProcessController.
Fixes the kernel_team disappearing from ProcessController's list
(and also having too-low memory amounts) as noticed in #19460.
"int" of course is also an abbrevation for "integer", so having
two abbreviations is sometimes confusing. The BeOS functions
just use "interrupt" (e.g. "install_io_interrupt_handler"); it
seems we inherited the "int" abbreviation from NewOS.
The basic kernel methods and files related to interrupts are
here adjusted to drop the abbreviation and just use "interrupt(s)".
The architecture-specific functions ("arch_int_*") are mostly
moment left alone for now, though of course architecture-specific
usages of the generic kernel methods are adjusted.
Change-Id: Ic113ea1280a3c78e25f8ca3cc55b24ed5f594eae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9119
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This doesn't get all the filesystems that were missing these checks
(e.g. I didn't adjust the more "WIP" filesystems like XFS and BTRFS)
but it does get most of them.
* Restore logic for excluding app_server side of bitmaps
(though this may not work for server-cloned areas, only
server-allocated ones.)
* Leave TODO in place for media buffers.
* Add all kernel-writable areas of the system (kernel) team
to writable memory, but exclude the block_cache.
Fixes display of kernel memory information in ProcessController's
memory usage menu.
Otherwise it won't be reset at all and we will begin with the
previous thread's FPU state, both for userland and kernel threads.
Also clear the FPU state in x86_return_to_userland, just like
in syscall exit.
Change-Id: Ie46d0e64a680c860c7fbff8dc57116625724eadd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9092
Tested-by: Commit checker robot <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
The XSAVE area can be quite large (1-2KB+), so rather than always
putting it on the kernel stack, just use the arch_thread FPU state.
Change-Id: Ie64c3ea3ca52cd8a4425ae1da69792588a69832a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9090
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This reverts most of c7360f4b02.
Unlike the other floating-point registers, these values are callee-saved
(see "System V Application Binary Interface, AMD64 Architecture
Supplement" section 3.2.1.) So we need to preserve their values and not
reset defaults on context switch.
EMMS, as the previous changes used, does not suffice to clear
exceptions. We could use FNCLEX instead, but we need to reset
x87 state on context switch anyway, so use FNINIT. Do not
reinstate FNCLEX in the exception handler since it will
be executed on context switch anyway.
We also need to ensure a clean initial state, so take care of that
in arch_thread_init.
See also:
* remarks in 396b74228e
* as well as 53e2dc0f85Fixes#19454 and #18624. Doesn't regress #18656 and #19063.
Doesn't seem to affect #19450.
Change-Id: I7179f1ec7304e7aed09ff80f6773e53d5dbdf5f9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9081
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
cache_get_pages locks and unlocks the cache to wait for busy pages,
as well as after it's done, which creates a race where some other
thread may start waiting on a page that we have marked busy. But
as we are about to free those pages, that wait will deadlock.
Just loop through the cache's pages directly, skipping any busy ones
and freeing the others directly.
Fixes a deadlock observed with BFS on a ramdisk.
ssize_t is 64-bit on 64-bit architectures, if we truncate to int
then values above 2GB will be seen as negative and errors instead
of the successes they are.
Seems to fix#16861.
Otherwise there is a race that can occur if the waiting thread is
interrupted (or hasn't slept yet) while the writing thread tries to
unblock it.
Instead, don't call SetNotified again if we unblocked with a status
of B_OK. This can only happen when we were notified by another thread
successfully.
Should help with #19458.
Change-Id: Iad46b26374a01539f8765231d259392c231c786a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9085
Reviewed-by: waddlesplash <[email protected]>
FreeBSD also uses NetBSD's versions (with their own modifications,
however.) So it seems to make sense for us to adopt these, too;
they look to be better tuned than ours were (like handling
non-aligned addresses better, which was a TODO before.)
* Rewrite generic memcpy, with optimizations more like the common memcmp
optimizations.
* Rewrite generic memset, with a proper optimized implementation.
* Name the files "generic_" like other files in the arch generics dirs.
* Always use the generic versions in the bootloader, since it's
complied with special flags.
Put the C++ versions in files with their own names, and
rename the assembly thunks to "commpage_string.S", as it
really just invokes the commpage versions.
The kernel x86 arch_string.S is left alone for the moment
as it will be replaced in the near future anyway.
It's branded as a MediaTek device, but the firmware
copyright is Ralink.
From upstream b96864412700a2a5b5e9aaf5d6513ec062cfc96f.
Includes adaptations to make it compile on Haiku.