aboutsummaryrefslogtreecommitdiff
path: root/kern/pc_sample.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/pc_sample.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/pc_sample.c')
-rw-r--r--kern/pc_sample.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kern/pc_sample.c b/kern/pc_sample.c
index fcb9d71b..e9f0b16a 100644
--- a/kern/pc_sample.c
+++ b/kern/pc_sample.c
@@ -46,12 +46,18 @@ typedef sampled_pc_t sampled_pcs[MAX_PC_SAMPLES];
void take_pc_sample(
const thread_t t,
sample_control_t *cp,
- sampled_pc_flavor_t flavor)
+ sampled_pc_flavor_t flavor,
+ boolean_t usermode,
+ vm_offset_t kern_pc)
{
vm_offset_t pc;
struct sampled_pc *sample;
- pc = interrupted_pc(t);
+ if (usermode)
+ pc = interrupted_pc(t);
+ else
+ pc = kern_pc;
+
cp->seqno++;
sample = &((sampled_pc_t *)cp->buffer)[cp->seqno % MAX_PC_SAMPLES];
sample->id = (vm_offset_t)t;