This commit was manufactured by cvs2svn to create branch
[linux-2.6.git] / Documentation / ckrm / numtasks
1 Introduction
2 -------------
3
4 Numtasks is a resource controller under the CKRM framework that allows the 
5 user/sysadmin to manage the number of tasks a class can create. It also allows
6 one to limit the fork rate across the system.
7
8 As with any other resource under the CKRM framework, numtasks also assigns
9 all the resources to the detault class(/rcfs/taskclass). Since , the number
10 of tasks in a system is not limited, this resource controller provides a
11 way to set the total number of tasks available in the system through the config
12 file. By default this value is 128k(131072). In other words, if not changed,
13 the total number of tasks allowed in a system is 131072.
14
15 The config variable that affect this is sys_total_tasks.
16
17 This resource controller also allows the sysadmin to limit the number of forks
18 that are allowed in the system within the specified number of seconds. This
19 can be acheived by changing the attributes forkrate and forkrate_interval in 
20 the config file. Through this feature one can protect the system from being
21 attacked by fork bomb type applications.
22
23 Installation
24 -------------
25
26 1. Configure "Number of Tasks Resource Manager" under CKRM (see
27       Documentation/ckrm/installation). This can be configured as a module
28       also. But, when inserted as a module it cannot be removed.
29
30 2. Reboot the system with the new kernel. Insert the module, if compiled
31       as a module.
32
33 3. Verify that the memory controller is present by reading the file
34    /rcfs/taskclass/config (should show a line with res=numtasks)
35
36 Usage
37 -----
38
39 For brevity, unless otherwise specified all the following commands are
40 executed in the default class (/rcfs/taskclass).
41
42 As explained above the config file shows sys_total_tasks and forkrate
43 info.
44
45    # cd /rcfs/taskclass
46    # cat config
47    res=numtasks,sys_total_tasks=131072,forkrate=1000000,forkrate_interval=3600
48
49 By default, the sys_total_tasks is set to 131072(128k), and forkrate is set
50 to 1 million and forkrate_interval is set to 3600 seconds. Which means the
51 total number of tasks in a system is limited to 131072 and the forks are 
52 limited to 1 million per hour.
53
54 sysadmin can change these values by just writing the attribute/value pair
55 to the config file.
56
57    # echo res=numtasks,forkrate=100,forkrate_interval=10 > config
58    # cat config
59    res=numtasks,sys_total_tasks=1000,forkrate=100,forkrate_interval=10
60
61    # echo res=numtasks,forkrate=100,forkrate_interval=10 > config
62    # cat config
63    res=numtasks,sys_total_tasks=1000,forkrate=100,forkrate_interval=10
64
65 By making total_guarantee and max_limit to be same as sys_total_tasks, 
66 sysadmin can make the numbers in shares file be same as the number of tasks
67 for a class.
68
69    # echo res=numtasks,total_guarantee=131072,max_limit=131072 > shares
70    # cat shares
71    res=numtasks,guarantee=-2,limit=-2,total_guarantee=131072,max_limit=131072
72
73
74 Class creation 
75 --------------
76
77    # mkdir c1
78
79 Its initial share is don't care. The parent's share values will be unchanged.
80
81 Setting a new class share
82 -------------------------
83
84 'guarantee' specifies the number of tasks this class is entitled to get
85 'limit' is the maximum number of tasks this class can get.
86
87 Following command will set the guarantee of class c1 to be 25000 and the limit 
88 to be 50000
89
90    # echo 'res=numtasks,guarantee=25000,limit=50000' > c1/shares
91    # cat c1/shares      
92    res=numtasks,guarantee=25000,limit=50000,total_guarantee=100,max_limit=100
93
94 Limiting forks in a time period
95 -------------------------------
96 By default, this resource controller allows forking of 1 million tasks in
97 an hour.
98
99 Folowing command would change it to allow only 100 forks per 10 seconds
100
101    # echo res=numtasks,forkrate=100,forkrate_interval=10 > config
102    # cat config
103    res=numtasks,sys_total_tasks=1000,forkrate=100,forkrate_interval=10
104
105 Note that the same set of values is used across the system. In other words,
106 each individual class will be allowed 'forkrate' forks in 'forkrate_interval'
107 seconds.
108
109 Monitoring
110 ----------
111
112 stats file shows statistics of the number of tasks usage of a class
113 [root@localhost taskclass]# cat stats
114 Number of tasks resource:
115 Total Over limit failures: 0
116 Total Over guarantee sucesses: 0
117 Total Over guarantee failures: 0
118 Maximum Over limit failures: 0
119 Maximum Over guarantee sucesses: 0
120 Maximum Over guarantee failures: 0
121 cur_alloc 38; borrowed 0; cnt_guar 131072; cnt_limit 131072 cnt_unused 131072, unused_guarantee 100, cur_max_limit 0
122