Date: Fri, 6 Oct 2000 00:22:01 +0200 From: Bernd Walter <ticso@cicely5.cicely.de> To: John Baldwin <jhb@FreeBSD.org> Cc: Jake Burkholder <jburkhol@home.com>, Boris Popov <bp@butya.kz>, freebsd-smp@FreeBSD.org, Mark Murray <mark@grondar.za> Subject: Re: Problems with kthread_exit() and SMPng Message-ID: <20001006002200.E40689@cicely5.cicely.de> In-Reply-To: <XFMail.001005143039.jhb@FreeBSD.org>; from jhb@FreeBSD.org on Thu, Oct 05, 2000 at 02:30:39PM -0700 References: <20001005223733.A40689@cicely5.cicely.de> <XFMail.001005143039.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Oct 05, 2000 at 02:30:39PM -0700, John Baldwin wrote: > > On 05-Oct-00 Bernd Walter wrote: > > On Thu, Oct 05, 2000 at 11:53:53AM -0700, John Baldwin wrote: > >> > >> On 05-Oct-00 Mark Murray wrote: > >> > Hmm. I'll try that. Will the (kthread_)exit release Giant? > >> > >> Yes. cpu_exit() (called by exit1()) releases Giant as its > >> final act before calling cpu_switch() (should be cpu_throw()) > >> to run the next process. > >> > >> > My thread does a lot of work; if it holds Giant, then it can't be > >> > preempted. That would be a problem. > >> > >> Errr, it can be pre-empted, but your thread doesn't need Giant except > >> for kthread_exit(). > >> > >> > There is another problem; printf's inside a kthread corrupt like > >> > crazy. They look very unthreadsafe. > >> > >> printf() is not MP safe. :-P You probably want to grab Giant before > >> calling printf(). > > > > Isn't it better to just fetch Giant inside of kthread_exit() and printf()? > > Giant is recursive so it shouldn't hurt much if we allocate it while > > already owning it but we don't need to rechange thread safe code after > > these restrictions fall. > > Ugh. If I'm going to go stick mutexes in code, I want to put the > right ones in. :-P Of course that's much better ;) The situation with such functions is not uncritical as you may need to release other mutexes before you call printf(); Say you have a driver which is called via another driver (upcall, ...). The other driver is not updated and calls us while holding Giant and we need to fetch one of our own mutexes for processing. That means we have to own Giant before we fetch our own mutex if we want to make use of printf() or we need to release our before entering Giant to do printf(). Otherwise we don't have a fixed mutex order :( -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001006002200.E40689>