-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME
169 lines (145 loc) · 7.95 KB
/
README
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
cgroup_tests
============
A very simple cgroup test program which tortures the cgroup
filesystem a bit.
How it works
------------
Initially it creates a random directory tree and places a memory_hog
(or any other program) to a cgroup. After that it moves them around
and removes/creates new cgroups at random places. For each child
which dies a new one is created.
cgroup_tests is not really smart in creating the trees. It just
tries to as chaotic as possible and stress testing the API.
How to build
------------
The programs depend on asprintf, so you probably need a glibc for
getting building and running. Apart of this, no additional special
dependencies exists.
$ make
gcc -Wall -g -O0 cgroup_tests.c -o cgroup_tests
gcc -Wall -g -O0 memory_hog.c -o memory_hog
gcc -Wall -g -O0 dir_walker.c -o dir_walker
Usage
-----
A few simple examples
# ./cgroup_tests ./memory_hog
will create 100 cgroups under /sys/fs/cgroup/memory and 50 memory hogs
and shuffles them around for 60 seconds. Each memory hog allocates
10M, write a patter, waits a second and releases the memory again. 5
times repeated.
# ./cgroup_tests ./memory_hog
mkdir 791 rmdir 690 moved 921 forked 65 reaped 15
[root@test-kvm memory]# cd /sys/fs/cgroup/memory && tree -d
.
└── cgt-5178
├── 0
│ └── 5
│ └── 10
│ └── 15
│ ├── 1464
│ │ └── 1465
│ └── 20
│ └── 25
│ └── 30
│ ├── 1433
│ └── 35
│ ├── 1007
│ │ └── 1311
│ └── 40
│ ├── 1339
│ ├── 1340
│ │ └── 1365
│ ├── 1344
│ │ ├── 1415
│ │ │ ├── 1459
│ │ │ ├── 1460
│ │ │ ├── 1461
│ │ │ ├── 1462
│ │ │ └── 1463
│ │ ├── 1416
│ │ ├── 1417
│ │ │ └── 1446
│ │ └── 1420
│ │ └── 1423
│ │ └── 1426
│ ├── 45
│ │ └── 50
│ │ ├── 55
│ │ │ ├── 60
│ │ │ │ ├── 1466
│ │ │ │ └── 229
│ │ │ │ ├── 1355
│ │ │ │ ├── 1437
│ │ │ │ └── 251
│ │ │ │ ├── 1406
│ │ │ │ └── 257
│ │ │ └── 645
│ │ │ └── 652
│ │ │ └── 663
│ │ │ └── 712
│ │ │ └── 843
│ │ │ ├── 930
│ │ │ │ └── 1410
│ │ │ └── 932
│ │ │ └── 1432
│ │ └── 57
│ ├── 951
│ │ └── 1112
│ │ └── 1361
│ │ └── 1419
│ └── 952
│ └── 1149
│ ├── 1152
│ │ └── 1243
│ │ ├── 1291
│ │ │ └── 1296
│ │ │ └── 1302
│ │ │ ├── 1326
│ │ │ ├── 1329
│ │ │ │ ├── 1346
│ │ │ │ │ ├── 1453
│ │ │ │ │ └── 1454
│ │ │ │ │ ├── 1455
│ │ │ │ │ └── 1456
│ │ │ │ └── 1380
│ │ │ │ ├── 1398
│ │ │ │ │ └── 1422
│ │ │ │ └── 1399
│ │ │ └── 1330
│ │ ├── 1368
│ │ │ ├── 1451
│ │ │ └── 1452
│ │ ├── 1427
│ │ └── 1428
│ │ └── 1440
│ ├── 1434
│ └── 1435
├── 1108
│ ├── 1441
│ └── 1442
├── 1183
│ ├── 1337
│ │ ├── 1391
│ │ ├── 1392
│ │ │ └── 1438
│ │ ├── 1393
│ │ │ ├── 1444
│ │ │ └── 1445
│ │ └── 1436
│ └── 1411
└── 1194
├── 1309
│ └── 1336
├── 1457
└── 1458
101 directories
Let's say you want to to create a lot of cgroups and only a few
clients which only exist short you could do this here:
# ./cgroup_tests -g 1000 -c 200 -t 20 ./memory_hog -- -s 0 -l 1 -b 1M
cgroup_tests creates 10000 cgrougs and tries to keep 200 memory hogs
alive. They will only allocated 1M each and do not loop or sleep at all.
Acknowlegment
-------------
- list.h is taken from the Linux kernel (include/linux/list.h) and
modified by <[email protected]> for userland usage. Note
this is a GPL v2 licensed header.