From owner-freebsd-performance@FreeBSD.ORG Fri Dec 5 15:02:26 2008 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B68AB106564A for ; Fri, 5 Dec 2008 15:02:26 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.24]) by mx1.freebsd.org (Postfix) with ESMTP id 696D58FC0C for ; Fri, 5 Dec 2008 15:02:26 +0000 (UTC) (envelope-from raykinsella78@gmail.com) Received: by qw-out-2122.google.com with SMTP id 9so9511qwb.7 for ; Fri, 05 Dec 2008 07:02:25 -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:in-reply-to:mime-version:content-type:references; bh=faHwGvv8uEV9DVnn4wRuezdbwEWUCntTBtJj/tNB4Ks=; b=xIPP9Mz+xLnLfjHBFZKzTuPGCyetZn5jPdTcJzY21dYms2bln8lNUSnsB5/0GxzpgY T4hNbW0kwJxMuAYxb5uVxJZ9vuhJwbKMebtapnT38Mc1MTIIQN1wUqVzWwfv5f2E3JKC j9FMo4Nu7j+OJo4aqi5h0syfDcc9GGMTHr2sc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=NHorBfrprovFbmaw/acoR9SiTAWFAfwX9GtataHcdMPFll16LrEdbstPSi9ry93Ia7 Rmhz//TtZZvPvwkmDlj/uyjrXzZuUf5FGuQOt7JnIXRx9FpNdZBON5hO+UzPu3tsx9qk o2sK9V1jQM5v8bbF5uoM4sCfdGdDjJbRUiQ1g= Received: by 10.214.148.10 with SMTP id v10mr131404qad.287.1228489345585; Fri, 05 Dec 2008 07:02:25 -0800 (PST) Received: by 10.214.243.19 with HTTP; Fri, 5 Dec 2008 07:02:25 -0800 (PST) Message-ID: <584ec6bb0812050702j7dbf5b54k87d2cb4e4f6fa8b4@mail.gmail.com> Date: Fri, 5 Dec 2008 15:02:25 +0000 From: "Ray Kinsella" To: freebsd-performance@freebsd.org In-Reply-To: <584ec6bb0812050701t4bcccb1fr214370f4535ae1d0@mail.gmail.com> MIME-Version: 1.0 References: <584ec6bb0812050701t4bcccb1fr214370f4535ae1d0@mail.gmail.com> 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: Re: Thread priority in FreeBSD X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2008 15:02:26 -0000 Apologies, I neglected to clarify, I am of course talking about Kernel Threads. On Fri, Dec 5, 2008 at 3:01 PM, Ray Kinsella wrote: > Hi all, > > I have a problem trying to influence 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 > > * > > > * >