# 2.6 kernel scheduler questions

## wrc1944

In the 2.6 kernel config files, and when you run make xconfig, under General setup, there are several scheduler options, which when you run make xconfig, and before you load an old config file, they are all checked "y." 

# CONFIG_IOSCHED_NOOP is not set

# CONFIG_IOSCHED_AS is not set

CONFIG_IOSCHED_DEADLINE=y

CONFIG_IOSCHED_CFQ=y

This seems to change between  the vanilla kernel, and if you patch with -mm, or whatever, which of course is understandable, as for example, the mm patches add the CFQ scheduler option.

Anyway, my question is regarding how many schedulers should be set. I would think only one would be needed with each kernel, chosen for a specific usage, and others would either conflict, or not be used, and thus needlessly increase the kernel size. Can anyone please enlighten me as to what is the best policy regarding the number of schedulers set "y," that is, only one, or if multiples are OK, and would be used as needed, or just what is the correct usage? 

When I patched with an -ck version, it seemed to add these two, so I'm a little confused on these points.

CONFIG_IOSCHED_DEADLINE=y

CONFIG_IOSCHED_CFQ=y

wrc1944

----------

## gringo

Well, you can have them all set to yes, but only one will be used AFAIK. I had them all checked, to see which one performs better on my system. 

Actually im using the default one. In ck & mm the default is cfq, in vanilha kernels the default is anticipatory.

You can change the defaults by adding elevator=yourscheduler to the kernel image in your bootloader.

Don´t sure about this, but i believe you cannot change the scheduler while the system is running. Maybe anyone can enlighten me too...

TIA

----------

## spb

 *gringo wrote:*   

> Don´t sure about this, but i believe you cannot change the scheduler while the system is running. Maybe anyone can enlighten me too...

 There's a patch named 'elv-select' around that lets you do exactly that. It creates a sysfs entry for each block device in your system that lets you change the I/O scheduler for that device at run-time. So you could run CFQ on a hard disk and AS on a CD-ROM, for example. It was in love-sources a while ago, but seems to have been dropped in the more recent releases.

----------

## gringo

Yes, you are right, i forget that completly. 

Its available here http://www.kerneltrap.org/~npiggin/elevator/, but it seems to be quite old.

----------

## steel300

The elv-select patches have lost interest. It's a great concept, but recent (drastic) changes have cuased the elv-select patches to oops more often than not.

----------

## danone

steel when will you release th love-sources for final 2.6.5 kernel?

----------

## steel300

 *danone wrote:*   

> steel when will you release th love-sources for final 2.6.5 kernel?

 

OneOfOne's handling that while my dekstop rebuilds. I had a run in with my BIOS that didn't prove helpful. He's already released it and we just fixed the framebuffer issues, as well as the nvidia issues. I'll be back by the end of the week to resume my seat at the head of love-sources.

----------

## wrc1944

Thanks to all for the info. One more question.

OK-     I had deadline, and cfq schedulers set "y" in my 2.6.5-mm1 kernel. I booted, checked dmesg, and I was using the deadline scheduler.

Then I added "elevator=cfq to my 2.6.5-mm1 kernel line in grub, and rebooted. This time, dmesg indicates I'm now using the cfq scheduler.

So my conclusions are:

1. You can have 2 or more schedulers set "y" in your kernel config file, and when booting, the kernel, if not specifically set to default to a specific scheduler (like the vanilla defaults to anticipatory), defaults to the first one set  to "y" in the config file, in my case, deadline. (I guess when building the kernel, the config file sets the order of the schedulers built into the kernel according to the config file scheduler list?)

2. The grub kernel line addendum of elevator=scheduler overrides any default any particular kernel might have set.

3. You can't have more than one scheduler operating at one time.

Are these conclusions correct, or am I still missing something in my understanding?

wrc1944

----------

## steel300

 *wrc1944 wrote:*   

> Thanks to all for the info. One more question.
> 
> OK-     I had deadline, and cfq schedulers set "y" in my 2.6.5-mm1 kernel. I booted, checked dmesg, and I was using the deadline scheduler.
> 
> Then I added "elevator=cfq to my 2.6.5-mm1 kernel line in grub, and rebooted. This time, dmesg indicates I'm now using the cfq scheduler.
> ...

 

The kernel has them in a specific order. I don't believe it's alphabetical, but I could be wrong. Either way, the kernel will default to a certain scheduler.

 *wrc1944 wrote:*   

> 
> 
> 2. The grub kernel line addendum of elevator=scheduler overrides any default any particular kernel might have set.
> 
> 

 

That is correct

 *wrc1944 wrote:*   

> 
> 
> 3. You can't have more than one scheduler operating at one time.
> 
> 

 

For now, that is right. Once Nick gets back on elv-select, you can have different scheduler for different devices.

 *wrc1944 wrote:*   

