On 03-Jul-2002 Julian Elischer wrote:
> congratulations.. I think that you win the Matt Dillon "got both
> processors to enter the ddb at the same time" award..
> 
> On Wed, 3 Jul 2002, David Wolfskill wrote:
> 
>> login: panic: vm_page_free: invalid wire count (360), pindex: 0x1
>> cpuid = 0; lapic.id = 00000000
>> Debugger("panic")
>> uernteilm etoruatp  s9t owpiptihn gi nctpeursr
>>  Sttso pdpiesda balte d
>> in_Debugger.0x46:  xchgl   %ebx,
>> db>
>> al trap 9: general protectinuwlppippelo
>> u 1lcd i10
>> irtnot  0:c026scpnr   01:da20fmpnr   010a2ppx8cxppxexpeppxxeppxp         pps@xxltx
>>                         = DPL 0, pres 1, def32 1, gran 1
>> processor eflags        = resume, IOPL = 0
>> current process         = c)elt r,o=
>> S
>> Xc
>> pDcXKK`K$KhK,KpK4KxK
> 
> doing an nm and figuring out where the processor was
> might be informative.

If you have a valid eip you can use addr2line to get the
exact source line.  We probably need to not allow concurrent
panics.  We already don't allow concurrent ddb sessions, but
we do let both processors panic at the same time I think.

Hmm, this should already be happening though:

panic(const char *fmt, ...)
{
        int bootopt;
        va_list ap;
        static char buf[256];

#ifdef SMP
        /*
         * We don't want multiple CPU's to panic at the same time, so we
         * use panic_cpu as a simple spinlock.  We have to keep checking
         * panic_cpu if we are spinning in case the panic on the first
         * CPU is canceled.
         */
        if (panic_cpu != PCPU_GET(cpuid))
                while (atomic_cmpset_int(&panic_cpu, NOCPU,
                    PCPU_GET(cpuid)) == 0)
                        while (panic_cpu != NOCPU)
                                ; /* nothing */
#endif

I suppose this could be broken if we migrate.  I'll try to
think of a better solution.  Probably using curthread instead
of cpuid.  Try this untested diff (warning, my mailer will
probably botch this):

Index: kern_shutdown.c
===================================================================
RCS file: /usr/cvs/src/sys/kern/kern_shutdown.c,v
retrieving revision 1.128
diff -u -r1.128 kern_shutdown.c
--- kern_shutdown.c     12 May 2002 18:27:28 -0000      1.128
+++ kern_shutdown.c     3 Jul 2002 17:12:32 -0000
@@ -421,7 +421,7 @@
 }
 
 #ifdef SMP
-static u_int panic_cpu = NOCPU;
+static uintptr_t panic_thread = NULL;
 #endif
 
 /*
@@ -441,15 +441,17 @@
 #ifdef SMP
        /*
         * We don't want multiple CPU's to panic at the same time, so we
-        * use panic_cpu as a simple spinlock.  We have to keep checking
-        * panic_cpu if we are spinning in case the panic on the first
+        * use panic_thread as a simple spinlock.  We have to keep checking
+        * panic_thread if we are spinning in case the panic on the first
         * CPU is canceled.
         */
-       if (panic_cpu != PCPU_GET(cpuid))
-               while (atomic_cmpset_int(&panic_cpu, NOCPU,
-                   PCPU_GET(cpuid)) == 0)
-                       while (panic_cpu != NOCPU)
-                               ; /* nothing */
+       if (panic_thread != curthread)
+               while (atomic_cmpset_ptr(&panic_thread, NULL, curthread) == 0)
+                       while (panic_thread != NULL) {
+#ifdef __i386__
+                               ia32_pause();
+#endif
+                       }
 #endif
 
        bootopt = RB_AUTOBOOT | RB_DUMP;
@@ -479,7 +481,7 @@
        /* See if the user aborted the panic, in which case we continue. */
        if (panicstr == NULL) {
 #ifdef SMP
-               atomic_store_rel_int(&panic_cpu, NOCPU);
+               atomic_store_rel_ptr(&panic_thread, NULL);
 #endif
                return;
        }


-- 

John Baldwin <[EMAIL PROTECTED]>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to