From 675fd4eecd75a7156c83bb814ecfdbbcfbf27ea1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 20 Apr 2016 00:32:15 +0200 Subject: Add kernel profiling through sampling * NEWS: Advertise feature. * configfrac.ac (--enable-kernsample): Add option. * kern/pc_sample.h (take_pc_sample): Add usermode and pc parameter. (take_pc_sample_macro): Take usermode and pc parameters, pass as such to take_pc_sample. * kern/pc_sample.c (take_pc_sample): Use pc parameter when usermode is 1. * kern/mach_clock.c (clock_interrupt): Add pc parameter. Pass usermode and pc to take_pc_sample_macro call. * i386/i386/hardclock.c (hardclock): Pass regs->eip to clock_interrupt call on normal interrupts, NULL on interrupt interrupt. * vm/vm_fault.c (vm_fault_cleanup): Set usermode to 1 and pc to NULL in take_pc_sample_macro call. --- kern/pc_sample.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'kern/pc_sample.h') diff --git a/kern/pc_sample.h b/kern/pc_sample.h index 4832cb9f..04ca6671 100644 --- a/kern/pc_sample.h +++ b/kern/pc_sample.h @@ -71,22 +71,24 @@ typedef struct sample_control sample_control_t; extern void take_pc_sample( thread_t thread, sample_control_t *cp, - sampled_pc_flavor_t flavor); + sampled_pc_flavor_t flavor, + boolean_t usermode, + vm_offset_t pc); /* * Macro to do quick flavor check for sampling, * on both threads and tasks. */ -#define take_pc_sample_macro(thread, flavor) \ +#define take_pc_sample_macro(thread, flavor, usermode, pc) \ MACRO_BEGIN \ task_t task; \ \ if ((thread)->pc_sample.sampletypes & (flavor)) \ - take_pc_sample((thread), &(thread)->pc_sample, (flavor)); \ + take_pc_sample((thread), &(thread)->pc_sample, (flavor), usermode, pc); \ \ task = (thread)->task; \ if (task->pc_sample.sampletypes & (flavor)) \ - take_pc_sample((thread), &task->pc_sample, (flavor)); \ + take_pc_sample((thread), &task->pc_sample, (flavor), usermode, pc); \ MACRO_END #endif /* _KERN_PC_SAMPLE_H_ */ -- cgit v1.2.3