View Single Post
Posts: 34 | Thanked: 50 times | Joined on Jun 2010
#292
Hi Guys,

I've tidied up the cgroup patch a lot. It's now a self-contained script, it no longer needs bash and it's a bit more effective when you run things from x-terminal (previously you had to run bash before anything in x-term would be cgrouped).

Code:
#!/bin/sh

if [ $USER != root ]; then
  echo "Error: you need to run this script as root."
  echo "Exiting..."
  exit 0
fi
      
mkdir /usr/local/sbin >/dev/null 2>&1
cat <<_EOF >/usr/local/sbin/cgroup_clean        
#!/bin/sh
if [ "$*" != "/user" ]; then
  rmdir /dev/cgroup/cpu/$*
fi
_EOF
chmod u+x /usr/local/sbin/cgroup_clean

cat <<_EOF >/etc/event.d/speedpatch 
description "speedpatch"

console none

start on MOUNTS_OK
stop on stopping xomap

script
    mkdir -p /dev/cgroup/cpu
    mount -t cgroup cgroup /dev/cgroup/cpu -o cpu,memory
    mkdir -m 0777 /dev/cgroup/cpu/user
    echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent
    echo "1" > /dev/cgroup/cpu/user/notify_on_release
end script
_EOF

if [ `cat /home/user/.profile |grep /dev/cgroup |wc -l` -eq 0 ] ; then
  cat <<_EOF >>/home/user/.profile
  if [ "\$PS1" ] ; then
    mkdir -p -m 0700 /dev/cgroup/cpu/user/\$\$  
    echo \$\$ > /dev/cgroup/cpu/user/\$\$/tasks
    echo "1" > /dev/cgroup/cpu/user/\$\$/notify_on_release
  fi
_EOF
fi

echo Patch complete, reboot to enable
To apply this, cut+paste the code into a file named "patchit.sh", chmod u+x on the file, then run it as root "./patchit.sh".

If you've applied the original cgroup patch, then you should remove the 4 cgroup lines from rc.local too. It probably won't hurt to have rc.local with the old patch enabled, it's just tidier to get rid of it. If you've got nothing other than cgroup in /etc/rc.local, then it's safe to remove the file entirely.

Usual disclaimer - use the patch at your own risk, I take no responsibility for anything bad that happens in your life.
 

The Following 4 Users Say Thank You to thingonaspring For This Useful Post: