From owner-freebsd-drivers@FreeBSD.ORG Mon Dec 1 21:43:45 2008 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3091710656D9; Mon, 1 Dec 2008 21:43:45 +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 A8B528FC0A; Mon, 1 Dec 2008 21:43:44 +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 mB1LhaQl000939; Mon, 1 Dec 2008 16:43:36 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Mon, 1 Dec 2008 15:05:56 -0500 User-Agent: KMail/1.9.7 References: <5D267A3F22FD854F8F48B3D2B52381933940B2DEFE@IRVEXCHCCR01.corp.ad.broadcom.com> <492B2306.60404@freebsd.org> In-Reply-To: <492B2306.60404@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812011505.56535.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 01 Dec 2008 16:43:37 -0500 (EST) X-Virus-Scanned: ClamAV 0.93.1/8704/Mon Dec 1 11:39:36 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: Sam Leffler , "freebsd-net@FreeBSD.org" Subject: Re: Gathering Hardware State During a Driver Initiated Kernel Panic X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2008 21:43:45 -0000 On Monday 24 November 2008 04:56:22 pm Sam Leffler wrote: > David Christensen wrote: > > Is there a method or callback in FreeBSD where a driver can > > be notified that it has caused a kernel panic in order to > > generate a dump of internal hardware state information? I've > > written a sysctl call for manual intervention and can handle > > some "expected" hardware events completely in the driver but > > I don't know of a way to get control again in cases where the > > driver wasn't expecting a failure. > > > > Not sure how one can deduce a driver is at fault but you might define a > ddb command for the driver and invoke that on panic using the ddb script > mechanisms (see ddb(4)). You might be able to set the current 'panic' ddb script function to one you define in your code somehow. That is, set it on entry to bce_start() and then reset it to empty when bce_start() returns. Similarly for the interrupt handler, bce_init(), and bce_ioctl(). I haven't looked to see if there is a clean way to set a script function in C though. -- John Baldwin From owner-freebsd-drivers@FreeBSD.ORG Fri Dec 5 15:09:58 2008 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE51A1065675 for ; Fri, 5 Dec 2008 15:09:57 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: from mail-qy0-f18.google.com (mail-qy0-f18.google.com [209.85.221.18]) by mx1.freebsd.org (Postfix) with ESMTP id 75E1B8FC1A for ; Fri, 5 Dec 2008 15:09:57 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: by qyk11 with SMTP id 11so49536qyk.19 for ; Fri, 05 Dec 2008 07:09:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=Xrp7Awb0nGH9E7b46rKNjRHzAUmqA24aDUyLilunXWw=; b=eCYJ5o4il9W1UqkR6gOjwpgNivQRyNcf5r2qf6sq++zD05Rr5ZfnMDuDIdDR/d1clY kncNdS0rGZu4O7Nl01H6u+1eVW3x29NG5Eigr+w10PBQW8fOac2VJdcpBaYsHma3hhkQ ZPdPK3j9J5uX2S4CMODXIRxeoEL+kRIiLqHnI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=kciC95JBU3nexv/uNavmjC3NW3WlPmuoFLFkKRzElfUKdMEGpEBojUBvdifJbKp/DL 6UqaLbYA/zdPNqzD6HC695khnrVsNyHXqA8BN92NTTefu2rz+a4tUMX+jMoJbMZIhKwv XXRQ9CshJpri4//6GyFpv1KeRwbW9Mnyj1mYE= Received: by 10.214.115.21 with SMTP id n21mr158800qac.211.1228489796831; Fri, 05 Dec 2008 07:09:56 -0800 (PST) Received: by 10.214.243.19 with HTTP; Fri, 5 Dec 2008 07:09:56 -0800 (PST) Message-ID: <584ec6bb0812050709p309d406ax7e22d1fad8ad9719@mail.gmail.com> Date: Fri, 5 Dec 2008 15:09:56 +0000 From: "Ray Kinsella" To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Kernel Thread priority in FreeBSD X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 15:09:58 -0000 Hi all, I am reposting this from the performance list, as it might be a better forum for the question. I have a problem trying to influence kernel thread scheduling in FreeBSD. There are three threads I am interested the priority of:- a. Enqueue Thread: - Enqueues data in a circular buffer b. Interrupt Handler: - Signals that data in the circular buffer has been processed and in ready for removal - Queues an entry on a task queue so the data is removed from the circular buffer asynchronousily - Data is processed by a pci card c. Task Queue Thread: - Dequeues request from a task queue. - Dequeues data from the circular buffer. *Objective: *I want to prioritise the *Enqueue Thread, *such that it will always executes until the circular buffer is exhausted of space. I want the *Task Queue Thread* to have the lowest priority such that it only runs when the *Enqueue Thread* has no work to do. *Observed behaviour: *I set the *Enqueue Thread, *to have a priority of PRI_MAX_KERN (0) I set the *Task Queue Thread,* to have a priority of PRI_MIN_KERN (64) In the main I see the following scheduling:- ... *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread, *puts requests on a taskqueue for async processing. *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread**, *puts requests on a taskqueue for async processing. *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer .. No matter what I do with thread priorities, the *Task Queue Thread *always follows the *Interrupt Handler. * *Ideal behaviour* Ideally I would get the following behaviour, were *Enqueue Thread *will always run instead of *Task Queue Thread *thread while it has work to do. *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread, *puts requests on a taskqueue for async processing. *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread**, *puts requests on a taskqueue for async processing. *Enqueue Thread, *Enqueues serveral requests on the circular buffer *Interrupt Handler*, Interrupts the *Enqueue Thread**, *puts requests on a taskqueue for async processing. *Enqueue Thread, *yields timeslices as the circular buffer is maxed out *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer *Task Queue Thread, *Dequeues the request from a taskqueue and the data from the circular buffer Any idea's how to encourage the scheduler to adopt this behaviour ? Thanks Ray Kinsella * *