Date: Fri, 4 Jan 2008 21:37:26 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 132526 for review Message-ID: <200801042137.m04LbQxF064701@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=132526 Change 132526 by jb@jb_freebsd1 on 2008/01/04 21:36:46 Pass the trapframe pointer to the clock hook function so we get to use the registers. Make the cyclic_clock() function machine-specific in case we need to do it differently on other arches. Save the pc in the cpu structure array. Pass the pc and upc to the profile provider probes so they are available to DTrace scripts as arg0 and arg1 in exactly the same way as they are on Solaris. Affected files ... .. //depot/projects/dtrace/src/sys/amd64/amd64/local_apic.c#13 edit .. //depot/projects/dtrace/src/sys/cddl/amd64/cyclic_machdep.c#8 edit .. //depot/projects/dtrace/src/sys/cddl/dev/profile/profile.c#5 edit .. //depot/projects/dtrace/src/sys/cddl/kern/cyclic.c#8 edit .. //depot/projects/dtrace/src/sys/compat/opensolaris/sys/cpuvar.h#6 edit .. //depot/projects/dtrace/src/sys/sys/dtrace_bsd.h#10 edit Differences ... ==== //depot/projects/dtrace/src/sys/amd64/amd64/local_apic.c#13 (text+ko) ==== @@ -682,10 +682,10 @@ */ int cpu = PCPU_GET(cpuid); if (lapic_cyclic_clock_func[cpu] != NULL) - (*lapic_cyclic_clock_func[cpu])(); + (*lapic_cyclic_clock_func[cpu])(frame); #endif -/* Fire hardclock at hz. */ + /* Fire hardclock at hz. */ la->la_hard_ticks += hz; if (la->la_hard_ticks >= lapic_timer_hz) { la->la_hard_ticks -= lapic_timer_hz; ==== //depot/projects/dtrace/src/sys/cddl/amd64/cyclic_machdep.c#8 (text+ko) ==== @@ -30,7 +30,6 @@ static void disable(cyb_arg_t); static void reprogram(cyb_arg_t, hrtime_t); static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *); -static void cyclic_clock(void); static cyc_backend_t be = { NULL, /* cyb_configure */ @@ -74,6 +73,31 @@ cyclic_uninit(); } +static hrtime_t exp_due[SMP_MAXCPU]; + +/* + * This function is the one registered by the machine dependent + * initialiser as the callback for high speed timer events. + */ +static void +cyclic_clock(struct trapframe *frame) +{ + cpu_t *c = &solaris_cpu[curcpu]; + + if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[curcpu]) { + if (TRAPF_USERMODE(frame)) { + c->cpu_profile_pc = 0; + c->cpu_profile_upc = TRAPF_PC(frame); + } else { + c->cpu_profile_pc = TRAPF_PC(frame); + c->cpu_profile_upc = 0; + } + + /* Fire any timers that are due. */ + cyclic_fire(c); + } +} + static void enable(cyb_arg_t arg) { /* Register the cyclic clock callback function. */ @@ -86,7 +110,6 @@ lapic_cyclic_clock_func[curcpu] = NULL; } -static hrtime_t exp_due[SMP_MAXCPU]; static void reprogram(cyb_arg_t arg, hrtime_t exp) { exp_due[curcpu] = exp; @@ -104,4 +127,3 @@ smp_rendezvous_cpus((cpumask_t) (1 << c->cpuid), NULL, func, NULL, param); } - ==== //depot/projects/dtrace/src/sys/cddl/dev/profile/profile.c#5 (text+ko) ==== @@ -198,29 +198,23 @@ profile_probe_percpu_t *pcpu = arg; profile_probe_t *prof = pcpu->profc_probe; hrtime_t late; + solaris_cpu_t *c = &solaris_cpu[curcpu]; late = dtrace_gethrtime() - pcpu->profc_expected; pcpu->profc_expected += pcpu->profc_interval; -#ifdef DOODAD - dtrace_probe(prof->prof_id, CPU->cpu_profile_pc, - CPU->cpu_profile_upc, late, 0, 0); -#else - dtrace_probe(prof->prof_id, 0, 0, late, 0, 0); -#endif + dtrace_probe(prof->prof_id, c->cpu_profile_pc, + c->cpu_profile_upc, late, 0, 0); } static void profile_tick(void *arg) { profile_probe_t *prof = arg; + solaris_cpu_t *c = &solaris_cpu[curcpu]; -#ifdef DOODAD - dtrace_probe(prof->prof_id, CPU->cpu_profile_pc, - CPU->cpu_profile_upc, 0, 0, 0); -#else - dtrace_probe(prof->prof_id, 0, 0, 0, 0, 0); -#endif + dtrace_probe(prof->prof_id, c->cpu_profile_pc, + c->cpu_profile_upc, 0, 0, 0); } static void ==== //depot/projects/dtrace/src/sys/cddl/kern/cyclic.c#8 (text+ko) ==== @@ -333,6 +333,7 @@ #include <sys/kmem.h> #include <sys/cmn_err.h> #include <sys/dtrace_bsd.h> +#include <machine/cpu.h> static kmem_cache_t *cyclic_id_cache; static cyc_id_t *cyclic_id_head; @@ -1415,20 +1416,6 @@ SYSUNINIT(cyclic_unregister, SI_SUB_CYCLIC, SI_ORDER_SECOND, cyclic_unload, NULL); -/* - * This function is the one registered by the machine dependent - * initialiser as the callback for high speed timer events. - */ -static void -cyclic_clock(void) -{ - cpu_t *c = &solaris_cpu[curcpu]; - - if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[curcpu]) - /* Fire any timers that are due. */ - cyclic_fire(c); -} - /* ARGSUSED */ static int cyclic_modevent(module_t mod __unused, int type, void *data __unused) ==== //depot/projects/dtrace/src/sys/compat/opensolaris/sys/cpuvar.h#6 (text+ko) ==== @@ -39,6 +39,8 @@ struct cyc_cpu *cpu_cyclic; uint32_t cpu_flags; uint_t cpu_intr_actv; + uintptr_t cpu_profile_pc; + uintptr_t cpu_profile_upc; } solaris_cpu_t; /* Some code may choose to redefine this if pcpu_t would be more useful. */ ==== //depot/projects/dtrace/src/sys/sys/dtrace_bsd.h#10 (text+ko) ==== @@ -38,7 +38,7 @@ * Cyclic clock function type definition used to hook the cyclic * subsystem into the appropriate timer interrupt. */ -typedef void (*cyclic_clock_func_t)(void); +typedef void (*cyclic_clock_func_t)(struct trapframe *); /* * These external variables are actually machine-dependent, sohelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801042137.m04LbQxF064701>
