From owner-freebsd-current@FreeBSD.ORG Mon May 5 13:01:52 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0798C37B40E for ; Mon, 5 May 2003 13:01:49 -0700 (PDT) Received: from mail.speakeasy.net (mail14.speakeasy.net [216.254.0.214]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6A63D43FB1 for ; Mon, 5 May 2003 13:01:47 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 12558 invoked from network); 5 May 2003 20:01:54 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 5 May 2003 20:01:54 -0000 Received: from laptop.baldwin.cx ([216.133.140.1]) by server.baldwin.cx (8.12.8/8.12.8) with ESMTP id h45K1idt015282; Mon, 5 May 2003 16:01:45 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <010c01c312ca$dad34b00$932a40c1@PHE> Date: Mon, 05 May 2003 16:01:52 -0400 (EDT) From: John Baldwin To: Petri Helenius cc: freebsd-current@FreeBSD.ORG cc: sos@FreeBSD.org Subject: RE: kthread_exit and giant X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 May 2003 20:01:52 -0000 On 05-May-2003 Petri Helenius wrote: > IŽve been bouncing this with Soren a few roundtrips and I thought IŽll ask a wider > audience since I could not locate the information who would be responsible for > grabbing Giant in this case, but it seems to be required to hold it when the thread > exits; (the panic occurs when ATA RAID rebuild thread completes) The kthread is supposed to acquire Giant before calling kthread_exit(). Actually, my guess is that the ar kthread needs to acquire Giant for the lifetime of the thread. I have an untested patch locally: Index: ata-raid.c =================================================================== RCS file: /usr/cvs/src/sys/dev/ata/ata-raid.c,v retrieving revision 1.64 diff -u -r1.64 ata-raid.c --- ata-raid.c 4 May 2003 16:17:54 -0000 1.64 +++ ata-raid.c 5 May 2003 18:15:35 -0000 @@ -969,6 +969,7 @@ int disk, s, count = 0, error = 0; caddr_t buffer; + mtx_lock(&Giant); if ((rdp->flags & (AR_F_READY|AR_F_DEGRADED)) != (AR_F_READY|AR_F_DEGRADED)) kthread_exit(EEXIST); > FreeBSD 5.0-CURRENT #3: Sat May 3 11:09:45 GMT 2003 > root@kompak.vuokselantie10.fi:/usr/src/sys/i386/compile/EMTEST > kompak# atacontrol status 0 > ar0: ATA RAID1 subdisks: ad4 ad6 status: REBUILDING 44% completed > kompak# panic: mutex Giant not owned at ../../../kern/kern_exit.c:122 > Debugger("panic") > Stopped at Debugger+0x54: xchgl %ebx,in_Debugger.0 > db> trace > Debugger(c038d044,c03eedc0,c038c78b,d26f4c54,1) at Debugger+0x54 > panic(c038c78b,c038c8c4,c038acdf,7a,104) at panic+0xab > _mtx_assert(c03ed140,1,c038acdf,7a,85) at _mtx_assert+0xec > exit1(c2a075f0,0,85,84,2) at exit1+0x33 > kthread_exit(0,1,1,0,0) at kthread_exit+0xb6 > ar_rebuild(c25e3000,d26f4d48,c038ad90,310,c2a075f0) at ar_rebuild+0x445 > fork_exit(c0161c40,c25e3000,d26f4d48) at fork_exit+0xc0 > fork_trampoline() at fork_trampoline+0x1a > --- trap 0x1, eip = 0, esp = 0xd26f4d7c, ebp = 0 --- > db> -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/