Date: Mon, 30 May 2005 13:01:39 +0100 (BST) From: Robert Watson <rwatson@FreeBSD.org> To: littlegege@263.net Cc: freebsd-hackers@freebsd.org Subject: Re: how can I get the meminfo of each kernel process? Message-ID: <20050530125857.G52379@fledge.watson.org> In-Reply-To: <20050530032647.CE08F4359F@smtp.263.net> References: <20050530032647.CE08F4359F@smtp.263.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 30 May 2005 littlegege@263.net wrote: > I want to get the meminfo of each kernel process,such as how much memory > size is allocated to a process.How can i do? I will do this in kernel > space,so which data structure can i used to achieve this. Kernel processes are a bit of a misnomer -- in general, they actually represent individual threads running in a single kernel address space. As such, memory is typically not owned by the kernel process, it's owned by the kernel as a whole. Normally, the approach taken is to track memory owned by individual kernel subsystems, which can (in most cases) be done using a combination of "vmstat -m" and "vmstat -z". Since individual threads may enter many different subsystems, and the largest volumes of memory are actually typically handed off between several threads (i.e., network packet buffers), this can provide better insight into memory use in the kernel. There are plans, in the future, to start using pure threads without associated kernel processes in the kernel, which will reduce overhead as well as make it more clear that kernel threads generally operate within a single process (task) address space. If you're interested in tracking memory allocation and use for specific kernel threads, you might want to look at ktr(4), which is a general kernel tracing primitive, and has hooks into the various kernel memory allocators to track memory allocation and free events. Robert N M Watson
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050530125857.G52379>