diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-15 15:05:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-15 16:28:18 +0200 |
commit | 4ab9d8736b9cb4199caed31e53ccdf30c202bee5 (patch) | |
tree | 64842019f52748bd533ee2062311db536a61936c /Kernel/Syscalls | |
parent | 704bfe54b6c135df615549f49a99e15ba2492a0e (diff) | |
download | serenity-4ab9d8736b9cb4199caed31e53ccdf30c202bee5.zip |
Kernel: Make perf_event() work for global profiles
Previously calls to perf_event() would end up in a process-specific
perfcore file even though global profiling was enabled. This changes
the behavior for perf_event() so that these events are stored into
the global profile instead.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/perf_event.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Kernel/Syscalls/perf_event.cpp b/Kernel/Syscalls/perf_event.cpp index cc0c91bf6c..94e4daf881 100644 --- a/Kernel/Syscalls/perf_event.cpp +++ b/Kernel/Syscalls/perf_event.cpp @@ -11,9 +11,13 @@ namespace Kernel { KResultOr<int> Process::sys$perf_event(int type, FlatPtr arg1, FlatPtr arg2) { - if (!create_perf_events_buffer_if_needed()) - return ENOMEM; - return perf_events()->append(type, arg1, arg2, nullptr); + auto events_buffer = current_perf_events_buffer(); + if (!events_buffer) { + if (!create_perf_events_buffer_if_needed()) + return ENOMEM; + events_buffer = perf_events(); + } + return events_buffer->append(type, arg1, arg2, nullptr); } } |