Advertise here: Contact FM.


But... I don't _want_ it to work right!!
February 1, 2008 12:40 PM   RSS feed for this thread 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.
posted by lucasks to computers & internet (5 comments total) 3 users marked this as a favorite
Have your device driver open up a socket and listen on it, so that it is effectively a daemon. That way you can use telnet to connect to it and send it commands. In the driver, have a simple command parser that interprets what's coming in on the socket, and acts on it. That way, for example, you could telnet to it and send something like:

grabgig 4

to have it allocate 4 gig of RAM.
posted by veedubya at 12:52 PM on February 1


Can you build on the fault injection code that's in the -mm branch?
posted by cmonkey at 12:55 PM on February 1


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


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


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


« Older How do I get the music off of ...   |   [Ladies filter] My niece just ... Newer »

You are not logged in, either login or create an account to post comments



Related Questions
Help needed for a beginner installing LINUX drivers March 14, 2008
Printing to a Windows printer from a Macbook on... September 24, 2007
3D Rage II+ Drivers (or, Can Drivers Be Copied Off... February 23, 2007
Will i need to remove and replace my soundcard for... November 17, 2006
Print to JPEG? March 27, 2006