How to add an I/O Scheduler to your kernel

How to add an I/O Scheduler to your kernel:

Praise God, another succesful addition to the TBLTE kernel was that of adding the FIOPS I/O scheduler to the kernel. What is an I/O scheduler? Well it is the part of the kernel that handles, or schedules, input and output. Particularly, this has to do with writing and reading to and from media, like your hard drive, flash drive, etc.

So, how do we do that? How do we add I/O schedulers to our kernel?

Well, for the TBLTE kernel, I will show you what I did, and you can add to your kernel similarly.

Go to the block folder in your kernel source. The first thing that you need to do is add the fiops-iosched.c file. Whatever I/O scheduler you want to add will be named like this: {NAME-iosched.c} you can search Google or github for them, or take them from my source if you would like.

Once you put your fiops-iosched.c file in your kernel’s ./block/ folder, you can now edit two other files in that folder. You need to add the new scheduler to the make file, so it knows to make it, you can do that like so:

Open ./block/Makefile and add this line after the other *-iosched.o lines:

[CODE]
obj-$(CONFIG_IOSCHED_FIOPS) += fiops-iosched.o
[/CODE]

Notice that it just uses the name of the iosched file, but with an “.o” extension instead of a “.c” extension. The “.c” file you added earlier will create a “.o” (object) file that the Kernel needs to use to “make” the kernel.

Now edit the ./block/Kconfig.iosched file like so:

[CODE]
config IOSCHED_FIOPS
tristate “FIOPS I/O scheduler”
default y
—help—
The FIOPS I/O scheduler. WJH.
[/CODE]

This way, when you are moddifying your configuration, you can select to build it. Notice that it is a “default y”, essentially, I am telling the config file creator to allways assume I want to build this, unless I choose not to. You can also eddit the “—help—” portion to say anything you want. I put my initials in there so I can find it easily with the search tool.

Now open your configuration file. For the stock builds, that would be ./arch/arm/configs/ap88084_sec_defconfig, and add this line:

[CODE]
CONFIG_IOSCHED_FIOPS=y
[/CODE]

Note that you could also do this through

[CODE]$ make menuconfig [/CODE]

.
You may also note, since we gave it a “default y” in the Kconfig.iosched file, we don’t actually need to add this to our configs, as it will be built by default, but I like to declare what I am building in my configs so I remember what I am doing.

There you go! Now when you build your kernel again, the FIOPS I/O scheduler will be added in. It is remarkably simple, just the way I like it. You can read the commit here: [url]https://github.com/alaskalinuxuser/kernel_samsung_tblte/commit/f80320a895612bd1379ca789f88f1d6dfd6e68f9[/url]

Linux – keep it simple.

 

Adding a new I/O scheduler to your Kernel

In my continuing effort to learn about kernel modification, I was blessed to be able to add a new I/O scheduler to my kernel. To be honest, the ArcTeam kernel that I started with was already well equiped in the I/O scheduler department, but as this is a learning experience, I just had to add one more!

The kernel already included noop, deadline, row, cfq, fiops, sio, and bfq. There really were not many options left of what to add, and of the few that remained there was some ambiguity of quality. However, I chose the VR I/O scheduler, and got to work.

First, I added the new I/O scheduler to block/Kconfig.iosched, like so:

[CODE]
config IOSCHED_VR
tristate “VR I/O scheduler”
default y
—help—
The VR I/O scheduler gives the best benchmark readings, but is
somewhat unstable/unreliable for daily use.
[/CODE]

This makes it an option that can be selected when you are compiling the kernel, such as when using

[CODE]$ make menuconfig[/CODE]

.

Next on the agenda was adding it into the block/Makefile:

[CODE]
+obj-$(CONFIG_IOSCHED_VR) += vr-iosched.o
[/CODE]

Note that the file here is an .o (object file) but the actual file we will add is the block/vr-iosched.c file. That is because the makefile needs the object made FROM the c file, not the c file itself.

Finally, we copy our block/vr-iosched.c file into the block directory. It is over 400 lines long, or I would post it here. Surprisingly simple! I like to keep things simple!

You can even check it out on my github at: https://github.com/alaskalinuxuser/kernel_samsung_jf/commit/904abfe90be7e27908dc0ac8f03d5f8bbfd37714

Linux – keep it simple.

 

How to check your governor and I/O scheduler from the command line

The other day, when working through some issues with kernel governors and I/O schedulers, I realized that I was a bit rusty on where to find them from the command line. After some searching and tinkering, I thought I might save some internet searcher the long and winding road to find this out.

From the command line:

[CODE]
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand userspace powersave performance

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
ondemand

$ cat /sys/block/sda/queue/scheduler
noop [deadline] cfq
[/CODE]

It’s a pretty simple trick to just read what is written in the /sys directory. As you can see here, my laptop system is running the ondemand kernel governor with the deadline I/O scheduler. If you are using this for yourself, you can check any of the cpu’s and drives by inputing them instead of the cpu0 and sda which I used here. This works on just about anything running a Linux kernel, from computers to cell phones like Android.

Linux – keep it simple.