From owner-freebsd-arch@FreeBSD.ORG Sun Nov 11 16:38:32 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 AB02116A46D for ; Sun, 11 Nov 2007 16:38:32 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from relay02.kiev.sovam.com (relay02.kiev.sovam.com [62.64.120.197]) by mx1.freebsd.org (Postfix) with ESMTP id 2C15913C4B7 for ; Sun, 11 Nov 2007 16:38:32 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from [212.82.216.226] (helo=deviant.kiev.zoral.com.ua) by relay02.kiev.sovam.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1IrFp9-0008l4-PR; Sun, 11 Nov 2007 18:38:16 +0200 Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.1/8.14.1) with ESMTP id lABGcFLA049206; Sun, 11 Nov 2007 18:38:15 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.1/8.14.1/Submit) id lABGcFBA049205; Sun, 11 Nov 2007 18:38:15 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 11 Nov 2007 18:38:15 +0200 From: Kostik Belousov To: Alexander Motin Message-ID: <20071111163815.GJ37471@deviant.kiev.zoral.com.ua> References: <1191187393.00807485.1191175801@10.7.7.3> <1191189248.00807488.1191177603@10.7.7.3> <4736D8AF.7010209@FreeBSD.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8O4mmsqCUhOCyWJp" Content-Disposition: inline In-Reply-To: <4736D8AF.7010209@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Scanner-Signature: 1118cf21f7425d415ed61e91afc5cb63 X-DrWeb-checked: yes X-SpamTest-Envelope-From: kostikbel@gmail.com X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 1761 [Nov 09 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {received from trusted relay: not dialup} X-SpamTest-Method: none X-SpamTest-Method: Local Lists X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release 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: Sun, 11 Nov 2007 16:38:32 -0000 --8O4mmsqCUhOCyWJp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 11, 2007 at 12:25:51PM +0200, Alexander Motin wrote: > >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? >=20 > Digging kernel with a dirty hands I have found the way which looks like= =20 > working. I have briefly tested it on i386. >=20 > printf("%p, %p. Used %d of %d.\n", &var, > (char *)td->td_kstack + td->td_kstack_pages * PAGE_SIZE, > (char *)td->td_kstack + td->td_kstack_pages * PAGE_SIZE - > (char *)&var, > td->td_kstack_pages * PAGE_SIZE); >=20 > 'var' here is a name of some local variable. >=20 > Can anybody comment correctness of this way or propose another one? Most of the time, you will get the correct value. But, see the vm_thread_new_altstack() in vm/vm_glue.c. --8O4mmsqCUhOCyWJp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHNy/2C3+MBN1Mb4gRAuh/AJ9MS/VAWnbhZ9Ne63x4ZNe++AWeUgCfcVM+ WYGlKQXjxdPUfRhLxADZqN0= =I7+7 -----END PGP SIGNATURE----- --8O4mmsqCUhOCyWJp--