Previously this just turned the rw_lock into the equivalent of a
recursive_lock, which meant that reader vs. writer assertions
were of no use.
Now, we have a per-thread static array which stores the held read
locks, allowing ASSERT_READ_LOCKED_RW_LOCK to work properly,
and allowing multiple readers to be active at a time.
This probably should still remain disabled even on nightly builds,
but at least it's much more useful as a debugging tool than it was
beforehand.
Change-Id: I386b2bc2ada8df42f4ab11a05563ef22af58e77f
GCC 13 warns that the item could be initialized. From looking at the code, it
could very well be that the log message contained garbage. At least clear the
data before sending it out.
Change-Id: Id02bf314d0c02f852748bdac9cef010ebf073994
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6654
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
The module includes the C-style header file, thus all members are added in the
global namespace.
Change-Id: I5e82c8520b0495e3c437c43cfeea9cc454d39482
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6653
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
GCC 13 warns that this member could be unitialized. Now it is initialized
explicitly before it is used anywhere else.
Change-Id: Ia8d5e95cc247921c6ee240a106a80d73c54caee4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6652
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
The C++ standard in rule 3.3.7[basic.scope.class] determines how the compiler
should handle cases where a member shares the name of a type. It is up to the
compiler whether this requires a diagnostic warning. GCC 13 emits a warning
(changes-meaning). This fixes the issuing of this warning.
Change-Id: I9c58c0dd6298055959154f78d47ad9088e8225dc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6651
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
GCC 13 warns that the a pointer is taken from a member that according to the
rules is not yet initialized. Fix the declaration and order of initialization
to prevent us depending on undefined behavior.
Change-Id: Iab4644c33a3a286e083450da0b3575acfe284f29
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6650
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Just in case, adjust the buffer to format an int32 to a string as the maximum
length that it could be.
Change-Id: I00aede3f684211f9c860455063244422be1d0ee9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6649
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
With GCC13 the current code and its use of the `realloc` function triggers a
potential use after free warning. The code is most likely correct, but there
may be a bug in GCC13's use after free checking, or this is one of the cases
where it is not possible to accurately detect if there is really a chance that
it is used after free.
This rewrites the code in such a way that the warning is no longer triggered.
No functional change intended.
Change-Id: I85e145de2128d4b12a9b3016de33d9facaf0d758
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6648
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
In C++20 `requires` is a reserved keyword. GCC13 warns against its use. This
change removes the use of the keyword in our own code, and ignores it in the
external 'libsolv' code.
Change-Id: I3319d20c0a3fdad89630683cdff5ea3b17f04e99
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6647
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
GCC 13 is more strict about what C++ features are available in a freestanding
(= build without standard library) build. The `stdlib.h` and `math.h` headers
are redefined as part of libstdc++. If the object is built as freestanding, it
should be assumed that none of the standard library functions are available.
The solution in Haiku has been to add part of the standard library into the
kernel shared object. The method of exposing them has been to allow the
use of `stdlib.h` and `math.h` in the kernel and in kernel add-ons.
This change allows that approach to continue. What it does, is that it defines
specific headers which will be picked up when a module is built using private
kernel headers. When building for the kernel (or for the boot module), it will
bypass GCC 13's libstdc++ default behaviour of not including the POSIX/platform
header with all the function definitions.
An alternative to be considered for the longer term is to specifically define
the parts of the C/C++ standard library that is available in the kernel in
these headers, or create custom headers when building kernel modules (which is
how Linux approaches it).
Change-Id: Icab4614f642219fa77732b02401570708ee9a963
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6645
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
The query bin command is already added earlier in the file, and does not
actually require to be linked against localestub. Removing the duplicate, as
it caused all the include directives to gcc to be duplicated, which caused
trouble in gcc2 when using #include_next directives.
Similarly, urlwrapper.cpp is a duplicate entry and does not actually require
libbnetapi.so.
The clockconfig tool has moved to the launch daemon in c16361c4.
Change-Id: I266ada433448a96bee8de325133a548f0985da59
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6661
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
GCC 13 warns that the use of auto_ptr on an array can lead to undefined
behavior, because auto_ptr will use `delete` instead of `delete[]`.
Replaced the use with `std::vector` instead. Since the `data()` member was only
introduced in C++11, the solution uses the [] operator instead to get the
address of the beginning of the array.
Change-Id: Ib457580eedb03338a454fb96b27602c3830c1634
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6644
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
GCC's overflow checker gives a warning about the potential that the atomic
functions called in teams.cpp and threads.cpp will write to a null-pointer.
In this case, it is safe to assume that the values will never be null,
therefore these warnings can be safely ignored.
Relates to/fixes #17734
Change-Id: I777ff96f2812ed7d3ba57a46cad89ef6994cb08f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6643
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Chromebook elemi has no touchscreen but coreboot still declares one in ACPI
tables. Fail gracefully rather than hard crash
Change-Id: I3bad098e7c7887e86669143c0ccec5b46b1428d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6659
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Currently internal keyboard is not detected. Turns out
that reset sequence doesn't respond in expected way. Comparing with
Linux implementation, it doesn't check the return value of reset command but
compensates it by checking get_device_id and set_leds. Try reset test if it
doesn't work check ID
Change-Id: I5506f69a7083ab8ea6c936c8016fd59311a16368
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6610
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
ShowImage hides the mouse pointer when in full screen. This change
additionally avoids triggering the screen saver in that case, using
the same method as MediaPlayer, i.e. setting the current mouse
coordinates.
Change-Id: I151be209f02a2b8d3033766f2b7469655a5c8b61
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6639
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
GCC 13 is more strict about what C++ features are available in a freestanding
(= build without standard library) build. The container types are not
available.
In this case the device manager does not use the std::set container.
Change-Id: Iaa2d71b40c9247fac8ccf2a0033c9fc288550dc7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6642
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
* Fills in a detection gap where HaikuPortsCross might reference
packages that no longer exist in haikuports.cross
* A handy pre-bootstrap check
Change-Id: Id397ecda731a7b7d8fc3d407a4791724494611d7
At least a read lock of the sVnodeLock must be held when calling
lookup_vnode, but we held none at all. This rectifies that problem.
This bug appears to have been around for many years, but no-one
noticed since ASSERT_READ_LOCKED_RW_LOCK only works with more
debug options turned on than the kernel is built with. I discovered
this while working on a new version of those additional options.
The functions declared in locks.h were and are exactly identical
to these inline blocks of code. So, rather than duplicate them,
just invoke them directly. The compiler will probably inline them
anyway.
Checks if a `vm_page` is part of a `VMArea` before doing work with
it, as pages in a `VMCache` that an area is a part of might not
belong to that area.
This fixes a bug for copy-on-write areas when an application is
`fork`ing.
Change-Id: Ic5683c67865b41bf3708bb7ea4104502ddf31a19
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6496
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
- Resize the `page_protections` array in `cut_area` and also shift
the bits if necessary.
- Set the correct protection array as well as the real page
protections for the second area produced by `cut_area`.
Change-Id: I62293480487e869420ebe5a3bc729cec2a14c687
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6395
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
It takes one parameter to specify a thread that is blocked on such
a user mutex.
Change-Id: I513ce130137a327cbaf305d2945e6cfe3c09879e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6606
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This requires the use of fault handlers in the atomics.
GLTeapot now runs in the range of 590-610 FPS on my VM. However, it still
isn't using anywhere near 100% CPU usage. Some of that may be waiting for
app_server to respond to draw requests, but a lot of it still isn't.
Change-Id: I7be87d10cb1b00f07b055d9094b77837b49c5055
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6603
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This requires the introduction of the flag B_USER_MUTEX_SHARED, and then
actually using the SHARED flags in pthread structures to determine when
it should be passed through.
This commit still uses wired memory even for per-team contexts.
That will change in the next commit.
GLTeapot FPS seems about the same.
Change-Id: I749a00dcea1531e113a65299b6d6610f57511fcc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6602
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Now the table is locked with a rw_lock, and individual entries have
each their own rw_locks also.
This improves the "contention" benchmark I have here (2 locks, 6 threads,
acquire & release one lock 50,000 times per thread) mentioned in the last
commit down to under 4s consistently, around 3.45s with the system idle
and around 3.9s when moving windows around. Before this commit, it was
around 6.7s in the best case and 7.0s in the worst, and before that,
it couldn't break 3.8s in the best case.
This does make GLTeapot just slightly worse: it is now down to 310-330
(with occasional dips to 300-310) from 320-340. But the following commits
will improve that substantially.
Change-Id: Ie029a2510746f876f4d4c74d7e878fdadf3cf590
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6601
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
* Get rid of the multiple entries/condition-variables system.
Instead, allocate one structure per variable and do not add/remove
it from the hash until all waiters are gone.
* Get rid of "locked". All wait wakeups of B_OK mean "locked". All
nonzero values mean "not locked." This mirrors what the kernel mutex
implementation does (however, that also tracks the owning thread,
for assertion's sake.)
* Remove "lastWaiter" logic (for now.) As we no longer hold a lock
after wakeup, we cannot reliably check and act on it outside the
"wait" function. This means that interrupted or timed-out waits
will cause a potentially unnecessary syscall on next unblock,
but that will be resolved in the next commit.
Due to the single global lock, user mutex acquisition is an extremely
"noisy" process that can take shorter or longer depending on what is
going on elsewhere on the system, so performance is hard to measure.
With one benchmark that acquires mutexes as fast as possible with
lots of contention, most runs came in as being around the same amount
of time both before and after this change (around 4.25s real). Moving
Terminal's window around while running the test caused runtime to go
up to around 6.7s before this change, and about 7.0s after.
GLTeapot seems to go from 350-380 FPS before this change and 320-340
after. It still spends the vast majority of its time waiting for address
space and cache locks, however.
It is expected that the next commits will build on this change to
improve performance beyond even the "before" numbers above.
Change-Id: I6581a6f7cb0ca0513ea639f8499a1c0c8596c026
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6490
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Fixes#2748
Also fixes a comment misstating a function's name and code style.
Change-Id: I609a1f1e100ded647818e70b428cedc48cf29036
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6604
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
* Introduce SWDBM flag similarly to the arm64 port
* Reuse TEX[2] for SWDBM flag which should be availble
to be used by the operating system if TEX remap
is enabled.
* Introduce SetAndClearPageTableEntryFlags for updating
accessed and modified flags atomically
* Startup sequence is handled similarly to accessed flag, i.e.
set Modified flag in initially mapped pages in bootloader and early map.
* Once the kernel initialization has progressed enough,
pages are mapped as read-only and modified flag handling is done
in the page fault handler.
Change-Id: I8f761e2c6325d1b91481abd569d5e8befded0761
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6518
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>