From owner-freebsd-hackers@FreeBSD.ORG Sat Jan 10 06:08:24 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01F1A16A4CE for ; Sat, 10 Jan 2004 06:08:24 -0800 (PST) Received: from Vitsch.net (b74143.upc-b.chello.nl [212.83.74.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id D3D8243D41 for ; Sat, 10 Jan 2004 06:08:21 -0800 (PST) (envelope-from Danovitsch@Vitsch.net) Received: from FreeBSD.Danovitsch.LAN (b83007.upc-b.chello.nl [212.83.83.7]) by Vitsch.net (8.12.3p2/8.11.3) with ESMTP id i0AE82Xe034592 for ; Sat, 10 Jan 2004 15:08:02 +0100 (CET) (envelope-from Danovitsch@Vitsch.net) Content-Type: text/plain; charset="us-ascii" From: "Daan Vreeken [PA4DAN]" To: FreeBSD-hackers@FreeBSD.org Date: Sat, 10 Jan 2004 15:08:22 +0100 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200401101508.22640.Danovitsch@Vitsch.net> Subject: kernel threads and printf locking question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2004 14:08:24 -0000 Hi, I am writing a kernel module in which I have created a kernel thread with= =20 kthread_create. For debugging I have added a couple of printf's in the=20 thread-routine. Running the module on a single-proc system works fine, bu= t=20 when running it on one of my SMP machines the console freezes after a cou= ple=20 of seconds. I have been looking through the archives and through some other drivers (= for=20 example randomdev.c uses a kthread and printf's from it ). I found a vers= ion=20 of randomdev.c with google that lock's Giant while calling printf, but=20 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=20 checks if ( curproc =3D=3D our thread ) and locks Giant if true, then pri= ntf's.=20 (since some of the routines get called both from the thread and from othe= r=20 places.) What is the current state of printf-locking when called from a kernel thr= ead?=20 Is locking Giant the only possible way to avoid problems on SMP systems, = or=20 is there a more fine-grained printf lock available? (on 5.1-RELEASE or=20 -current) thanks, Daan