Date: Sun, 11 Nov 2007 19:41:20 +0200 From: Alexander Motin <mav@FreeBSD.org> Cc: Kostik Belousov <kostikbel@gmail.com>, freebsd-arch@freebsd.org Subject: Re: Kernel thread stack usage Message-ID: <47373EC0.2040804@FreeBSD.org> In-Reply-To: <47373C5E.2080800@elischer.org> References: <1191187393.00807485.1191175801@10.7.7.3> <1191189248.00807488.1191177603@10.7.7.3> <4736D8AF.7010209@FreeBSD.org> <20071111163815.GJ37471@deviant.kiev.zoral.com.ua> <47373C5E.2080800@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> Kostik Belousov wrote: >>>> The question is: is there correct way to somehow get current kernel >>>> thread stack usage or just a stack base address? >>> Digging kernel with a dirty hands I have found the way which looks >>> like working. I have briefly tested it on i386. >>> >>> 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); >>> >>> 'var' here is a name of some local variable. >>> >>> 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. I have seen that. But as I have understood td_altkstack is just a temporal storage for original td_kstack value. I don't see how it interfere my question. -- Alexander Motin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47373EC0.2040804>