"Fix" kernel profiling for i386
authorAlex Hornung <ahornung@gmail.com>
Sat, 3 Jan 1970 05:16:21 +0000 (06:16 +0100)
committerAlex Hornung <ahornung@gmail.com>
Sat, 3 Jan 1970 05:16:21 +0000 (06:16 +0100)
* 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
sys/cpu/i386/include/profile.h
sys/kern/subr_prof.c
sys/platform/pc32/icu/icu_vector.s

index 44de11d..287f019 100644 (file)
@@ -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 */
index 33099f9..ef507cc 100644 (file)
 #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))
index 8f46cf6..f1d2348 100644 (file)
@@ -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");
index 67429a0..ffa95f1 100644 (file)
@@ -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