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/mach_clock.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'kern/mach_clock.c') diff --git a/kern/mach_clock.c b/kern/mach_clock.c index 1817ce22..d6ebf23e 100644 --- a/kern/mach_clock.c +++ b/kern/mach_clock.c @@ -133,7 +133,8 @@ timer_elt_data_t timer_head; /* ordered list of timeouts */ void clock_interrupt( int usec, /* microseconds per tick */ boolean_t usermode, /* executing user code */ - boolean_t basepri) /* at base priority */ + boolean_t basepri, /* at base priority */ + vm_offset_t pc) /* address of interrupted instruction */ { int my_cpu = cpu_number(); thread_t thread = current_thread(); @@ -184,8 +185,11 @@ void clock_interrupt( * This had better be MP safe. It might be interesting * to keep track of cpu in the sample. */ - if (usermode) { - take_pc_sample_macro(thread, SAMPLED_PC_PERIODIC); +#ifndef MACH_KERNSAMPLE + if (usermode) +#endif + { + take_pc_sample_macro(thread, SAMPLED_PC_PERIODIC, usermode, pc); } #endif /* MACH_PCSAMPLE */ -- cgit v1.2.3