]> git.hungrycats.org Git - linux/commitdiff
[PATCH] out-of-line locks / i386
authorZwane Mwaikambo <zwane@linuxpower.ca>
Sat, 4 Sep 2004 09:18:47 +0000 (02:18 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 4 Sep 2004 09:18:47 +0000 (02:18 -0700)
Signed-off-by: Zwane Mwaikambo <zwane@fsmlabs.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/kernel/time.c
arch/i386/kernel/vmlinux.lds.S
arch/i386/oprofile/op_model_athlon.c
arch/i386/oprofile/op_model_p4.c
arch/i386/oprofile/op_model_ppro.c
include/asm-i386/ptrace.h
include/asm-i386/rwlock.h
include/asm-i386/spinlock.h

index f8dcf5d687650dc26af16b999d33de5adedf7ab2..8a8c0f643d1fe01989f8313b0e2e84ffff925738 100644 (file)
@@ -200,6 +200,19 @@ unsigned long long monotonic_clock(void)
 }
 EXPORT_SYMBOL(monotonic_clock);
 
+#if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER)
+unsigned long profile_pc(struct pt_regs *regs)
+{
+       unsigned long pc = instruction_pointer(regs);
+
+       if (pc >= (unsigned long)&__lock_text_start &&
+           pc <= (unsigned long)&__lock_text_end)
+               return *(unsigned long *)(regs->ebp + 4);
+
+       return pc;
+}
+EXPORT_SYMBOL(profile_pc);
+#endif
 
 /*
  * timer_interrupt() needs to keep up the real-time clock,
index 8eb5ea15a12b26cfbd97d8b87a78af41bb2d254d..e0512cc8bea76b9b73c75177426209b0b6306095 100644 (file)
@@ -18,6 +18,7 @@ SECTIONS
   .text : {
        *(.text)
        SCHED_TEXT
+       LOCK_TEXT
        *(.fixup)
        *(.gnu.warning)
        } = 0x9090
index dbbc0ff8ce92c3c22f1e10c239465f8e9612460d..0d4e00f42995ff2a9ed5836637177a7be3f4c764 100644 (file)
@@ -96,7 +96,7 @@ static int athlon_check_ctrs(unsigned int const cpu,
 {
        unsigned int low, high;
        int i;
-       unsigned long eip = instruction_pointer(regs);
+       unsigned long eip = profile_pc(regs);
        int is_kernel = !user_mode(regs);
 
        for (i = 0 ; i < NUM_COUNTERS; ++i) {
index 661896b3bfcc102818eba90644b0acf0c942b344..1b3626df5dd227cbfafaaf6814d2d6f48f47d551 100644 (file)
@@ -625,7 +625,7 @@ static int p4_check_ctrs(unsigned int const cpu,
 {
        unsigned long ctr, low, high, stag, real;
        int i;
-       unsigned long eip = instruction_pointer(regs);
+       unsigned long eip = profile_pc(regs);
        int is_kernel = !user_mode(regs);
 
        stag = get_stagger();
index e10b49e50191b75c0a0a131fa823eb6496f9c54e..0cc80654db626cbc2f374880e395dbadcefd3594 100644 (file)
@@ -91,7 +91,7 @@ static int ppro_check_ctrs(unsigned int const cpu,
 {
        unsigned int low, high;
        int i;
-       unsigned long eip = instruction_pointer(regs);
+       unsigned long eip = profile_pc(regs);
        int is_kernel = !user_mode(regs);
  
        for (i = 0 ; i < NUM_COUNTERS; ++i) {
index 0e6725c46a7be63ca3c4dbcc804bdfe1b4b571da..2d673afe72f33e350aa42e78790a5ecae79274bc 100644 (file)
@@ -57,7 +57,11 @@ struct pt_regs {
 #ifdef __KERNEL__
 #define user_mode(regs) ((VM_MASK & (regs)->eflags) || (3 & (regs)->xcs))
 #define instruction_pointer(regs) ((regs)->eip)
+#if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER)
+extern unsigned long profile_pc(struct pt_regs *regs);
+#else
 #define profile_pc(regs) instruction_pointer(regs)
 #endif
+#endif
 
 #endif
index 291091ddae4ccf9229c317f1c6fe96791641dce5..b57cc7afdf7e27b220ad1c1b96cbf82a09f591fc 100644 (file)
 
 #define __build_read_lock_ptr(rw, helper)   \
        asm volatile(LOCK "subl $1,(%0)\n\t" \
-                    "js 2f\n" \
+                    "jns 1f\n" \
+                    "call " helper "\n\t" \
                     "1:\n" \
-                    LOCK_SECTION_START("") \
-                    "2:\tcall " helper "\n\t" \
-                    "jmp 1b\n" \
-                    LOCK_SECTION_END \
                     ::"a" (rw) : "memory")
 
 #define __build_read_lock_const(rw, helper)   \
        asm volatile(LOCK "subl $1,%0\n\t" \
-                    "js 2f\n" \
-                    "1:\n" \
-                    LOCK_SECTION_START("") \
-                    "2:\tpushl %%eax\n\t" \
+                    "jns 1f\n" \
+                    "pushl %%eax\n\t" \
                     "leal %0,%%eax\n\t" \
                     "call " helper "\n\t" \
                     "popl %%eax\n\t" \
-                    "jmp 1b\n" \
-                    LOCK_SECTION_END \
+                    "1:\n" \
                     :"=m" (*(volatile int *)rw) : : "memory")
 
 #define __build_read_lock(rw, helper)  do { \
 
 #define __build_write_lock_ptr(rw, helper) \
        asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
-                    "jnz 2f\n" \
+                    "jz 1f\n" \
+                    "call " helper "\n\t" \
                     "1:\n" \
-                    LOCK_SECTION_START("") \
-                    "2:\tcall " helper "\n\t" \
-                    "jmp 1b\n" \
-                    LOCK_SECTION_END \
                     ::"a" (rw) : "memory")
 
 #define __build_write_lock_const(rw, helper) \
        asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
-                    "jnz 2f\n" \
-                    "1:\n" \
-                    LOCK_SECTION_START("") \
-                    "2:\tpushl %%eax\n\t" \
+                    "jz 1f\n" \
+                    "pushl %%eax\n\t" \
                     "leal %0,%%eax\n\t" \
                     "call " helper "\n\t" \
                     "popl %%eax\n\t" \
-                    "jmp 1b\n" \
-                    LOCK_SECTION_END \
+                    "1:\n" \
                     :"=m" (*(volatile int *)rw) : : "memory")
 
 #define __build_write_lock(rw, helper) do { \
index d6dbfd46956597d3c146ad8ef3db22d8af9c7ebe..c189e1b9be4c7beade875f03e13b4b58b79a32ab 100644 (file)
@@ -46,20 +46,18 @@ typedef struct {
 #define spin_lock_string \
        "\n1:\t" \
        "lock ; decb %0\n\t" \
-       "js 2f\n" \
-       LOCK_SECTION_START("") \
+       "jns 3f\n" \
        "2:\t" \
        "rep;nop\n\t" \
        "cmpb $0,%0\n\t" \
        "jle 2b\n\t" \
        "jmp 1b\n" \
-       LOCK_SECTION_END
+       "3:\n\t"
 
 #define spin_lock_string_flags \
        "\n1:\t" \
        "lock ; decb %0\n\t" \
-       "js 2f\n\t" \
-       LOCK_SECTION_START("") \
+       "jns 4f\n\t" \
        "2:\t" \
        "testl $0x200, %1\n\t" \
        "jz 3f\n\t" \
@@ -70,7 +68,7 @@ typedef struct {
        "jle 3b\n\t" \
        "cli\n\t" \
        "jmp 1b\n" \
-       LOCK_SECTION_END
+       "4:\n\t"
 
 /*
  * This works. Despite all the confusion.