Skip Links

Network World

  • Social Web 
  • Email 
  • Close

(Comma separation for multiple addresses)
Your Message:

Kernel space: Fair user scheduling for Linux

A new set of Linux scheduler features would allocate CPU time fairly among the users on the system.
By Jonathan Corbet, LinuxWorld.com
October 23, 2007 07:37 PM ET
  • Share/Email
  • Tweet This
  • Comment
  • Print

The Completely Fair Scheduler (CFS) was merged for the 2.6.23 kernel. One CFS feature which did not get in, though, was the group scheduling facility. Group scheduling makes the CFS fairness algorithm operate in a hierarchical fashion: processes are divided into groups, and, within each group, processes are scheduled fairly against one another. At the higher level, each group as a whole is given a fair share of the processor. The grouping of processes is done in user space in a highly flexible manner; the control groups (formerly "process containers") mechanism allows a management daemon to classify processes according to almost any policy.

One of the reasons why group scheduling did not get into 2.6.23 is that the control groups patch was not ready for merging. The author had expected control groups to go in for 2.6.24, but, as of this writing, it is looking like that patch might still be under too much active development to get into the mainline. The group scheduling feature is not waiting, though; it has been merged for the 2.6.24 release. In the absence of control groups, the general group scheduling mechanism will not be available. Over the last few months, though, the group scheduler has evolved a new feature which will allow it to be used without control groups, and which implements what is likely to be the most common use case.

That feature is per-user scheduling: creating a separate group for each user running on the system and using those groups to give each user a fair share of the processor. Since the groups are created implicitly by the scheduler, there is no separate need for the control groups interface. Instead, if the "fair user" configuration option is selected, the per-user group scheduling will go into effect with no further intervention by the administrator required.

Of course, once the system provides fair per-user scheduling, administrators will immediately want to make it unfair by arranging for some users to get more CPU time than others. The age-old technique of raising the priority of that crucial administrative wesnoth process still works, but it is a crude and transparent tool. It would be much nicer to be able to tweak the scheduler so that certain users get a higher share of the CPU for the running of their crucial games video diagnostic tools.

To achieve such ends with the 2.6.24 scheduler, it will only be necessary to go to the new sysfs directory /sys/kernel/uids. There will be a subdirectory there for every active user ID on the system, and each subdirectory will contain a file called cpu_share. The integer value found in that file defaults to 1024. For the purposes of adjusting scheduling, all that really matters with the cpu_share value is its ratio between two users. If one user's cpu_share is set to 2048, that user will get twice as much CPU time as any one user whose value remains at the default 1024. The end result is that adjusting the scheduling of the CPU between users is quite easy for the administrator to do.

  • Share/Email
  • Tweet This
  • Comment
  • Print
Latest News
rssRss Feed
View more Latest News