summaryrefslogtreecommitdiff
path: root/Kernel/PerformanceEventBuffer.cpp
AgeCommit message (Collapse)Author
2022-05-03Kernel: Move Kernel/Arch/x86/SafeMem.h to Kernel/Arch/SafeMem.hTimon Kruiper
The file does not contain any specific architectural code, thus it can be moved to the Kernel/Arch directory.
2022-05-03Kernel: Fetch the frame pointer using __builtin_frame_address()Timon Kruiper
This compiler builtin abstracts away the specifics of fetching the frame pointer. This will allow the KSyms.cpp to be build for the aarch64 target. While we're here, lets also change the PerformanceEventBuffer.cpp to not rely on x86_64 specifics.
2022-04-03Kernel: Store AddressSpace memory regions in an IntrusiveRedBlackTreeAndreas Kling
This means we never need to allocate when inserting/removing regions from the address space.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-03Kernel: Fixed behavior of repeated calls to register_stringJakub Berkop
Previously register_string would return incorrect values when called multiple times with the same input. This patch makes this function return the same index, identical strings. This change was required, as this functionality is now being used with read syscall profiling, (#12465), which uses 'register_string' to registers file path on every read syscall.
2022-02-27Everywhere: Make JSON serialization fallibleIdan Horowitz
This allows us to eliminate a major source of infallible allocation in the Kernel, as well as lay down the groundwork for OOM fallibility in userland.
2022-02-14Kernel/Profiling: Add profiling to read syscallJakub Berkop
Syscalls to read can now be profiled, allowing us to monitor filesystem usage by different applications.
2022-01-30Kernel: Remove unnecessary includes from Thread.hAndreas Kling
...and deal with the fallout by adding missing includes everywhere.
2022-01-12Kernel: Make PerformanceEventBuffer::add_process fallible with ErrorOrIdan Horowitz
2022-01-12Kernel: Use try_serialize_absolute_path in PerformanceEventBufferIdan Horowitz
This only moves the issue, as PerformanceEventBuffer::add_process can't fail yet, but this will allow us to remove the non-failable Custody::absolute_path API.
2022-01-05Kernel: Use unchecked_append in PerformanceEventBuffer `raw_backtrace()`Brian Gianforcaro
We always validate the size before we append, so there is no reason to use the checked append.
2021-12-30Kernel: Add some implied auto qualifiersHendiadyoin1
2021-12-19Kernel: Mask kernel addresses in perf event streams for non-superuserAndreas Kling
We now turn kernel addresses into 0xdeadc0de, same as /proc/PID/stacks/
2021-12-19Kernel: Don't include kmalloc perf events in JSON for non-superuserAndreas Kling
These events contain sensitive kernel information and should not be available to regular users.
2021-12-19Kernel: Stop perf event stack walk on bogus userspace->kernel traversalAndreas Kling
When walking the stack to generate a perf_event sample, we now check if a userspace stack frame points back into kernel memory. It was possible to use this as an arbitrary kernel memory read. :^)
2021-12-18Kernel: Start perf event stack capture at RBP, not EBP on x86_64Andreas Kling
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-11AK: Make HashTable and HashMap try_* functions return ErrorOr<T>Andreas Kling
This allows us to use TRY() and MUST() with them.
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-10-15Kernel: Add cross platform RegisterState header and Aarch64 versionJames Mintram
A new RegisterState header includes the platform specific RegisterState header based on the platform being compiled. The Aarch64 RegisterState header contains stubs for Debug
2021-10-15Kernel: Split SmapDisabler so header is platform independentJames Mintram
A new header file has been created in the Arch/ folder while the implementation has been moved into a CPP living in the X86 folder.
2021-10-12Kernel: Pass RegisterState by ref to event bufferJames Mintram
2021-10-12Kernel: Accept RegisterState in append_with_ip_and_bpJames Mintram
2021-09-13Kernel: Deduplicate signpost perf event stringsAli Mohammad Pur
2021-09-07Kernel: Make PerformanceEventBuffer::to_json() return a KResultAndreas Kling
There's a ton of things inside to_json() that could go wrong but we don't know about it yet. One step at a time.
2021-09-07Kernel: Make KBuffer::try_create_with_size() return KResultOrAndreas Kling
This allows us to use TRY() in a lot of new places.
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-12Kernel: Make sys$perf_register_string() generate the string ID'sAndreas Kling
Making userspace provide a global string ID was silly, and made the API extremely difficult to use correctly in a global profiling context. Instead, simply make the kernel do the string ID allocation for us. This also allows us to convert the string storage to a Vector in the kernel (and an array in the JSON profile data.)
2021-08-12Kernel+LibC: Add sys$perf_register_string()Andreas Kling
This syscall allows userspace to register a keyed string that appears in a new "strings" JSON object in profile output. This will be used to add custom strings to profile signposts. :^)
2021-08-12Kernel+LibC: Add PERF_EVENT_SIGNPOSTAndreas Kling
This event will be used by userspace programs wanting to mark interesting high-level events in the profile. :^)
2021-08-10Kernel: Add syscall performance event typeJean-Baptiste Boric
This allows tracing the syscalls made by a thread through the kernel's performance event framework, which is similar in principle to strace. Currently, this merely logs a stack backtrace to the current thread's performance event buffer whenever a syscall is made, if profiling is enabled. Future improvements could include tracing the arguments and the return value, for example.
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Rename Process::space() => Process::address_space()Andreas Kling
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-07-19Kernel: Rename PerformanceEvent methods to be more ARCH independentBrian Gianforcaro
2021-06-29Kernel: Remove some unnecessary JSON related includesAndreas Kling
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-05-29Kernel: Make PerformanceEventBuffer creation API OOM safeBrian Gianforcaro
2021-05-19Kernel: Generate page fault events from the kernel profilerBrian Gianforcaro
Hook the kernel page fault handler and capture page fault events when the fault has a current thread attached in TLS. We capture the eip and ebp so we can unwind the stack and locate which pieces of code are generating the most page faults. Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-19Kernel: Add support for profiling kmalloc()/kfree()Gunnar Beutner
2021-05-19Kernel+LibC: Add support for filtering profiling eventsGunnar Beutner
This adds the -t command-line argument for the profile tool. Using this argument you can filter which event types you want in your profile.
2021-05-19Kernel: Track performance events for context switchesGunnar Beutner
2021-05-16AK+Kernel+LibELF: Remove the need for `IteratorDecision::Continue`Nicholas Baron
By constraining two implementations, the compiler will select the best fitting one. All this will require is duplicating the implementation and simplifying for the `void` case. This constraining also informs both the caller and compiler by passing the callback parameter types as part of the constraint (e.g.: `IterationFunction<int>`). Some `for_each` functions in LibELF only take functions which return `void`. This is a minimal correctness check, as it removes one way for a function to incompletely do something. There seems to be a possible idiom where inside a lambda, a `return;` is the same as `continue;` in a for-loop.
2021-05-14Kernel: Correctly set the lost_samples field for the first sampleGunnar Beutner
This ensures that the lost_samples field is set to zero for the first sample. We didn't lose any samples before the first sample so this is the correct value. Without this Profiler gets confused and draws the graph for the process which contains the first CPU sample incorrectly (all zeroes usually).
2021-05-14Kernel+Profiler: Track lost time between profiler timer ticksGunnar Beutner
We can lose profiling timer events for a few reasons, for example disabled interrupts or system slowness. This accounts for lost time between CPU samples by adding a field lost_samples to each profiling event which tracks how many samples were lost immediately preceding the event.
2021-05-07Kernel: Add PerformanceManager static class, move perf event APIs thereBrian Gianforcaro
The current method of emitting performance events requires a bit of boiler plate at every invocation, as well as having to ignore the return code which isn't used outside of the perf event syscall. This change attempts to clean that up by exposing high level API's that can be used around the code base.
2021-04-26Kernel: Avoid calling characters() where not necessaryGunnar Beutner
2021-04-26Kernel: Use the correct union member for unmap eventsGunnar Beutner
2021-04-26Kernel+Profiler: Improve profiling subsystemGunnar Beutner
This turns the perfcore format into more a log than it was before, which lets us properly log process, thread and region creation/destruction. This also makes it unnecessary to dump the process' regions every time it is scheduled like we did before. Incidentally this also fixes 'profile -c' because we previously ended up incorrectly dumping the parent's region map into the profile data. Log-based mmap support enables profiling shared libraries which are loaded at runtime, e.g. via dlopen(). This enables profiling both the parent and child process for programs which use execve(). Previously we'd discard the profiling data for the old process. The Profiler tool has been updated to not treat thread IDs as process IDs anymore. This enables support for processes with more than one thread. Also, there's a new widget to filter which process should be displayed.