View previous topic :: View next topic |
Author |
Message |
manojpm n00b
Joined: 11 Mar 2006 Posts: 33
|
Posted: Wed Feb 28, 2007 1:17 am Post subject: how to use different i/o shedulers for different devices. |
|
|
hi,
i have been having speed problems when i perform data transfer on my usb pen drive using the default cfq io scheduler. the kernel load throughout the data transfer is around 6-7. when i switched to deadline and anticipatory i/o scheduler, the time taken for data transfer has decreased but the kernel load is the same. then i read this article(http://kerneltrap.org/node/3851) on kernel trap on how different devices need different i/o schedulers(hdisk need a cfq/as/deadline) and usb stick need noop scheduler. i wanted to know if the current linux kernel can load the best i/o scheduler for a device if i compile all the io schedulers as modules OR can i atleast configure my kernel manually to use cfq/as/deadline for hdisks and noop for usb disks ??
a part of the article at kernel trap:
"This is just an executive summary. I don't know the details.
Normally a disk scheduler tries to balance between these goals:
- fairness (let every process have its share of the access to disk)
- performance (try to serve requests close to current disk head position first, because seeking there is fastest)
- realtime (guarantee that a request is serviced in a given time)
A scheduler gets as input the list of sectors that processes have recently requested and which haven't yet given. It knows where the disk head currently is, and whatever other data it "remembers" from the past requests.
A typical scheduler is called cyclic elevator, where disk heads move from beginning of disk to the end of disk in one direction. Assume that you get some requests in a sorted queue, and you're going to satisfy them. So, you'll first filter the list of requests by deciding that you will not satisfy requests for sectors below your current head position. Then you'll simply go to the sector closest to your current position in your sorted list. So, crunch crunch crunch, you move from start of disk to the end of disk. When you reach the highest unsatisfied sector number, your cycle is over and you seek to the lowest unsatisfied sector. Rinse and repeat.
Linux 2.2 at least used the cyclic elevator if I remember right.
So, with these approximate goals in mind, we can look at the different schedulers available.
- deadline scheduler: this is a cyclic elevator but with a twist: requests are given a deadline by which they get served. When a request starts to look like it's going to expire, the kernel will skip intermediate sectors and move to that request, thus giving some realtime behaviour.
- AS scheduler: a cyclic elevator with waiting policy: after you service a request that looks like it might have future requests coming nearby, you pause even if there's more sectors in your work queue. The anticipatory scheduler literally anticipates more requests to follow on this track or very close by. How AS decides whether to anticipate is basically just lot of guesswork based on typical access patterns.
- cfq scheduler: different sort of stab at fairness. It's different from either of these two, and doesn't use cyclic elevator and has realtime guarantees and aggressively avoids starvation. It could be a good scheduler for multiuser systems.
- noop scheduler: just service next request in the queue without any algorithm to prefer this or that request.
You want to use noop scheduler on devices where there are no seeking penalty, such as flash drives. That's why USB stick wants noop. Unfortunately, harddisks are very mechanial beasts and their performance is highly controlled by their seeking abilities. All these schedulers above are really trying to figure out how to extract maximum performance off the harddisk without causing bad behaviour in other cases" |
|
Back to top |
|
|
Stever Apprentice
Joined: 01 Mar 2005 Posts: 151 Location: North Carolina
|
Posted: Wed Feb 28, 2007 6:35 pm Post subject: |
|
|
You can set or view the scheduler for each device through Code: | /sys/block/DEVICE/queue/scheduler | Just replace DEVICE with the name of the block device, for example to make sda use CFQ, Code: | echo cfq >/sys/block/sda/queue/scheduler |
HTH |
|
Back to top |
|
|
manojpm n00b
Joined: 11 Mar 2006 Posts: 33
|
Posted: Thu Mar 01, 2007 7:14 am Post subject: |
|
|
for this to work, should i build the schedulers as modules or directly into the kernel ?? |
|
Back to top |
|
|
Stever Apprentice
Joined: 01 Mar 2005 Posts: 151 Location: North Carolina
|
Posted: Thu Mar 01, 2007 2:01 pm Post subject: |
|
|
I've always built them into the kernel, but AFAIK there is no problem with compiing them as modules.
The only thing I can think of is that whichever scheduler you want to be the default has to be built-in. |
|
Back to top |
|
|
manojpm n00b
Joined: 11 Mar 2006 Posts: 33
|
Posted: Thu Mar 01, 2007 2:15 pm Post subject: |
|
|
is it difficult for the kernel do this automatically ?? i mean noop for usb devices and cfq for hdisks ,etc
also, the high load issue:
i use the system monitor applet that comes with gnome panel. whenever i do a usb data transfer or data transfer to my windows partitions (using ntfs3g 1.0), the "LOAD"(red color) goes up considerably (around 6 to 7 for usb transfer) . is this normal. why is this happening ? . also, what exactly does the LOAD indicate ? i dont mind an indepth detailed technical answer |
|
Back to top |
|
|
desultory Bodhisattva
Joined: 04 Nov 2005 Posts: 9410
|
Posted: Fri Mar 02, 2007 1:01 am Post subject: |
|
|
manojpm wrote: | is it difficult for the kernel do this automatically ?? i mean noop for usb devices and cfq for hdisks ,etc | I suggest using udev to run a command to poke the desired values into the appropriate files, it should not be difficult. |
|
Back to top |
|
|
RazielFMX l33t
Joined: 23 Apr 2005 Posts: 835 Location: NY, USA
|
Posted: Fri Mar 02, 2007 1:45 am Post subject: |
|
|
Wow... I'm definitely going to play with this! Thanks for all the great info! _________________ I am not anti-systemd; I am pro-choice. If being the latter makes you feel that I am the former, then so be it. |
|
Back to top |
|
|
|