]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/kgdb.c
generic: reduce stack pressure in sched_affinity
[linux-2.6-omap-h63xx.git] / kernel / kgdb.c
index 68aea78407e4be3fb1c27f42af3918faff0a9859..1bd0ec1c80b284ec06870bc8bc2b2ce726e27815 100644 (file)
@@ -200,6 +200,17 @@ int __weak kgdb_arch_init(void)
        return 0;
 }
 
+int __weak kgdb_skipexception(int exception, struct pt_regs *regs)
+{
+       return 0;
+}
+
+void __weak
+kgdb_post_primary_code(struct pt_regs *regs, int e_vector, int err_code)
+{
+       return;
+}
+
 /**
  *     kgdb_disable_hw_debug - Disable hardware debugging while we in kgdb.
  *     @regs: Current &struct pt_regs.
@@ -550,18 +561,6 @@ static void kgdb_wait(struct pt_regs *regs)
        smp_wmb();
        atomic_set(&cpu_in_kgdb[cpu], 1);
 
-       /*
-        * The primary CPU must be active to enter here, but this is
-        * guard in case the primary CPU had not been selected if
-        * this was an entry via nmi.
-        */
-       while (atomic_read(&kgdb_active) == -1)
-               cpu_relax();
-
-       /* Wait till primary CPU goes completely into the debugger. */
-       while (!atomic_read(&cpu_in_kgdb[atomic_read(&kgdb_active)]))
-               cpu_relax();
-
        /* Wait till primary CPU is done with debugging */
        while (atomic_read(&passive_cpu_wait[cpu]))
                cpu_relax();
@@ -589,12 +588,12 @@ static void kgdb_flush_swbreak_addr(unsigned long addr)
        if (!CACHE_FLUSH_IS_SAFE)
                return;
 
-       if (current->mm) {
+       if (current->mm && current->mm->mmap_cache) {
                flush_cache_range(current->mm->mmap_cache,
                                  addr, addr + BREAK_INSTR_SIZE);
-       } else {
-               flush_icache_range(addr, addr + BREAK_INSTR_SIZE);
        }
+       /* Force flush instruction cache if it was outside the mm */
+       flush_icache_range(addr, addr + BREAK_INSTR_SIZE);
 }
 
 /*
@@ -718,14 +717,16 @@ int remove_all_break(void)
 
        /* Clear memory breakpoints. */
        for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) {
-               if (kgdb_break[i].state != BP_SET)
-                       continue;
+               if (kgdb_break[i].state != BP_ACTIVE)
+                       goto setundefined;
                addr = kgdb_break[i].bpt_addr;
                error = kgdb_arch_remove_breakpoint(addr,
                                kgdb_break[i].saved_instr);
                if (error)
-                       return error;
-               kgdb_break[i].state = BP_REMOVED;
+                       printk(KERN_ERR "KGDB: breakpoint remove failed: %lx\n",
+                          addr);
+setundefined:
+               kgdb_break[i].state = BP_UNDEFINED;
        }
 
        /* Clear hardware breakpoints. */
@@ -1434,18 +1435,18 @@ acquirelock:
                        atomic_set(&passive_cpu_wait[i], 1);
        }
 
-#ifdef CONFIG_SMP
-       /* Signal the other CPUs to enter kgdb_wait() */
-       if ((!kgdb_single_step || !kgdb_contthread) && kgdb_do_roundup)
-               kgdb_roundup_cpus(flags);
-#endif
-
        /*
         * spin_lock code is good enough as a barrier so we don't
         * need one here:
         */
        atomic_set(&cpu_in_kgdb[ks->cpu], 1);
 
+#ifdef CONFIG_SMP
+       /* Signal the other CPUs to enter kgdb_wait() */
+       if ((!kgdb_single_step || !kgdb_contthread) && kgdb_do_roundup)
+               kgdb_roundup_cpus(flags);
+#endif
+
        /*
         * Wait for the other CPUs to be notified and be waiting for us:
         */
@@ -1501,7 +1502,8 @@ int kgdb_nmicallback(int cpu, void *regs)
 {
 #ifdef CONFIG_SMP
        if (!atomic_read(&cpu_in_kgdb[cpu]) &&
-                       atomic_read(&kgdb_active) != cpu) {
+                       atomic_read(&kgdb_active) != cpu &&
+                       atomic_read(&cpu_in_kgdb[atomic_read(&kgdb_active)])) {
                kgdb_wait((struct pt_regs *)regs);
                return 0;
        }
@@ -1594,7 +1596,7 @@ static void kgdb_initial_breakpoint(void)
 }
 
 /**
- *     kkgdb_register_io_module - register KGDB IO module
+ *     kgdb_register_io_module - register KGDB IO module
  *     @new_kgdb_io_ops: the io ops vector
  *
  *     Register it with the KGDB core.