From e77c22bf4572510f33c3cf12804d87074ddd4f87 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Thu, 20 May 2004 16:12:19 +0000 Subject: [PATCH] Moved i386 asms to an i386 header. The asms are for calibration of high resolution kernel profiling (options GUPROF. "U" in GUPROF stands for microseconds resolution, but the resolution is now smaller than 1 nanosecond on multi-GHz machines and the accuracy is heading towards 1 nanosecond too). Arches that support GUPROF must now provide certain macros for the calibration. GUPROF is now only supported for i386's, so the absence of the new macros for other arches doesn't break anything that wasn't already broken. amd64's have uncommitted support for GUPROF, and sparc64's have support that seems to be complete except here (there was an #error for non-i386 cases; now there are undefined macros). Changed the asms a little: - declare them as __volatile. They must not be moved, and exporting a label across asms is technically incorrect, so try harder to stop gcc moving them. - don't put the non-clobbered register "bx" in the clobber list. The clobber lists are still more conservative than necessary. - drop the non-support for gcc-1. It just gave a better error message, and this is not useful since compiling with gcc-1 would cause thousands of worse error messages. - drop the support for aout. --- sys/i386/include/profile.h | 19 +++++++++++++++++++ sys/kern/subr_prof.c | 22 +++------------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/sys/i386/include/profile.h b/sys/i386/include/profile.h index 01ed0d8aa2ce..1c5ecf20261d 100644 --- a/sys/i386/include/profile.h +++ b/sys/i386/include/profile.h @@ -53,7 +53,26 @@ #define MCOUNT_DECL(s) #define MCOUNT_ENTER(s) #define MCOUNT_EXIT(s) +#if defined(__GNUC__) || defined(__INTEL_COMPILER) +#define MCOUNT_OVERHEAD(label) \ + __asm __volatile("pushl %0; call __mcount; popl %%ecx" \ + : \ + : "i" (profil) \ + : "ax", "dx", "cx", "memory") +#define MEXITCOUNT_OVERHEAD() \ + __asm __volatile("call .mexitcount; 1:" \ + : : \ + : "ax", "dx", "cx", "memory") +#define MEXITCOUNT_OVERHEAD_GETLABEL(labelp) \ + __asm __volatile("movl $1b,%0" : "=rm" (labelp)) +#elif defined(lint) +#define MCOUNT_OVERHEAD(label) +#define MEXITCOUNT_OVERHEAD() +#define MEXITCOUNT_OVERHEAD_GETLABEL() #else +#error +#endif /* !(__GNUC__ || __INTEL_COMPILER) */ +#else /* !GUPROF */ #define MCOUNT_DECL(s) u_long s; #ifdef SMP extern int mcount_lock; diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index a238f013ad12..622dea74f9a6 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -57,8 +57,6 @@ SYSINIT(kmem, SI_SUB_KPROF, SI_ORDER_FIRST, kmstartup, NULL) struct gmonparam _gmonparam = { GMON_PROF_OFF }; #ifdef GUPROF -#include - void nullfunc_loop_profiled() { @@ -221,27 +219,13 @@ kmstartup(dummy) startguprof(p); for (i = 0; i < CALIB_SCALE; i++) -#if defined(__i386__) && (__GNUC__ >= 2 || defined(__INTEL_COMPILER)) - __asm("pushl %0; call __mcount; popl %%ecx" - : - : "i" (profil) - : "ax", "bx", "cx", "dx", "memory"); -#elif defined(lint) -#else -#error -#endif + MCOUNT_OVERHEAD(profil); mcount_overhead = KCOUNT(p, PC_TO_I(p, profil)); startguprof(p); for (i = 0; i < CALIB_SCALE; i++) -#if defined(__i386__) && (__GNUC__ >= 2 || defined(__INTEL_COMPILER)) - __asm("call " __XSTRING(HIDENAME(mexitcount)) "; 1:" - : : : "ax", "bx", "cx", "dx", "memory"); - __asm("movl $1b,%0" : "=rm" (tmp_addr)); -#elif defined(lint) -#else -#error -#endif + MEXITCOUNT_OVERHEAD(); + MEXITCOUNT_OVERHEAD_GETLABEL(tmp_addr); mexitcount_overhead = KCOUNT(p, PC_TO_I(p, tmp_addr)); p->state = GMON_PROF_OFF;