From fe83deb3dbdb69f73ff47346d15e00e265e47361 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Thu, 9 Jul 2020 11:50:59 +0900 Subject: [PATCH] profile: make header user-space includable Change-Id: I4a88d9be7c169f29ef6f6328e8576a3fe3b6e34f --- kernel/include/profile.h | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/kernel/include/profile.h b/kernel/include/profile.h index 78ab15cd..426aad8e 100644 --- a/kernel/include/profile.h +++ b/kernel/include/profile.h @@ -50,6 +50,7 @@ enum profile_event_type { #define __NR_profile PROFILE_EVENT_MAX +#ifdef __KERNEL__ struct thread; struct process; @@ -63,6 +64,75 @@ int profile_accumulate_and_print_job_events(struct process *proc); int profile_alloc_events(struct thread *thread); void profile_dealloc_thread_events(struct thread *thread); void profile_dealloc_proc_events(struct process *proc); + +#else // User space interface +#include +#include + +/* Per-thread */ +static inline void mckernel_profile_thread_on(void) +{ + syscall(__NR_profile, PROF_ON); +} + +static inline void mckernel_profile_thread_off(void) +{ + syscall(__NR_profile, PROF_OFF); +} + +static inline void mckernel_profile_thread_print(void) +{ + syscall(__NR_profile, PROF_PRINT); +} + +static inline void mckernel_profile_thread_print_off(void) +{ + syscall(__NR_profile, PROF_OFF | PROF_PRINT); +} + +/* Per-process */ +static inline void mckernel_profile_process_on(void) +{ + syscall(__NR_profile, PROF_PROC | PROF_ON); +} + +static inline void mckernel_profile_process_off(void) +{ + syscall(__NR_profile, PROF_PROC | PROF_OFF); +} + +static inline void mckernel_profile_process_print(void) +{ + syscall(__NR_profile, PROF_PROC | PROF_PRINT); +} + +static inline void mckernel_profile_process_print_off(void) +{ + syscall(__NR_profile, PROF_PROC | PROF_OFF | PROF_PRINT); +} + +/* Per-job */ +static inline void mckernel_profile_job_on(void) +{ + syscall(__NR_profile, PROF_JOB | PROF_ON); +} + +static inline void mckernel_profile_job_off(void) +{ + syscall(__NR_profile, PROF_JOB | PROF_OFF); +} + +static inline void mckernel_profile_job_print(void) +{ + syscall(__NR_profile, PROF_JOB | PROF_PRINT); +} + +static inline void mckernel_profile_job_print_off(void) +{ + syscall(__NR_profile, PROF_JOB | PROF_OFF | PROF_PRINT); +} + +#endif // __KERNEL__ #endif // PROFILE_ENABLE