> 
> 
> Are these conclusions correct, or am I still missing something in my understanding?
> 
> wrc1944

 

Your conclusions are, for the most part, correct.

----------

## wrc1944

steel300,

Thanks for the confirmation on my points about schedulers.

IIRC, in make xconfig, they aren't listed alphabetical, and I know with my -mm kernels, where I had deadline and cfq set "y," even though mm     defaults to cfq, deadine is right above cfq in the list, and since I also had deadline set "y," when I booted, it used deadline. I would assume if I had anticipatory and cfq set "y," mm would use anticipatory instead of the cfq default. 

Here's from my current 2.6.5-mm1 config file.

CONFIG_EMBEDDED=y

# CONFIG_KALLSYMS is not set

# CONFIG_FUTEX is not set

# CONFIG_EPOLL is not set

# CONFIG_IOSCHED_NOOP is not set

# CONFIG_IOSCHED_AS is not set

CONFIG_IOSCHED_DEADLINE=y

CONFIG_IOSCHED_CFQ=y

# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set

Thanks for the clarifications,

wrc1944

----------

## Jake

 *steel300 wrote:*   

> The elv-select patches have lost interest. It's a great concept, but recent (drastic) changes have cuased the elv-select patches to oops more often than not.

 

That's strange. It works on both my P4 laptop and my Athlon XP desktop with kernel 2.6.5-rc2. I've never had it oops. MM probably breaks it, though.

----------

## steel300

 *Jake wrote:*   

>  *steel300 wrote:*   The elv-select patches have lost interest. It's a great concept, but recent (drastic) changes have cuased the elv-select patches to oops more often than not. 
> 
> That's strange. It works on both my P4 laptop and my Athlon XP desktop with kernel 2.6.5-rc2. I've never had it oops. MM probably breaks it, though.

 

Are you using any USB devices? Mainly mass storage devices a live a USB memory stick, or a portabele MP3 player or the like? It oopses when you take them out.

----------

## gringo

Has this been fixed in the 2.6.5 kernel ?? 

Didnt try them so far, will give it a shot this weekend.

TIA

----------

## Jake

 *steel300 wrote:*   

>  *Jake wrote:*    *steel300 wrote:*   The elv-select patches have lost interest. It's a great concept, but recent (drastic) changes have cuased the elv-select patches to oops more often than not. 
> 
> That's strange. It works on both my P4 laptop and my Athlon XP desktop with kernel 2.6.5-rc2. I've never had it oops. MM probably breaks it, though. 
> 
> Are you using any USB devices? Mainly mass storage devices a live a USB memory stick, or a portabele MP3 player or the like? It oopses when you take them out.

 

I've tested the latop quite a bit with a memory stick. I'm reasonably sure it doesn't cause problems on my dekstop either. The only reason I'm not using it on my desktop now is because I thought it was causing probelms with my memory stick (not oopses, just making it not work), but it turned out to be udev not auto-loading the sg module, while devfs on the latop does.

----------

## Souperman

Is there a doc somewhere that explains what a scheduler does and describes the differences between/pros & cons of the various schedulers available for 2.6?   :Confused: 

----------

## steel300

 *Souperman wrote:*   

> Is there a doc somewhere that explains what a scheduler does and describes the differences between/pros & cons of the various schedulers available for 2.6?  

 

Anticipatory Scheduler - Read/write data, then wait. If a read comes in that's close to the current position of the head, read/write that data. Once the wait period has passed, move on to the next process that has asked for the disk.

CFQ - Completely Fair Queueing of processes to disk time. No process can hog the disk. All processes get the same amount of time to use the disk.

Deadline - Each process gets a deadline as to when it has to finisch using the disk. If the deadline has passed, that process monopolizes the disk. Otherwise, it's just a round robin of who gets the disk when.

Noop - No scheduler logic at all. A process asks for the disk, if it's available, it gets to use it. If it's not available, it waits.

----------

## steel300

 *Jake wrote:*   

>  *steel300 wrote:*    *Jake wrote:*    *steel300 wrote:*   The elv-select patches have lost interest. It's a great concept, but recent (drastic) changes have cuased the elv-select patches to oops more often than not. 
> 
> That's strange. It works on both my P4 laptop and my Athlon XP desktop with kernel 2.6.5-rc2. I've never had it oops. MM probably breaks it, though. 
> 
> Are you using any USB devices? Mainly mass storage devices a live a USB memory stick, or a portabele MP3 player or the like? It oopses when you take them out. 
> ...

 

It has to be mm that broke it then. I'll keep trying to get it.

----------

## Jake

 *steel300 wrote:*   

> It has to be mm that broke it then. I'll keep trying to get it.

 

That wouldn't surprise me, considering MM also broke reiser4.

----------

