Log in

No account? Create an account
linux source - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

linux source [Apr. 8th, 2004|02:19 am]
Brad Fitzpatrick
Tried to sleep a couple times but now for some reason I'm trying to read the source to Linux. It's surprisingly well documented.

In particular, I'm trying to figure what's responsible for freeing slab items of type "nfs_inode_cache" and "dentry_cache". Earlier today Lisa gave me the mystery of figuring out why two identical machines (hardware, software, roles, weighting) showed massively different amounts of free memory. (120 MB vs 500 MB). I looked at /proc/slabinfo and saw nfs_inode_cache and dentry_cache incredibly high on one, which I immediately recognized as find(1)'s fault, which was the only machine of ours with that not disabled.

So while I had confidence those cache items in the slabs would be reclaimed when necessary, I wanted to see the magic.

I've been looking at the slab, NFS, fs, and now VM code. Think I found what I was looking for:

mm/vmscan.c:try_to_free_pages -> shrink_slab

It's pretty cool... there's a "shrinker_list" of caches that can be shrunk with callbacks for the VM.

(easily amused at 2am)

So from there:

fs/dcache.c: set_shrinker(DEFAULT_SEEKS, shrink_dcache_memory);
fs/inode.c: set_shrinker(DEFAULT_SEEKS, shrink_icache_memory);

Now I'm curious if there's a way to invoke try_to_free_pages by hand, without waiting for the system memory to get low. I recognize it's not very useful, but I'm just curious.

I should sleep though or I won't get to work on time and be able wear my employee of the month shirt for the ~5th month in a row come May 1st.

[User Picture]From: brad
2004-04-08 08:43 am (UTC)
Would it let you change those at runtime? Could I effectively force a prune by lowering the ceiling, then removing it again?

If so, that'd be neat.

But I'll probably find a work-around to my current problem. (userspace naively looking at memfree to decide when to shrink itself.... should be looking at memfree + cached or similar)
(Reply) (Parent) (Thread)