aboutsummaryrefslogtreecommitdiff
path: root/kern/mach_clock.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-20 00:32:15 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-04-20 00:32:15 +0200
commit675fd4eecd75a7156c83bb814ecfdbbcfbf27ea1 (patch)
treeca1ef6507b938fe491bdf51a2fe6137de52d0f4c /kern/mach_clock.c
parentc908225cb5def2c6df3cf889ca458db8b633d395 (diff)
downloadgnumach-675fd4eecd75a7156c83bb814ecfdbbcfbf27ea1.tar.gz
gnumach-675fd4eecd75a7156c83bb814ecfdbbcfbf27ea1.tar.bz2
gnumach-675fd4eecd75a7156c83bb814ecfdbbcfbf27ea1.zip
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.
Diffstat (limited to 'kern/mach_clock.c')
-rw-r--r--kern/mach_clock.c10
1 files changed, 7 insertions, 3 deletions
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 */