Linux desktop responsiveness: a cgroups comparison

In 2010, the proposed ~200-line Linux scheduler patch prompted a discussion about improving desktop responsiveness under load. Lennart Poettering demonstrated a userspace approach using the existing kernel, with comparative results posted to the mailing list.

The discussion covered both implementation and testing. Lennart argued that session grouping was better managed in userspace, since graphical sessions do not necessarily correspond to TTYs. Linus emphasised measurements and observable improvements in interactive behaviour.

There was also a question about whether heavily parallel kernel builds represented typical desktop use. Con Kolivas discussed that concern, as did Lennart in the mailing-list thread.

Lennart’s example added the following to ~/.bashrc:

Shell
  if [ "$PS1" ] ; then  
          mkdir -m 0700 /sys/fs/cgroup/cpu/user/$$
          echo $$ > /sys/fs/cgroup/cpu/user/$$/tasks
  fi

It then required this command to be run as the superuser:

Shell
  mount -t cgroup cgroup /sys/fs/cgroup/cpu -o cpu
  mkdir -m 0777 /sys/fs/cgroup/cpu/user

These commands record the userspace example from that discussion. The broader question was where to manage process grouping and how to measure its effect on normal desktop workloads.