summaryrefslogtreecommitdiff
path: root/Kernel/PerformanceEventBuffer.h
AgeCommit message (Collapse)Author
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-05AK+Kernel: Move KResult.h to Kernel/API for userspace accesssin-ack
This commit moves the KResult and KResultOr objects to Kernel/API to signify that they may now be freely used by userspace code at points where a syscall-related error result is to be expected. It also exposes KResult and KResultOr to the global namespace to make it nicer to use for userspace code.
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-07-19Kernel: Rename PerformanceEvent methods to be more ARCH independentBrian Gianforcaro
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-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+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.
2021-04-26Kernel: Increase max frame count to 64Gunnar Beutner
Even just profiling Piano hits the previous limit.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-02Kernel+Profiler: Capture metadata about all profiled processesAndreas Kling
The perfcore file format was previously limited to a single process since the pid/executable/regions data was top-level in the JSON. This patch moves the process-specific data into a top-level array named "processes" and we now add entries for each process that has been sampled during the profile run. This makes it possible to see samples from multiple threads when viewing a perfcore file with Profiler. This is extremely cool! :^)
2021-03-02Kernel: Start work on full system profiling :^)Andreas Kling
The superuser can now call sys$profiling_enable() with PID -1 to enable profiling of all running threads in the system. The perf events are collected in a global PerformanceEventBuffer (currently 32 MiB in size.) The events can be accessed via /proc/profile
2021-03-02Kernel: Better handling of allocation failure in profilingAndreas Kling
If we can't allocate a PerformanceEventBuffer to store the profiling events, we now fail sys$profiling_enable() and sys$perf_event() with ENOMEM instead of carrying on with a broken buffer.
2021-01-17Kernel: Prune uninteresting kernel frames from profiling samplesAndreas Kling
Start capturing the sample stacks at the EIP/EBP of the pre-empted thread instead of capturing EBP in the sampling function itself.
2021-01-11Kernel+Profiler: Make profiling per-process and without core dumpsAndreas Kling
This patch merges the profiling functionality in the kernel with the performance events mechanism. A profiler sample is now just another perf event, rather than a dedicated thing. Since perf events were already per-process, this now makes profiling per-process as well. Processes with perf events would already write out a perfcore.PID file to the current directory on death, but since we may want to profile a process and then let it continue running, recorded perf events can now be accessed at any time via /proc/PID/perf_events. This patch also adds information about process memory regions to the perfcore JSON format. This removes the need to supply a core dump to the Profiler app for symbolication, and so the "profiler coredump" mechanism is removed entirely. There's still a hard limit of 4MB worth of perf events per process, so this is by no means a perfect final design, but it's a nice step forward for both simplicity and stability. Fixes #4848 Fixes #4849
2020-12-31Everywhere: Re-format with clang-format-11Linus Groh
Compared to version 10 this fixes a bunch of formatting issues, mostly around structs/classes with attributes like [[gnu::packed]], and incorrect insertion of spaces in parameter types ("T &"/"T &&"). I also removed a bunch of // clang-format off/on and FIXME comments that are no longer relevant - on the other hand it tried to destroy a couple of neatly formatted comments, so I had to add some as well.
2020-12-19Kernel: Use fallible KBuffer API in PerformanceEventBufferAndreas Kling
2020-12-18Kernel: Move KBufferBuilder to the fallible KBuffer APIAndreas Kling
KBufferBuilder::build() now returns an OwnPtr<KBuffer> and can fail. Clients of the API have been updated to handle that situation.
2020-08-10Kernel: PID/TID typingBen Wiederhake
This compiles, and contains exactly the same bugs as before. The regex 'FIXME: PID/' should reveal all markers that I left behind, including: - Incomplete conversion - Issues or things that look fishy - Actual bugs that will go wrong during runtime
2020-03-08AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)Andreas Kling
Use this instead of uintptr_t throughout the codebase. This makes it possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-02Kernel: Start working on a syscall for logging performance eventsAndreas Kling
This patch introduces sys$perf_event() with two event types: - PERF_EVENT_MALLOC - PERF_EVENT_FREE After the first call to sys$perf_event(), a process will begin keeping these events in a buffer. When the process dies, that buffer will be written out to "perfcore" in the current directory unless that filename is already taken. This is probably not the best way to do this, but it's a start and will make it possible to start doing memory allocation profiling. :^)