From owner-freebsd-arch@FreeBSD.ORG Mon Oct 1 04:35:09 2007 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98A7916A419 for ; Mon, 1 Oct 2007 04:35:09 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outQ.internet-mail-service.net (outQ.internet-mail-service.net [216.240.47.240]) by mx1.freebsd.org (Postfix) with ESMTP id 7D0FD13C43E for ; Mon, 1 Oct 2007 04:35:09 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Sun, 30 Sep 2007 21:22:07 -0700 X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (home.elischer.org [216.240.48.38]) by idiom.com (Postfix) with ESMTP id BA712126547; Sun, 30 Sep 2007 21:22:06 -0700 (PDT) Message-ID: <470075EE.1030104@elischer.org> Date: Sun, 30 Sep 2007 21:22:06 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: Alexander Motin References: <46FFD850.1040508@FreeBSD.org> In-Reply-To: <46FFD850.1040508@FreeBSD.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: Kernel thread stack usage X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2007 04:35:09 -0000 Alexander Motin wrote: > Hi. > > As known in netgraph susbystem information passing from one node to > another by direct function calls without queueing. It gives performance > bonuses, but it also gives permanent stack overflow risk on complicated > graphs. Netgraph is still have a queues and able to use them when asked, > but now queueing is a flag which should be controlled by sending node. I > think it would be good to implement some algorithm which could monitor > stack usage on each call and enforce queueing when stack usage become > critical. > > The question is: is there correct way to somehow get current kernel > thread stack usage or just a stack base address? > I've thought about this quite a bit over the years. On possibility is a stack usage meter (which once did work out) and another is to have a 'hop count (or recursion count) added to the arguments passed around with the data. The nodes would have to cooperate with this scheme. The counter could be in the 'item' or an explicit argument. The 'recursion depth' counter may or may not be the same thing as a 'hop count' that could be kept in the mbuf. it is possible both make sense two mbuf counters. one oncremented whenever there is am mbuf handoff that doesn't involve queueing, and is cleared to 0 whenever queueing is invoked, and one that is continually incremented until the packet leaves the machine.. one to stop packets permanently circulating around a machine and one for stack protection..