From a441643cb427b8600bfb5ae3313522765a6f6521 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 29 Apr 2018 17:15:03 +0200 Subject: Minor changes --- kern/perfmon.c | 16 ++++++++-------- kern/perfmon.h | 16 ++++++---------- kern/perfmon_i.h | 13 ++++++------- kern/perfmon_types.h | 26 ++++++++++++++++++++++++++ kern/thread.c | 15 ++++++++------- kern/thread_i.h | 5 +---- 6 files changed, 55 insertions(+), 36 deletions(-) create mode 100644 kern/perfmon_types.h (limited to 'kern') diff --git a/kern/perfmon.c b/kern/perfmon.c index e7a1dfd..156ec7a 100644 --- a/kern/perfmon.c +++ b/kern/perfmon.c @@ -15,16 +15,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Permormance Monitoring module. - * Provide an interface to monitor threads and/or cpu performances events. * - * Monitoring is handled through event groups (perfmon group). + * TODO Description. * * Locking order : interrupts -> thread runq -> grouplist -> group * - * TODO Interupt overflow handling. - * TODO Api to differenciate user and kernel events. - * TODO Test on multi-group events and multi-groups threads/cpus. + * TODO API to differenciate user and kernel events. */ #include @@ -129,6 +125,10 @@ struct perfmon_group { unsigned short type; }; +/* + * List of all groups attached to a single monitored object, either a CPU + * or a thread. + */ struct perfmon_grouplist { struct list groups; struct spinlock lock; @@ -480,9 +480,9 @@ perfmon_cpu_pmu_unload(struct perfmon_cpu_pmu *cpu_pmu, unsigned int pmc_index) } void -perfmon_handle_of_intr(struct trap_frame *frame) +perfmon_of_intr(void) { - pmu_driver.handle_of_intr(frame); + pmu_driver.handle_of_intr(); } int diff --git a/kern/perfmon.h b/kern/perfmon.h index b979e65..b9a3882 100644 --- a/kern/perfmon.h +++ b/kern/perfmon.h @@ -18,8 +18,8 @@ * Performance monitoring based on hardware performance counters. */ -#ifndef _KERN_PERFMON_H -#define _KERN_PERFMON_H +#ifndef KERN_PERFMON_H +#define KERN_PERFMON_H #include @@ -64,11 +64,9 @@ struct perfmon_pmu_ops { void (*start)(unsigned int pmc_id, unsigned int raw_event_id); void (*stop)(unsigned int pmc_id); uint64_t (*read)(unsigned int pmc_id); - uint8_t (*get_pmc_width)(void); - void (*handle_of_intr)(struct trap_frame *frame); -#ifdef CONFIG_PERFMON_TEST void (*write)(unsigned int pmc_id, uint64_t value); -#endif /* CONFIG_PERFMON_TEST */ + uint8_t (*get_pmc_width)(void); + void (*handle_of_intr)(void); }; /* @@ -223,9 +221,7 @@ INIT_OP_DECLARE(perfmon_setup); /* * Handle overflow interrupt. */ -void perfmon_handle_of_intr(struct trap_frame *frame); - -int perfmon_on_overflow(struct perfmon_pmu_ops *driver); +void perfmon_of_intr(void); /* * Register an architecture-specific driver. @@ -247,4 +243,4 @@ void perfmon_cpu_pmc_set_prev(unsigned int pmc_id, uint64_t prev); */ void perfmon_cpu_pmc_inc_of(unsigned int pmc_id); -#endif /* _KERN_PERFMON_H */ +#endif /* KERN_PERFMON_H */ diff --git a/kern/perfmon_i.h b/kern/perfmon_i.h index 28cf16b..3072171 100644 --- a/kern/perfmon_i.h +++ b/kern/perfmon_i.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Remy Noel. + * Copyright (c) 2014-2018 Remy Noel. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,17 +16,17 @@ * * * Performance monitoring based on performance counters internal functions. - * */ -#ifndef _KERN_PERFMON_I_H -#define _KERN_PERFMON_I_H + +#ifndef KERN_PERFMON_I_H +#define KERN_PERFMON_I_H #include #ifdef CONFIG_PERFMON_TEST /* - * Set an running event hardware counter value for overflow tests purposes. + * Set a running event hardware counter value for overflow tests purposes. * * Beware, this will affect all events associated to the same hardware counter. */ @@ -39,5 +39,4 @@ int perfmon_get_pmc_width(void); #endif /* CONFIG_PERFMON_TEST */ -#endif /* _KERN_PERFMON_H */ - +#endif /* KERN_PERFMON_I_H */ diff --git a/kern/perfmon_types.h b/kern/perfmon_types.h new file mode 100644 index 0000000..6f9be0b --- /dev/null +++ b/kern/perfmon_types.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2014-2018 Remy Noel. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * + * Isolated type definition used to avoid inclusion circular dependencies. + */ + +#ifndef KERN_PERFMON_TYPES_H +#define KERN_PERFMON_TYPES_H + +struct perfmon_grouplist; + +#endif /* KERN_PERFMON_TYPES_H */ diff --git a/kern/thread.c b/kern/thread.c index a5d63b9..77960ec 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -617,9 +617,10 @@ thread_runq_schedule_load(struct thread *thread) static void thread_runq_schedule_unload(struct thread *thread) { - (void)thread; #ifdef CONFIG_PERFMON perfmon_thread_unload(thread); +#else + (void)thread; #endif } @@ -1868,7 +1869,7 @@ thread_init(struct thread *thread, void *stack, if (error) { goto error_perfmon; } -#endif +#endif /* CONFIG_PERFMON */ error = tcb_build(&thread->tcb, stack, fn, arg); @@ -1884,7 +1885,7 @@ error_tcb: #ifdef CONFIG_PERFMON perfmon_thread_destroy(thread); error_perfmon: -#endif +#endif /* CONFIG_PERFMON */ thread_destroy_tsd(thread); turnstile_destroy(thread->priv_turnstile); error_turnstile: @@ -2341,7 +2342,7 @@ thread_setup(void) #ifdef CONFIG_PERFMON #define THREAD_PERFMON_INIT_OP_DEPS \ - INIT_OP_DEP(perfmon_bootstrap, true), + INIT_OP_DEP(perfmon_bootstrap, true), #else /* CONFIG_PERFMON */ #define THREAD_PERFMON_INIT_OP_DEPS #endif /* CONFIG_PERFMON */ @@ -2734,10 +2735,10 @@ thread_report_periodic_event(void) spinlock_unlock(&runq->lock); } -unsigned int thread_cpu(const struct thread *thread) +unsigned int +thread_cpu(const struct thread *thread) { - assert (thread->runq != NULL); - + assert(thread->runq); return thread->runq->cpu; } diff --git a/kern/thread_i.h b/kern/thread_i.h index 066e6b7..9c24d3a 100644 --- a/kern/thread_i.h +++ b/kern/thread_i.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -74,10 +75,6 @@ struct thread_fs_data { unsigned short work; }; -#ifdef CONFIG_PERFMON -struct perfmon_grouplist; -#endif - /* * Maximum number of thread-specific data keys. */ -- cgit v1.2.3