3 # cpusets Create/remove cpusets
5 # chkconfig: 12345 01 99
6 # description: Creates/Removes all cpu sets configured to \
12 . /etc/sysconfig/system
14 if [ "${CPUSETS:-no}" = "no" ]; then
22 # Source function library.
23 . /etc/rc.d/init.d/functions
27 if grep -q "/dev/cgroup" /proc/mounts ; then
29 elif grep -q "/dev/cpuset" /proc/mounts ; then
33 if [ -n "${CGDIR}" ]; then
34 if [ -e ${CGDIR}/cpuset.cpus ]; then
36 elif [ ! -e ${CGDIR}/cpus ]; then
37 nls "ERROR: CGROUP/CPUSET mounted in a way I can't recognize" >&2
43 [ -n "${CGDIR}" ] && return
45 if grep -q cgroup /proc/filesystems 2>/dev/null ; then
46 mkdir -p /dev/cpuset 2>/dev/null
47 mount -t cgroup none /dev/cpuset -ocpuset
49 elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
50 mkdir -p /dev/cpuset 2>/dev/null
51 mount -t cpuset none /dev/cpuset
54 nls "ERROR: CGROUP/CPUSET support not enabled in kernel" >&2
61 local CPUS MEMS CPU_EXCLUSIVE MEM_EXCLUSIVE NOTIFY_ON_RELEASE TASKS
63 . /etc/sysconfig/cpusets/cpuset-$i
65 if mkdir "${CGDIR}/${NAME}" >/dev/null 2>&1 ; then
66 [ -n "$CPUS" ] && echo "$CPUS" >"${CGDIR}/${NAME}/${CSUBSYS}cpus"
67 [ -n "$MEMS" ] && echo "$MEMS" >"${CGDIR}/${NAME}/${CSUBSYS}mems"
68 [ -n "$CPU_EXCLUSIVE" ] && echo "$CPU_EXCLUSIVE" >"${CGDIR}/${NAME}/${CSUBSYS}cpu_exclusive"
69 [ -n "$MEM_EXCLUSIVE" ] && echo "$MEM_EXCLUSIVE" >"${CGDIR}/${NAME}/${CSUBSYS}mem_exclusive"
70 [ -n "$VIRTUALIZE" ] && echo "$VIRTUALIZE" >"${CGDIR}/${NAME}/${CSUBSYS}virtualize"
71 [ -n "$NOTIFY_ON_RELEASE" ] && echo "$NOTIFY_ON_RELEASE" >"${CGDIR}/${NAME}/${CSUBSYS}notify_on_release"
72 [ -n "$TASKS" ] && echo "$TASKS" >"${CGDIR}/${NAME}/tasks"
79 local CPUS MEMS CPU_EXCLUSIVE MEM_EXCLUSIVE NOTIFY_ON_RELEASE TASKS
81 . /etc/sysconfig/cpusets/cpuset-$i
83 # This MUST be rmdir (not rm -rf)
84 if rmdir "${CGDIR}/${NAME}" >/dev/null 2>&1 ; then
92 if [ $(cat "${CGDIR}/$1/tasks" 2>/dev/null | wc -c) -eq 0 ] ; then
102 rc_splash "bootcpusets start"
104 for i in $cpusets_boot; do
105 show "$(nls -n "Creating cpuset %s" "$i")"
106 if cpuset_create $i ; then
113 touch /var/lock/subsys/cpusets
117 for i in $cpusets_boot; do
118 show "$(nls -n "Removing cpuset %s" "$i")"
120 if cpuset_empty $i; then
121 if cpuset_remove $i; then
131 rm -f /var/lock/subsys/cpusets >/dev/null 2>&1
134 # Get list of config files
135 # ignores editor backup files and rpm blackups
138 for a in /etc/sysconfig/cpusets/$match; do
140 *rpmorig|*rpmnew|*rpmsave|*~|*.orig)
150 cpuset_files="$(cpuset_configs 'cpuset-*')"
152 for i in $cpuset_files; do
153 ONBOOT=""; . "$i" 2>/dev/null
154 is_yes "$ONBOOT" && echo "${i##*/cpuset-}"
158 # See how we were called.
168 nls "Configured cpusets:"
171 nls "Currently empty cpusets:"
172 for i in $(ls /dev/cpuset 2>/dev/null); do
173 if [ -d ${CGDIR}/$i ]; then
174 cpuset_empty $i && echo $i
178 nls "Currently active cpusets:"
179 for i in $(ls /dev/cpuset 2>/dev/null); do
180 if [ -d ${CGDIR}/$i ]; then
181 cpuset_empty $i || echo $i
192 msg_usage "$0 {start|stop|restart|status}"