But... I don't _want_ it to work right!!
February 1, 2008 12:40 PM Subscribe
Linux Hackers... help me make my linux box perform very very poorly on command.
OK, so for various reasons ( a research project) I want to be able to force the memory system to behave very very badly. I want to be able to force a cache-miss, or a TLB miss, or even force a page-fault disk read. So... I found a set of linux hooks in the kernel that would let me do this (ie flush_tlb()) but obviously they need to be run in kernel mode. So... I thought about writing a device driver to make the calls but I'm pretty sure even the driver wouldn't have permission to write to the CR registers (which is how the cache/TLB/ etc. flushes are done under the covers in x86).
I've never written a driver before and I don't want to go to the trouble just to find out it doesn't work. But a driver seems best since I want to write a variety of programs which could force this behavior whenever they want. So, hive mind any ideas? How can I make the memory hierarchy and virtual memory system break down on command?
==
PS I considered doing things like looking up the size and associativity of the caches and then forcing a cache miss but things like the victim cache and pre-fetcher make this approach difficult; to say nothing for how I would accomplish the same think at the page level.
OK, so for various reasons ( a research project) I want to be able to force the memory system to behave very very badly. I want to be able to force a cache-miss, or a TLB miss, or even force a page-fault disk read. So... I found a set of linux hooks in the kernel that would let me do this (ie flush_tlb()) but obviously they need to be run in kernel mode. So... I thought about writing a device driver to make the calls but I'm pretty sure even the driver wouldn't have permission to write to the CR registers (which is how the cache/TLB/ etc. flushes are done under the covers in x86).
I've never written a driver before and I don't want to go to the trouble just to find out it doesn't work. But a driver seems best since I want to write a variety of programs which could force this behavior whenever they want. So, hive mind any ideas? How can I make the memory hierarchy and virtual memory system break down on command?
==
PS I considered doing things like looking up the size and associativity of the caches and then forcing a cache miss but things like the victim cache and pre-fetcher make this approach difficult; to say nothing for how I would accomplish the same think at the page level.
Can you build on the fault injection code that's in the -mm branch?
posted by cmonkey at 12:55 PM on February 1, 2008
posted by cmonkey at 12:55 PM on February 1, 2008
Having a driver create an entry in /proc is pretty painless. User programs could then send commands to the driver through the file system.
posted by Zach! at 1:21 PM on February 1, 2008
posted by Zach! at 1:21 PM on February 1, 2008
Oh also: another idea for slowing paging down is to mess with the block device scheduler. See block/elevator.c. It explains how to write new ones. Then, you can have the driver switch between schedulers on-the-fly.
posted by Zach! at 1:58 PM on February 1, 2008
posted by Zach! at 1:58 PM on February 1, 2008
You may not need to use system calls to do this.
Create a memory hog application and run it. A memory hog creates a huge array and then reads locations from it rapidly, say every 128th, so that it needs the whole array to be paged in. If you run and detach one or two or three or twenty instances of that program, it'll hammer the OS paging in exactly the way you're talking about, because they'll try to consume more memory than exists.
posted by Steven C. Den Beste at 2:08 PM on February 1, 2008
Create a memory hog application and run it. A memory hog creates a huge array and then reads locations from it rapidly, say every 128th, so that it needs the whole array to be paged in. If you run and detach one or two or three or twenty instances of that program, it'll hammer the OS paging in exactly the way you're talking about, because they'll try to consume more memory than exists.
posted by Steven C. Den Beste at 2:08 PM on February 1, 2008
« Older How to get music off a corrupted iPod | Should I celebrate a child's menstruation? How? Newer »
This thread is closed to new comments.
grabgig 4
to have it allocate 4 gig of RAM.
posted by veedubya at 12:52 PM on February 1, 2008