From owner-freebsd-arch@FreeBSD.ORG Thu Nov 20 20:37:05 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 544A81065674; Thu, 20 Nov 2008 20:37:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id A0F328FC1C; Thu, 20 Nov 2008 20:37:04 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id mAKKaq1G068073; Thu, 20 Nov 2008 15:36:58 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-arch@freebsd.org Date: Thu, 20 Nov 2008 15:02:23 -0500 User-Agent: KMail/1.9.7 References: <492412E8.3060700@freebsd.org> In-Reply-To: <492412E8.3060700@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811201502.23943.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Thu, 20 Nov 2008 15:36:58 -0500 (EST) X-Virus-Scanned: ClamAV 0.93.1/8653/Thu Nov 20 04:04:07 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Lawrence Stewart Subject: Re: kthread_exit(9) unexpectedness X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2008 20:37:05 -0000 On Wednesday 19 November 2008 08:21:44 am Lawrence Stewart wrote: > Hi all, > > I tracked down a deadlock in some of my code today to some weird > behaviour in the kthread(9) KPI. The executive summary is that > kthread_exit() thread termination notification using wakeup() behaves as > expected intuitively in 8.x, but not in 7.x. In 5.x/6.x/7.x kthreads are still processes and it has always been a wakeup on the proc pointer. kthread_create() in 7.x returns a proc pointer, not a thread pointer for example. In 8.x kthreads are actual threads and kthread_add() and kproc_kthread_add() both return thread pointers. Hence in 8.x kthread_exit() is used for exiting kernel threads and wakes up the thread pointer, but in 7.x kthread_exit() is used for exiting kernel processes and wakes up the proc pointer. I think what is probably needed is to simply document that arrangement as such. Note that the sleeping on proc pointer has been the documented way to synchronize with kthread_exit() since 5.0. -- John Baldwin