Re: /proc/kmsg memory usage ?

Riley Williams (rhw@MemAlpha.cx)
Sun, 6 Jan 2002 23:19:32 +0000 (GMT)


Hi Steve.

> I am hoping someone here can point me towards the right
> documentation / web page.
>
> I want to find out what happens to kernel messages in /proc/kmsg if
> they are not read.
>
> Specifically,
> Are they cleared after a specified amount of time (eg every 24 hours) ?
> Are they cleared when they occupy a maximum size ?
> If they are not read will the memory they occupy grow indefinately ?

Essentially, they are cleared by default, due to the way they are
implemented.

The implementation consists of a ring buffer X bytes in size (the exact
size depends on whic h architecture you're talking about). When the
kernel is booted, the READ and WRITE pointers both point to the very
first byte of the buffer. As messages are written into the buffer, they
are written to the byte the WRITE pointer points to and that pointer is
incremented for each byte written. Likewise with the read pointer, as
bytes are read, it is incremented for each byte.

The way a ring buffer works is that when the last byte in the buffer is
used, the next byte to be used is the first one in the buffer. When the
write pointer catches up with the read pointer, a buffer full condition
is declared, but in the case of the kmsg buffer, this is dealt with by
incrementing the READ pointer to the next NEWLINE character and freeing
up the space in between.

Best wishes from Riley.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/