From owner-freebsd-current@FreeBSD.ORG Mon Jan 12 08:42:44 2004 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 CAC0116A4CE for ; Mon, 12 Jan 2004 08:42:44 -0800 (PST) Received: from mail3.speakeasy.net (mail3.speakeasy.net [216.254.0.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6450043D62 for ; Mon, 12 Jan 2004 08:42:38 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 1331 invoked from network); 12 Jan 2004 16:42:37 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 12 Jan 2004 16:42:37 -0000 Received: from 10.50.40.206 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.10/8.12.10) with ESMTP id i0CGgRM4063792; Mon, 12 Jan 2004 11:42:34 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: "Daan Vreeken [PA4DAN]" , FreeBSD-current@FreeBSD.org Date: Mon, 12 Jan 2004 11:08:47 -0500 User-Agent: KMail/1.5.4 References: <200401112142.53073.Danovitsch@Vitsch.net> In-Reply-To: <200401112142.53073.Danovitsch@Vitsch.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401121108.47481.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) Subject: Re: Kernel threads and printf locking question 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, 12 Jan 2004 16:42:44 -0000 On Sunday 11 January 2004 03:42 pm, Daan Vreeken [PA4DAN] wrote: > Hi, > > I am writing a kernel module in which I have created a kernel thread with > kthread_create. For debugging I have added a couple of printf's in the > thread routine. Running the module on a single-proc system works fine, but > when running it on one of my SMP machines the console freezes after a > couple of seconds. > > I have been looking through the archives and through some other drivers ( > for example randomdev.c uses a kthread and printf's from it ). I found a > version of randomdev.c with google that lock's Giant while calling printf, > but randomdev.c in my src-tree has no locking there. (I'm using > 5.1-RELEASE) Right now I have changed all printf's in my module into a > macro-function that checks if ( curproc == our thread ) and locks Giant if > true, then printf's. (since some of the routines get called both from the > thread and from other places.) > > What is the current state of printf-locking when called from a kernel > thread? Is locking Giant the only possible way to avoid problems on SMP > systems, or is there a more fine-grained printf lock available? (on > 5.1-RELEASE or -current) printf really probably does require Giant right now, it just happens to be used very often after bootup when SMP is running. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org