File: setup-cgroups-etc

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-13.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 57,848 kB
  • sloc: ansic: 432,690; java: 87,068; cpp: 31,958; sh: 29,445; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,705; csh: 3,934; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (71 lines) | stat: -rwxr-xr-x 2,569 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh

# Set up or take down filesystems for cgroups, cpusets etc. according
# to the argument ("start" or "stop").  This is intended to be run
# by the execd rc script.

# We have an "sge" level under the cgroup and cpuset mount points, and
# SGE will only firkle with such resource-control mechanisms if the
# relevant directory exists.  The sge directories are owned by the
# admin user for convenience of execd.

# Fixme:  Do something about /sys/fs/cgroup with prefixed files.

[ "$(uname -s)" = Linux -a $# -eq 1 ] || exit 0

PATH=/sbin:/usr/sbin:/bin:/usr/bin

adminuser=$(awk '/^admin_user/ {print $2}' $SGE_ROOT/$SGE_CELL/common/bootstrap)

cpuset_mnt=/dev/cpuset
sge_cpuset=$cpuset_mnt/sge
cgroup_mnt=/cgroups
sge_cgroup=$cgroup_mnt/sge

# There's probably no point in reporting errors.
# Would the directories be better owned by sgeadmin than root, when
# we use sgeadmin?

if [ "$1" != stop ]; then
    # We can use cpusets under older Linux versions (fixme: from
    # when?), specifically in Red Hat 5, where we don't have cgroups.
    # The documented recipe with cgroups is
    #   mount -t cgroup -ocpuset cpuset /dev/cpuset
    # but the cpuset filesystem type still works.
    if [ -f /proc/self/cpuset ]; then
        # We may already be set up, but just plough on and maybe re-do
        # things or ignore failure when they've been done.'
        mkdir -p $cpuset_mnt
        mount -t cpuset none $cpuset_mnt >/dev/null 2>&1
        mount | grep -q cpuset || rmdir $cpuset_mnt
        if [ ! -d $sge_cpuset ]; then
            mkdir $sge_cpuset 2>/dev/null
            # These aren't inherited, and mems needs to be set to add
            # a task anywhere below.
            /bin/cp $cpuset_mnt/mems $cpuset_mnt/cpus $sge_cpuset
            # Avoid a release agent for now
#             if ! /usr/bin/test -x /sbin/cpuset_release_agent; then
#                 cat <<EOF >/sbin/cpuset_release_agent
# #!/bin/sh
# exec rmdir $cpuset_mnt$1
# EOF
#                 chmod +x /sbin/cpuset_release_agent
#             fi
            chown -R $adminuser $sge_cpuset
        fi
    fi

    false &&                    # not yet
    if [ -f /proc/self/cgroup ]; then
        mkdir -p $cgroup_mnt
        for type in cpuacct memory freezer; do
            mount -t cgroup -o$type none $cgroup_mnt
        done
        mount | grep -q "none on $cgroup_mnt type cgroup" &&
        mkdir $sge_cgroup 2>/dev/null ||
        rmdir $cgroup_mnt 2>/dev/null
        [  -d $sge_cgroup ] && chown -R $adminuser $sge_cgroup
    fi
else
    : # no take down yet
fi