From 397c071c8c8974e6e918bd3f1b34bfac3e3e299d Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Sat, 3 Jan 1970 06:16:21 +0100 Subject: [PATCH] "Fix" kernel profiling for i386 * It is actually quite a hack-ish fix, but better than nothing; it even seems to work with these changes. * Note that the ICU bintr/eintr has been removed because it gave link-time collisions with the bintr/eintr macros in the apic code. If one doesn't use the APIC, it's probably a good idea to restore those bintr/eintr macros. * The spinlock foo is using some old spinlock_deprecated structures which should probably be changed. --- sys/cpu/i386/include/asmacros.h | 2 +- sys/cpu/i386/include/profile.h | 8 ++++++-- sys/kern/subr_prof.c | 2 +- sys/platform/pc32/icu/icu_vector.s | 2 -- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/cpu/i386/include/asmacros.h b/sys/cpu/i386/include/asmacros.h index 44de11d766..287f0197f7 100644 --- a/sys/cpu/i386/include/asmacros.h +++ b/sys/cpu/i386/include/asmacros.h @@ -69,7 +69,7 @@ * to a possibly-modified form that will be invisible to C programs. */ #define CNAME(csym) csym -#define HIDENAME(asmsym) __CONCAT(.,asmsym) +#define HIDENAME(asmsym) .asmsym #define ALIGN_PAGE .p2align PAGE_SHIFT /* page alignment */ #define ALIGN_DATA .p2align 2 /* 4 byte alignment, zero filled */ diff --git a/sys/cpu/i386/include/profile.h b/sys/cpu/i386/include/profile.h index 33099f93f4..ef507ccb20 100644 --- a/sys/cpu/i386/include/profile.h +++ b/sys/cpu/i386/include/profile.h @@ -72,10 +72,14 @@ #else #define MCOUNT_DECL(s) u_long s; #ifdef SMP +struct spinlock_deprecated; +extern struct spinlock_deprecated mcount_spinlock; +void spin_lock_np(struct spinlock_deprecated *sp); +void spin_unlock_np(struct spinlock_deprecated *sp); #define MCOUNT_ENTER(s) { s = read_eflags(); \ __asm __volatile("cli" : : : "memory"); \ - s_lock_np(&mcount_lock); } -#define MCOUNT_EXIT(s) { s_unlock_np(&mcount_lock); write_eflags(s); } + spin_lock_np(&mcount_spinlock); } +#define MCOUNT_EXIT(s) { spin_unlock_np(&mcount_spinlock); write_eflags(s); } #else #define MCOUNT_ENTER(s) { s = read_eflags(); cpu_disable_intr(); } #define MCOUNT_EXIT(s) (write_eflags(s)) diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index 8f46cf6aa4..f1d23488bc 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -114,7 +114,7 @@ kmstartup(void *dummy) else if (p->tolimit > MAXARCS) p->tolimit = MAXARCS; p->tossize = p->tolimit * sizeof(struct tostruct); - cp = (char *)malloc(p->kcountsize + p->fromssize + p->tossize, + cp = (char *)kmalloc(p->kcountsize + p->fromssize + p->tossize, M_GPROF, M_NOWAIT); if (cp == 0) { kprintf("No memory for profiling.\n"); diff --git a/sys/platform/pc32/icu/icu_vector.s b/sys/platform/pc32/icu/icu_vector.s index 67429a0cac..ffa95f1214 100644 --- a/sys/platform/pc32/icu/icu_vector.s +++ b/sys/platform/pc32/icu/icu_vector.s @@ -165,7 +165,6 @@ IDTVEC(icu_intr##irq_num) ; \ MEXITCOUNT ; \ jmp doreti ; \ -MCOUNT_LABEL(bintr) INTR_HANDLER(0, IO_ICU1, ENABLE_ICU1) INTR_HANDLER(1, IO_ICU1, ENABLE_ICU1) INTR_HANDLER(2, IO_ICU1, ENABLE_ICU1) @@ -182,7 +181,6 @@ MCOUNT_LABEL(bintr) INTR_HANDLER(13, IO_ICU2, ENABLE_ICU1_AND_2) INTR_HANDLER(14, IO_ICU2, ENABLE_ICU1_AND_2) INTR_HANDLER(15, IO_ICU2, ENABLE_ICU1_AND_2) -MCOUNT_LABEL(eintr) .data -- 2.41.0