From 0d997d48eae24b1bf137e4a3b5914560dbb1e8be Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 11 Aug 2021 20:04:03 +0200 Subject: Kernel+LibC: Add PERF_EVENT_SIGNPOST This event will be used by userspace programs wanting to mark interesting high-level events in the profile. :^) --- Kernel/PerformanceEventBuffer.cpp | 9 +++++++++ Kernel/PerformanceEventBuffer.h | 6 ++++++ Kernel/UnixTypes.h | 1 + Userland/Libraries/LibC/serenity.h | 1 + 4 files changed, 17 insertions(+) diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index f461ad8db9..aabfddc467 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -137,6 +137,10 @@ KResult PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID ti break; case PERF_EVENT_SYSCALL: break; + case PERF_EVENT_SIGNPOST: + event.data.signpost.arg1 = arg1; + event.data.signpost.arg2 = arg2; + break; default: return EINVAL; } @@ -231,6 +235,11 @@ bool PerformanceEventBuffer::to_json_impl(Serializer& object) const case PERF_EVENT_SYSCALL: event_object.add("type", "syscall"); break; + case PERF_EVENT_SIGNPOST: + event_object.add("type"sv, "signpost"sv); + event_object.add("arg1"sv, event.data.signpost.arg1); + event_object.add("arg2"sv, event.data.signpost.arg2); + break; } event_object.add("pid", event.pid); event_object.add("tid", event.tid); diff --git a/Kernel/PerformanceEventBuffer.h b/Kernel/PerformanceEventBuffer.h index 4c7c2fd748..217d738b09 100644 --- a/Kernel/PerformanceEventBuffer.h +++ b/Kernel/PerformanceEventBuffer.h @@ -62,6 +62,11 @@ struct [[gnu::packed]] KFreePerformanceEvent { FlatPtr ptr; }; +struct [[gnu::packed]] SignpostPerformanceEvent { + FlatPtr arg1; + FlatPtr arg2; +}; + struct [[gnu::packed]] PerformanceEvent { u16 type { 0 }; u8 stack_size { 0 }; @@ -80,6 +85,7 @@ struct [[gnu::packed]] PerformanceEvent { ContextSwitchPerformanceEvent context_switch; KMallocPerformanceEvent kmalloc; KFreePerformanceEvent kfree; + SignpostPerformanceEvent signpost; } data; static constexpr size_t max_stack_frame_count = 64; FlatPtr stack[max_stack_frame_count]; diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h index 9ebc56bca8..fe62781483 100644 --- a/Kernel/UnixTypes.h +++ b/Kernel/UnixTypes.h @@ -63,6 +63,7 @@ enum { PERF_EVENT_KFREE = 4096, PERF_EVENT_PAGE_FAULT = 8192, PERF_EVENT_SYSCALL = 16384, + PERF_EVENT_SIGNPOST = 32768, }; #define WNOHANG 1 diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index a2533479d6..6c7e0f3d7b 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -113,6 +113,7 @@ enum { PERF_EVENT_KFREE = 4096, PERF_EVENT_PAGE_FAULT = 8192, PERF_EVENT_SYSCALL = 16384, + PERF_EVENT_SIGNPOST = 32768, }; #define PERF_EVENT_MASK_ALL (~0ull) -- cgit v1.2.3