LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Slackware64 14.1 control groups filesystem mount problem (https://www.linuxquestions.org/questions/slackware-14/slackware64-14-1-control-groups-filesystem-mount-problem-4175486807/)

Richard Cranium 12-04-2013 05:38 AM

Slackware64 14.1 control groups filesystem mount problem
 
In /etc/rc.d/rc.S, there's some code that attempts to autodetect and mount the control groups filesystem interface...

Code:

# Mount Control Groups filesystem interface:
if grep -wq cgroup /proc/filesystems ; then
  if [ -d /sys/fs/cgroup ]; then
    # See linux-*/Documentation/cgroups/cgroups.txt (section 1.6)
    # Check if we have some tools to autodetect the available cgroup controllers
    if [ -x /usr/bin/lssubsys -a -x /usr/bin/tr -a -x /usr/bin/sed ]; then
      # Mount a tmpfs as the cgroup filesystem root
      mount -t tmpfs -o mode=0755 cgroup_root /sys/fs/cgroup
      # Autodetect available controllers and mount them in subfolders
      controllers="$(lssubsys -a 2>/dev/null | tr '\n' ' ' | tr ',' ' ' | sed s/.$//)"
      for i in $controllers; do
        mkdir /sys/fs/cgroup/$i
        mount -t cgroup -o $i $i /sys/fs/cgroup/$i
      done
      unset i controllers
    else
      # We can't use autodetection so fall back mounting them all together
      mount -t cgroup cgroup /sys/fs/cgroup
    fi
  else
    mkdir -p /dev/cgroup
    mount -t cgroup cgroup /dev/cgroup
  fi
fi

The autodetection works just fine, as long as you don't have /usr on a separate partition. Sadly, I do have /usr in its own logical volume, so I get the fallback. The fallback, however, doesn't work for the current version of libvirt.

The following version of the above code appears to work with no issues on my setup and allows libvirt to function (changes in bold):
Code:

# Mount Control Groups filesystem interface:
if grep -wq cgroup /proc/filesystems ; then
  if [ -d /sys/fs/cgroup ]; then
    # See linux-*/Documentation/cgroups/cgroups.txt (section 1.6)
    # Check if we have some tools to autodetect the available cgroup controllers
    if [ -x /bin/cut -a -x /bin/tail ]; then
      # Mount a tmpfs as the cgroup filesystem root
      mount -t tmpfs -o mode=0755 cgroup_root /sys/fs/cgroup
      # Autodetect available controllers and mount them in subfolders
      controllers="$(cat /proc/cgroups | cut -f 1 | tail -n +2)"
      for i in $controllers; do
        mkdir /sys/fs/cgroup/$i
        mount -t cgroup -o $i $i /sys/fs/cgroup/$i
      done
      unset i controllers
    else
      # We can't use autodetection so fall back mounting them all together
      mount -t cgroup cgroup /sys/fs/cgroup
    fi
  else
    mkdir -p /dev/cgroup
    mount -t cgroup cgroup /dev/cgroup
  fi
fi

I assume this is so early in the boot process so that LVM and/or fuse could be controlled by a control group. I don't know the ramifications to moving the original block of code quoted above to after the filesystems are mounted.

ponce 12-04-2013 05:48 AM

I proposed that block to Pat as I'm a libvirt user too: from a rapid test yours seems to work fine as well :)

GazL 12-04-2013 09:56 AM

From what I understand of the topic I believe the cgroup filesystems are there as a control interface. I doubt anything in lvm or fuse would need to use them, so I wouldn't expect problems from moving that section to a little later in rc.S.


Oh, and UUOC! :tisk: Shame on you! ;)

controllers="$(cut -f 1 /proc/cgroups | tail -n +2)"

Richard Cranium 12-04-2013 01:02 PM

Quote:

Originally Posted by GazL (Post 5075271)
Oh, and UUOC! :tisk: Shame on you! ;)

controllers="$(cut -f 1 /proc/cgroups | tail -n +2)"

Oops :redface:

BTW, the "original" version that I have above is actually modified from stock, which is
Code:

controllers="$(lssubsys -a 2>/dev/null | tr '\n' ' ' | sed s/.$//)"
Unfortunately, lssubsys -a provides the subsystem list in a comma delimited form...
Code:

root@testbed:~# lssubsys -a
cpuset,cpu,cpuacct,devices,freezer,net_cls,blkio,perf_event
root@testbed:~#lssubsys -a 2>/dev/null | tr '\n' ' ' | sed s/.$//
cpuset,cpu,cpuacct,devices,freezer,net_cls,blkio,perf_event

..which won't work in the for loop anyways. So there's actually a bug in the original, unless the init scripts change IFS to include ",".

Richard Cranium 02-20-2014 10:39 PM

Integrating GazL's spanking :) to my change with the stuff that's changed from the stock /etc/rc.d/rc.S code in bold...
Code:

# Mount Control Groups filesystem interface:
if grep -wq cgroup /proc/filesystems ; then
  if [ -d /sys/fs/cgroup ]; then
    # See linux-*/Documentation/cgroups/cgroups.txt (section 1.6)
    # Check if we have some tools to autodetect the available cgroup controllers
    if [ -x /bin/cut -a -x /bin/tail ]; then
      # Mount a tmpfs as the cgroup filesystem root
      mount -t tmpfs -o mode=0755 cgroup_root /sys/fs/cgroup
      # Autodetect available controllers and mount them in subfolders
      controllers="$(cut -f 1 /proc/cgroups | tail -n +2)"
      for i in $controllers; do
        mkdir /sys/fs/cgroup/$i
        mount -t cgroup -o $i $i /sys/fs/cgroup/$i
      done
      unset i controllers
    else
      # We can't use autodetection so fall back mounting them all together
      mount -t cgroup cgroup /sys/fs/cgroup
    fi
  else
    mkdir -p /dev/cgroup
    mount -t cgroup cgroup /dev/cgroup
  fi
fi

...to make it easier to align your systems (if needed) to the above code.

Richard Cranium 02-20-2014 10:56 PM

Quote:

Originally Posted by Richard Cranium (Post 5075379)
Unfortunately, lssubsys -a provides the subsystem list in a comma delimited form...
Code:

root@testbed:~# lssubsys -a
cpuset,cpu,cpuacct,devices,freezer,net_cls,blkio,perf_event
root@testbed:~#lssubsys -a 2>/dev/null | tr '\n' ' ' | sed s/.$//
cpuset,cpu,cpuacct,devices,freezer,net_cls,blkio,perf_event

..which won't work in the for loop anyways. So there's actually a bug in the original, unless the init scripts change IFS to include ",".

Interestingly, my upgraded-from-14.0-to-14.1 system does not have a problem with the lssubsys -a providing output in comma delimited form (the command provides it in space delimited form) but both of my installed-brand-spanking-new-14.1-install systems do (the output is comma delimited on those systems)!


All times are GMT -5. The time now is 08:48 AM.