From owner-freebsd-hackers@FreeBSD.ORG Tue May 15 10:32:53 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8113216A400 for ; Tue, 15 May 2007 10:32:53 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 42CBC13C455 for ; Tue, 15 May 2007 10:32:53 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 7817620A7; Tue, 15 May 2007 12:32:49 +0200 (CEST) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: 0.0/3.0 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on tim.des.no Received: from dwp.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id EDE952088; Tue, 15 May 2007 12:32:48 +0200 (CEST) Received: by dwp.des.no (Postfix, from userid 1001) id D61015180; Tue, 15 May 2007 12:32:48 +0200 (CEST) From: des@des.no (Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?=) To: Lawrence Stewart References: <4649349D.4060101@room52.net> Date: Tue, 15 May 2007 12:32:48 +0200 In-Reply-To: <4649349D.4060101@room52.net> (Lawrence Stewart's message of "Tue\, 15 May 2007 14\:18\:37 +1000") Message-ID: <86646ugywf.fsf@dwp.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Writing a plain text file to disk from kernel space X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2007 10:32:53 -0000 Lawrence Stewart writes: > I'm in the process of writing a kernel module to instrument some parts > of the network stack in FreeBSD 6.2. Everything works perfectly, > except that writing the logging info to syslog using printf is too > inefficient for this particular task. Given that log messages need to > be generated for each packet entering/leaving the network stack, my > testing thus far has showed that syslog groans under the load and uses > far too much CPU time. > > So, I'm looking for a way to manually open up a file from within > kernel space and dump characters into it. Look at the ktrace code. Note that it opens the file in userland and passes it down to the kernel. You may want to consider a similar mechanism. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no