kernel-switcher and cgroups

Discussion in general that pertains to Sabayon Linux - Must Pertain to Sabayon Linux

Moderator: Moderators

kernel-switcher and cgroups

Postby jyc » Wed Dec 26, 2012 22:45

Hello,

I was wondering if it were possible to enable cgroups while still being able to use kernel switcher - namely, if cgroups and kernel configuration settings can be made persistent and automatic without having to manually recompile the kernel every time (if I have to, I will).

I ask because I need to enable enable some extra kernel configuration to use cgroups on my Sabayon install, according to lxc-checkconfig:

Code: Select all
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: missing
Network namespace: enabled
Multiple /dev/pts instances: missing

--- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: missing
Cgroup cpuset: enabled

--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
File capabilities: enabled

Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/sbin/lxc-checkconfig



The missing things are those I need to enable in the kernel configuration.

if anyone could lend some help, that'd be much appreciated. Thanks!
jyc
Baby Hen
 
Posts: 5
Joined: Thu Aug 02, 2012 3:41

Re: kernel-switcher and cgroups

Postby sabayonino » Thu Dec 27, 2012 0:08

cgroups is enabled by default

see :
Code: Select all
# mount | grep cgroup


and

Code: Select all
# cat /proc/cgroups
User avatar
sabayonino
Sagely Hen
 
Posts: 1577
Joined: Sun Sep 21, 2008 1:12
Location: Italy

Re: kernel-switcher and cgroups

Postby jyc » Thu Dec 27, 2012 0:28

Sorry, I should have written it more clearly. I already know that cgroups is installed, but to enable it I meant to enable the full featureset, i.e., why I posted the lxc-checkconfig. If you look at that, you see that user namespaces, multiple /dev/pts instances, and the cgroup memory controller are not enabled in the default kernel configuration.

I ask because I need to enable enable some extra kernel configuration to use cgroups on my Sabayon install, according to lxc-checkconfig... if cgroups and kernel configuration settings can be made persistent and automatic without having to manually recompile the kernel every time (if I have to, I will).
jyc
Baby Hen
 
Posts: 5
Joined: Thu Aug 02, 2012 3:41

Re: kernel-switcher and cgroups

Postby sabayonino » Fri Jan 04, 2013 13:29

Hi

dev-libs/libcgroup in portage tree can solve your prob

Code: Select all
dev-libs/libcgroup
     Available versions:  ~0.38 ~0.39_rc1 {{+daemon debug pam static-libs +tools}}
     Homepage:            http://libcg.sourceforge.net/
     Description:         Tools and libraries to configure and manage kernel control groups



/etc/cgconfig.conf
Code: Select all
mount {
blkio = /sys/fs/cgroup;
cpu = /sys/fs/cgroup;
cpuacct = /sys/fs/cgroup;
cpuset = /sys/fs/cgroup;
memory = /sys/fs/cgroup;
}

group default {
perm {
task {
uid = mythtv;
gid = mythtv;
}
admin {
uid = mythtv;
gid = mythtv;
}
}
blkio {
blkio.weight = 200;
}
cpu {
cpu.shares = 1024;
}
cpuset {
cpuset.cpus = 0-1;
cpuset.mems = 0;
}
memory {
memory.swappiness = 60;
}
}

group frontend {
perm {
task {
uid = mythtv;
gid = mythtv;
}
admin {
uid = mythtv;
gid = mythtv;
}
}
blkio {
blkio.weight = 1000;
}
cpu {
cpu.shares = 8192;
}
cpuset {
cpuset.cpus = 0-1;
cpuset.mems = 0;
}
memory {
memory.limit_in_bytes = 1G;
memory.memsw.limit_in_bytes = 1152M;
memory.swappiness = 1;
}
}

group high {
perm {
task {
uid = mythtv;
gid = mythtv;
}
admin {
uid = mythtv;
gid = mythtv;
}
}
blkio {
blkio.weight = 500;
}
cpu {
cpu.shares = 8192;
}
cpuset {
cpuset.cpus = 0-1;
cpuset.mems = 0;
}
memory {
memory.limit_in_bytes = 512M;
memory.memsw.limit_in_bytes = 640M;
memory.swappiness = 1;
}
}

