From owner-cvs-all@FreeBSD.ORG Sat Oct 27 03:21:08 2007 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7317716A417; Sat, 27 Oct 2007 03:21:08 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 32BE513C4A7; Sat, 27 Oct 2007 03:21:08 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.1/8.14.1) with ESMTP id l9R3JrP2072289; Fri, 26 Oct 2007 21:19:53 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Fri, 26 Oct 2007 21:20:31 -0600 (MDT) Message-Id: <20071026.212031.-1607499905.imp@bsdimp.com> To: julian@elischer.org From: "M. Warner Losh" In-Reply-To: <4722399E.3090209@elischer.org> References: <200710261703.l9QH3Nmt061137@repoman.freebsd.org> <200710261420.34168.jhb@freebsd.org> <4722399E.3090209@elischer.org> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: cvs-src@freebsd.org, src-committers@freebsd.org, julian@freebsd.org, cvs-all@freebsd.org, jhb@freebsd.org Subject: Re: cvs commit: src/sys/sys kthread.h src/sys/kern kern_kthread.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Oct 2007 03:21:08 -0000 In message: <4722399E.3090209@elischer.org> Julian Elischer writes: : John Baldwin wrote: : > On Friday 26 October 2007 01:03:22 pm Julian Elischer wrote: : >> julian 2007-10-26 17:03:22 UTC : >> : >> FreeBSD src repository : >> : >> Modified files: : >> sys/sys kthread.h : >> sys/kern kern_kthread.c : >> Log: : >> kthread_exit needs no stinkin argument. : > : > So an important property of the old kthread_exit() (now kproc_exit()) was that : > a kernel module could safely ensure that a kthread it created was out of the : > kernel module's text segment before returning from a module unload hook to : > prevent kernel panics by sleeping on the proc pointer with the proc lock like : > so: : > : > mtx_lock(&mylock); : > PROC_LOCK(p); : > signal_death = 1; : > mtx_unlock(&mylock); : > msleep(p, &p->p_mtx, ...); : > PROC_UNLOCK(p); : > : > And have the main thread do this: : > : > ... : > mtx_lock(&mylock); : > while (!signal_death) { : > ... fetch work, may drop mylock... : > } : > mtx_unlock(&mylock); : > kthread_exit(0); : : the kproc_exit still does.. : : I didn't see any users of it in the code that I've switched to kthreads : so far so I haven't added it to the kthread_exit() yet. : : the intr code does: : thread_lock(td); : ithread->it_flags |= IT_DEAD; : if (TD_AWAITING_INTR(td)) { : TD_CLR_IWAIT(td); : sched_add(td, SRQ_INTR); : } : thread_unlock(td); : : but no wait. : : but I'll look further.. maybe it's in the drivers? See dev/pccbb/pccbb.c for an example of the old usage. Warner