tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] a character device counting kernel pages

On Thu, Aug 14, 2008 at 05:00:59PM +0300, Ilya Dogolazky wrote:
> Hi,
> the attached patch is implementing a simple counter of memory pages used by
> the kernel.
> This kernel memory consumption measuring device (/dev/kp0, major=239, minor=0)
> is reporting (in decimal form, useful for shell scripts) the number of
> physical memory pages used by the kernel itself. It is tested for ARM only,
> but will probably work with some other architectures too. To enable it add the
> line "pseudo-device pagecounter" to the config file and create the device node
> (mknod /dev/kp0 c 239 0).
> Usage in a shell script: KERNEL_MEM=$(cat /dev/kp0)

Heh, that's so Linux.  We BSDers prefer sysctl for that kind of stuff.
So I'd say it's the wrong approach for the interface (look at it that
way: sysctl is one, maybe two syscalls, cat /dev/kp0 is at least 4).

Now, for the counter itself;  I'm not familiar enough with the VM to be
completely affirmative, but your code looks to me like it's lacking some

I would say the best approach is to keep a counter of the PVF_KMPAGE
pages are they are mapped and unmapped, and simply expose that counter
through a sysctl.  You probably won't even have to care about locking it
as such allocation is likely to happen at splhigh() anyway.

For all I know, such a counter might already exist, and it'd be just a
matter of properly exposing it to userland.

That said, I think that kind of information would be useful to have;
I've heard people dealing with NKMEMPAGES troubles recently, and I don't
how to monitor their consumption.

Oh, and you you might prefer not copying the licence blob from just any
other source file.  Somehow I don't think you were writing this under
DARPA contract in 1992.

Quentin Garnier - -
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgpVaqbGlS74P.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index