[Prev][Next][Index][Thread]
UBC current value program
Keith wrote:
>As the size of the UBC is dynamic, can anyone tell me how I can find out
>what percentage of memory is being reserved for the buffer cache at any one
>moment in time?
>Before I start tuning the min/max values I would like to have a feel for how
>the size of the UBC fluctuates.
>Keith McCabe
>System Administrator
>Rolfe & Nolan Plc
>London
I wrote a quick little program to determine the size in pages of the ubc. I'll
post it here because it its pretty small. The technique used in this program
can get the value of any kernel variable, and there is a whole structure of
values for the ubc. Happy tuning.
-drew
-------
USMail: OTA Limited Partnership E-mail: drew@xxxxxx
1 Manhattanville Road Phone: +1 914 694 5800
Purchase, New York 10577 FAX: +1 914 694 5831
"Welcome, to the machine..."
-------
To complile, you must link with the mld library. Here's the command I use:
<drew@xxxxxx> cc ubcread.c -lmld -o ubcread
ubcread.c:
--------cut here----------
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <nlist.h>
struct nlist nl[] = {
{ "ubc_pages" },
#define XUBC_PAGES 0
{ "ubc_dirtypages" },
#define XUBC_DIRTYPAGES 1
{ 0 },
};
int kmem;
long pages;
main ()
{
if ((kmem = open("/dev/kmem", 0)) < 0) {
fprintf(stderr, "No kmem\n");
exit(1);
}
nlist("/vmunix", nl);
if (nl[0].n_type==0) {
fprintf(stderr, "No namelist\n");
exit(1);
}
printf("ubc_pages:");
lseek(kmem, nl[XUBC_PAGES].n_value, SEEK_SET);
read(kmem, &pages, sizeof(pages));
printf(" %d", pages);
printf("\n");
}