group idle {
perm {
task {
uid = mythtv;
gid = mythtv;
}
admin {
uid = mythtv;
gid = mythtv;
}
}
blkio {
blkio.weight = 100;
}
cpu {
cpu.shares = 256;
}
cpuset {
cpuset.cpus = 0-1;
cpuset.mems = 0;
}
memory {
memory.limit_in_bytes = 768M;
memory.memsw.limit_in_bytes = 896M;
memory.swappiness = 60;
}
}

group mythtv {
perm {
task {
uid = mythtv;
gid = mythtv;
}
admin {
uid = mythtv;
gid = mythtv;
}
}
blkio {
blkio.weight = 333;
}
cpu {
cpu.shares = 2048;
}
cpuset {
cpuset.cpus = 0-1;
cpuset.mems = 0;
}
memory {
memory.swappiness = 20;
}
}



/etc/cgrules.conf
Code: Select all
*:emerge * idle/
*:igdaemon * mythtv/
*:mplayer * high/
*:mythbackend * high/
*:mythcommflag * idle/
*:mythfrontend * frontend/
*:rsync * idle/
*:/usr/bin/X * mythtv/
*:xine * high/
harley * idle/
mythtv * mythtv/
portage * idle/
* * default/
# End of file


/etc/init.d/cgconfig
Code: Select all
#!/sbin/runscript
#
# Control Groups Configuration Startup
#
# This script runs the cgconfigparser utility to parse and setup
# the control group filesystem. It uses ${CONFIG_FILE}
# and parses the configuration specified in there.
#
CGCONFIGPARSER="/usr/sbin/cgconfigparser"
CONFIG_FILE=${CONFIG_FILE:-"/etc/cgconfig.conf"}
RULES_FILE="/etc/cgrules.conf"

depend() {
need localmount
after cron dhcp lircd lm_sensors mdadm monit mysql mythbackend nagios net netmount nfs nfsmount npcd ntp-client ntpd rsyncd smartd sshd udev-postmount vsftpd
}

create_default_groups() {
declare defaultcgroup

if [ -f /etc/cgrules.conf ]
then
read user ctrl defaultcgroup <<< \
$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)
if [[ -n $defaultcgroup && $defaultcgroup = "*" ]]
then
defaultcgroup=
fi
fi

if [ -z $defaultcgroup ]
then
defaultcgroup=sysdefault/
fi

#
# Find all mounted subsystems and create comma-separated list
# of controllers.
#
controllers=$(lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//)
echo "stop0"
#
# Create the default group, ignore errors when the default group
# already exists.
#
cgcreate -g $controllers:$defaultcgroup 2>/dev/null

#
# special rule for cpusets
#

if echo $controllers | grep -q -w cpuset; then
cpus=$(cgget -nv -r cpuset.cpus /)
cgset -r cpuset.cpus=$cpus $defaultcgroup
mems=$(cgget -nv -r cpuset.mems /)
cgset -r cpuset.mems=$mems $defaultcgroup
fi

#
# Classify everything to default cgroup. Ignore errors, some processes
# may exit after ps is run and before cgclassify moves them.
#
cgclassify -g $controllers:$defaultcgroup `ps --no-headers -eL o tid` \
2>/dev/null || :
}

classify_all() {
cgclassify "$@" $(ps --no-headers -eL o tid) 2>/dev/null
}

start() {
ebegin "Starting cgconfig service"

# Mount filesystem and create cgroups
if ! ${CGCONFIGPARSER} -l ${CONFIG_FILE} >/dev/null; then
eend 1 "Failed to parse ${CONFIG_FILE}"
return 1
fi

if [ $CREATE_DEFAULT == "yes" ]; then
create_default_groups >/dev/null
fi
if [ $CLASSIFY == "yes" ]; then
classify_all >/dev/null
fi

eend 0
}

stop() {
ebegin "Stopping cgconfig service"

# Gentoo deptree bug work around.
/usr/local/bin/classify_default.sh

# Cgclear hang bug work around.
kill_cgclear.sh >/dev/null 2>&1 &

cgclear >/dev/null
eend $?
}


Hope will help you
User avatar
sabayonino
Sagely Hen
 
Posts: 1577
Joined: Sun Sep 21, 2008 1:12
Location: Italy


Return to Sabayon Linux General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest