Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 434698
Collapse All | Expand All

(-)file_not_specified_in_diff (-27 / +26 lines)
Line  Link Here
0
-- cgconfig.initd.orig
0
++ cgconfig.initd
Lines 13-30 Link Here
13
RULES_FILE="/etc/cgroup/cgrules.conf"
13
RULES_FILE="/etc/cgroup/cgrules.conf"
14
14
15
# Support multiple mount points
15
# Support multiple mount points
16
MAX_INDEX=0
16
MOUNT_POINTS=
17
declare -a MOUNT_POINTS MOUNT_OPTIONS
18
17
19
move_all_to_init_class() {
18
move_all_to_init_class() {
20
	local i
19
	local i
21
	for i in $(seq 1 ${MAX_INDEX}); do
20
	for i in $MOUNT_POINTS; do
22
		cd ${MOUNT_POINTS[$i]}
21
		local mount_point=${i%:*}
22
		cd ${mount_point}
23
23
24
		if grep -qw ${MOUNT_POINTS[$i]} ${MOUNTS_FILE}; then
24
		if grep -qw "${mount_point}" ${MOUNTS_FILE}; then
25
			local directory
25
			local directory
26
			for directory in $(find . -depth -type d); do
26
			for directory in $(find . -depth -type d); do
27
				if [[ ${directory} != "." ]]; then
27
				if [ "${directory}" != "." ]; then
28
					# cat fails with "Argument list too long" error
28
					# cat fails with "Argument list too long" error
29
					sed -nu p < ${directory}/tasks > tasks
29
					sed -nu p < ${directory}/tasks > tasks
30
					rmdir ${directory}
30
					rmdir ${directory}
Lines 41-59 Link Here
41
parse_mounts() {
41
parse_mounts() {
42
	local device mount_point fs_type options other
42
	local device mount_point fs_type options other
43
	while read device mount_point fs_type options other; do
43
	while read device mount_point fs_type options other; do
44
		if grep -q ${device} <<< ${CGROUP_FS}; then
44
		if echo ${CGROUP_FS} | grep -q ${device}; then
45
			let MAX_INDEX++
45
			MOUNT_POINTS="${MOUNT_POINTS} ${mount_point}:${options}"
46
			MOUNT_POINTS[${MAX_INDEX}]=${mount_point}
47
			MOUNT_OPTIONS[${MAX_INDEX}]=${options}
48
		fi
46
		fi
49
	done < ${MOUNTS_FILE}
47
	done < ${MOUNTS_FILE}
50
}
48
}
51
49
52
umount_fs() {
50
umount_fs() {
53
	local i
51
	local i
54
	for i in $(seq 1 ${MAX_INDEX}); do
52
	for i in ${MOUNT_POINTS}; do
55
		umount ${MOUNT_POINTS[$i]}
53
		umount ${i%:*}
56
		rmdir ${MOUNT_POINTS[$i]}
54
		rmdir ${i%:*}
57
	done
55
	done
58
}
56
}
59
57
Lines 74-111 Link Here
74
72
75
	# Find default cgroup name in rules file
73
	# Find default cgroup name in rules file
76
	local default_cgroup
74
	local default_cgroup
77
	if [[ -f ${RULES_FILE} ]]; then
75
	if [ -f "${RULES_FILE}" ]; then
78
		local user controller
76
		default_cgroup=$(awk '$1 == "*" {print $3; exit}' ${RULES_FILE})
79
		read user controller default_cgroup <<< $(grep -m1 ^\* ${RULES_FILE})
77
		if [ $default_cgroup == "*" ]; then
80
		if [[ $default_cgroup == "*" ]]; then
81
			ewarn "${RULES_FILE} incorrect"
78
			ewarn "${RULES_FILE} incorrect"
82
			ewarn "Overriding it"
79
			ewarn "Overriding it"
83
			default_cgroup=
80
			default_cgroup=
84
		fi
81
		fi
85
	fi
82
	fi
86
	# Use predefined name if none was found
83
	# Use predefined name if none was found
87
	if [[ -z ${default_cgroup} ]]; then
84
	if [ -z "${default_cgroup}" ]; then
88
		default_cgroup=sysdefault
85
		default_cgroup=sysdefault
89
	fi
86
	fi
90
87
91
	# Create a default cgroup for tasks to return back to
88
	# Create a default cgroup for tasks to return back to
92
	local i
89
	local i
93
	for i in $(seq 1 ${MAX_INDEX}); do
90
	for i in $MOUNT_POINTS; do
91
		local mount_point=${i%:*}
92
		local mount_options=${i#*:}
94
		# Ignore if directory already exists
93
		# Ignore if directory already exists
95
		mkdir -p ${MOUNT_POINTS[$i]}/${default_cgroup}
94
		mkdir -p ${mount_point}/${default_cgroup}
96
		find ${MOUNT_POINTS[$i]}/ -name tasks | xargs  chmod a+rw
95
		find ${mount_point}/ -name tasks | xargs  chmod a+rw
97
		chmod go-w ${MOUNT_POINTS[$i]}/tasks
96
		chmod go-w ${mount_point}/tasks
98
97
99
		# Special rule for cpusets
98
		# Special rule for cpusets
100
		if grep -qw cpuset <<< ${MOUNT_OPTIONS[$i]}; then
99
		if echo ${mount_options} | grep -qw cpuset; then
101
			cat ${MOUNT_POINTS[$i]}/cpuset.cpus > ${MOUNT_POINTS[$i]}/${default_cgroup}/cpuset.cpus
100
			cat ${mount_point}/cpuset.cpus > ${mount_point}/${default_cgroup}/cpuset.cpus
102
			cat ${MOUNT_POINTS[$i]}/cpuset.mems > ${MOUNT_POINTS[$i]}/${default_cgroup}/cpuset.mems
101
			cat ${mount_point}/cpuset.mems > ${mount_point}/${default_cgroup}/cpuset.mems
103
		fi
102
		fi
104
103
105
		# Classify everything to default cgroup
104
		# Classify everything to default cgroup
106
		local j
105
		local j
107
		for j in $(ps --no-headers -eL o tid); do
106
		for j in $(ps --no-headers -eL o tid); do
108
			echo $j > ${MOUNT_POINTS[$i]}/${default_cgroup}/tasks 2>/dev/null
107
			echo $j > ${mount_point}/${default_cgroup}/tasks 2>/dev/null
109
		done
108
		done
110
	done
109
	done
111
110

Return to bug 434698