UML UBD Token Bucket I/O Limiter -------------------------------- Christopher S. Aker - caker at theshore.net http://www.theshore.net/~caker/uml/patches/ This patch implements a simple token bucket filter/limiter on requests processed through the async io_thread. It will work with or without COW, but not on ubd devices in sync mode. * Two new command line arguments for setting at boot-time: token_max=60000 This sets the maximum tokens in the token-bucket I/O request limiter. Each io_thread request subtracts one token from the bucket. The bucket is supplied with tokens every second. When the bucket becomes empty, I/O requests are throttled to the rate. token_refill=2000 This sets the bucket's refill rate, adding tokens to the bucket every second. This becomes the I/O request rate when the bucket becomes empty. * Three new mconsole commands to get status information and change the two variables above: (mconsole) help io_status - Return current I/O status and settings io_token_max - sets the bucket size io_token_refill - number of tokens to add each second * Example io_status output while: idle: io_count=1845202 io_rate=0 io_tokens=50000 token_refill=1024 token_max=50000 bursting: io_count=1861594 io_rate=6806 io_tokens=35754 token_refill=1024 token_max=50000 throttled: io_count=1994811 io_rate=1087 io_tokens=-153 token_refill=1024 token_max=50000 io_count=2052289 io_rate=1057 io_tokens=-286 token_refill=1024 token_max=50000 io_count=2067794 io_rate=1015 io_tokens=-132 token_refill=1024 token_max=50000 When io_tokens reaches zero or is negative, the I/O requests are being limted, but they'll not go through faster than the refill rate. * TODO Stop using an alarm in the io_thread, and instead use gettimeofday to calculate the token credits due and io_rate. * CHANGELOG 2004-03-28 - v1 - Initial release 2004-11-22 - v2 - Patch now includes the /proc/io_status patch, and a fix for when token_refill = 1 2004-11-26 - v3 - Split out /proc/io_status patch for, and a better fix for when token_refill = 1 -Chris