1 ========================= 2 Process Number Controller 3 ========================= 4 5 Abstract 6 -------- 7 8 The process number controller is used to allow 9 new tasks from being fork()'d or clone()'d aft 10 11 Since it is trivial to hit the task limit with 12 place, PIDs are a fundamental resource. As suc 13 preventable in the scope of a cgroup hierarchy 14 the number of tasks in a cgroup. 15 16 Usage 17 ----- 18 19 In order to use the `pids` controller, set the 20 pids.max (this is not available in the root cg 21 number of processes currently in the cgroup is 22 23 Organisational operations are not blocked by c 24 to have pids.current > pids.max. This can be d 25 be smaller than pids.current, or attaching eno 26 that pids.current > pids.max. However, it is n 27 policy through fork() or clone(). fork() and c 28 creation of a new process would cause a cgroup 29 30 To set a cgroup to have no limit, set pids.max 31 all new cgroups (N.B. that PID limits are hier 32 limit in the hierarchy is followed). 33 34 pids.current tracks all child cgroup hierarchi 35 superset of parent/child/pids.current. 36 37 The pids.events file contains event counters: 38 39 - max: Number of times fork failed in the cg 40 self or ancestors. 41 42 Example 43 ------- 44 45 First, we mount the pids controller:: 46 47 # mkdir -p /sys/fs/cgroup/pids 48 # mount -t cgroup -o pids none /sys/fs 49 50 Then we create a hierarchy, set limits and att 51 52 # mkdir -p /sys/fs/cgroup/pids/parent/ 53 # echo 2 > /sys/fs/cgroup/pids/parent/ 54 # echo $$ > /sys/fs/cgroup/pids/parent 55 # cat /sys/fs/cgroup/pids/parent/pids. 56 2 57 # 58 59 It should be noted that attempts to overcome t 60 fail:: 61 62 # cat /sys/fs/cgroup/pids/parent/pids. 63 2 64 # ( /bin/echo "Here's some processes f 65 sh: fork: Resource temporary unavailab 66 # 67 68 Even if we migrate to a child cgroup (which do 69 not be able to overcome the most stringent lim 70 parent's):: 71 72 # echo $$ > /sys/fs/cgroup/pids/parent 73 # cat /sys/fs/cgroup/pids/parent/pids. 74 2 75 # cat /sys/fs/cgroup/pids/parent/child 76 2 77 # cat /sys/fs/cgroup/pids/parent/child 78 max 79 # ( /bin/echo "Here's some processes f 80 sh: fork: Resource temporary unavailab 81 # 82 83 We can set a limit that is smaller than pids.c 84 processes from being forked at all (note that 85 pids.current):: 86 87 # echo 1 > /sys/fs/cgroup/pids/parent/ 88 # /bin/echo "We can't even spawn a sin 89 sh: fork: Resource temporary unavailab 90 # echo 0 > /sys/fs/cgroup/pids/parent/ 91 # /bin/echo "We can't even spawn a sin 92 sh: fork: Resource temporary unavailab 93 #
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.