From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 2 15:16:42 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 7FF4716A445 for ; Wed, 2 Nov 2005 15:16:42 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail5.speedfactory.net [66.23.216.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id A82D043D48 for ; Wed, 2 Nov 2005 15:16:41 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 1239527 for multiple; Wed, 02 Nov 2005 10:14:41 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.1/8.13.1) with ESMTP id jA2FGaGg057602; Wed, 2 Nov 2005 10:16:38 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Wed, 2 Nov 2005 09:53:43 -0500 User-Agent: KMail/1.8.2 References: <20051102093702.GB624@ilium.0xdeadc0de.net> In-Reply-To: <20051102093702.GB624@ilium.0xdeadc0de.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511020953.44298.jhb@freebsd.org> X-Spam-Status: No, score=-2.8 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=100 Cc: Viktor Vasilev Subject: Re: sysprof, interrupting threads 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: Wed, 02 Nov 2005 15:16:42 -0000 On Wednesday 02 November 2005 04:37 am, Viktor Vasilev wrote: > Hello fellow hackers, > > I was thinking of porting the linux sysprof kernel and userland tools > to FreeBSD. I spent some time studying the code and wrote a skeleton > driver that uses the callout mechanism to wake up periodically. That > was only to discover, that the context in which the driver awakes is > that of the software clock interrupt. > > The linux sysprof driver uses a timer hook API that was introduced in > the 2.6 kernel series. I don't have a profound understanding of the > linux kernel but it seems that the hook gets executed in the process > context that was currently executing as the tick happened. > > My question is, is there a better place to plant the code, so that it > executes periodically in the context of the current runnging thread? > I was also thinking of traversing the list of processes but I'm not > sure if I can tell which one was interrupted by the swi. > > Any suggestions are wellcome. hardclock_process() and statclock_process() (poorly named, should really be s/process/thread/ at this point). I believe kernel gprof profiling is done in statclock_process for example. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org