Re: inode_cache / dentry_cache not being reclaimed aggressivelyenough on low-memory PCs
From: Alex Buell
Date: Sat Jan 03 2004 - 13:31:54 EST
On Sat, 3 Jan 2004, John Lash wrote:
> Check on your system, /proc/sys/fs/dentry-state, first two values appear
> to be nr_dentry and nr_unused. Plug those values into the above code and
> if you get something around zero, that's why the memory is stuck.
Right, I put together this simple C program as follows:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int dentries_used, dentries_unused;
int inodes_used, inodes_unused;
int ratio = 1, used;
char entries[80];
FILE *fh;
fh = fopen("/proc/sys/fs/dentry-state", "r");
fgets(entries, 4096, fh);
fclose(fh);
dentries_used = atoi(entries);
dentries_unused = atoi(&entries[6]);
printf("nr_dentry: %d\nnr_unused: %d\n\n", dentries_used, dentries_unused);
used = dentries_used - dentries_unused;
printf("%d < %d * %d = %d\n", dentries_unused, used, ratio, (dentries_unused < used * ratio));
return 0;
}
This gives me interesting results:
1) On a box with humuguous dentries:
./fs_cache
nr_dentry: 76637
nr_unused: 67869
67869 < 8768 * 1 = 0
2) On a box with not so many:
./fs_cache
nr_dentry: 7950
nr_unused: 572
572 < 7378 * 1 = 1
So it seems you're quite right.
> A couple of solutions come to mind. The one I like best would be to
> adjust the above code to make it conscious of the total memory in the
> system and keep nr_unused to a reasonable percentage. Another is to
> allow unused_ratio to be less than 1, Possibly some/proc entry to lower
> it (.5, .25, whatever), or to avoid the float, provide another parameter
> to do an integer divisor for unused_ratio. Something like:
>
> nr_unused - nr_used * unused_ratio / ratio_fraction
That solution does seem be the best answer.
--
http://www.munted.org.uk
Your mother cooks socks in hell
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/