Commit c8b05e2
committed
Recycle used kernel thread stacks
Because new_kernel_stack iterates through the available stack
space linearly, it can only provide each stack slot once. This
means that there is a limited number of kernel threads that can
be created over the lifetime of the kernel. With the kernel
stack space defined so currently, and with one-page guard pages
for each stack, this would currently give a limit of 255 kernel
threads (including the initial thread).
To address this issue, we now recycle old kernel stack when their
thread exits. When we create a new thread, we check whether there
is a dead stack available. If so, we reuse it, rather than allocating
another. This means we go from having a limit of 255 kernel threads
ever to a limit of 255 simultaneous kernel threads. In practice,
this is likely to be sufficient.
Signed-off-by: SlyMarbo <the.sly.marbo@googlemail.com>1 parent d56e450 commit c8b05e2
1 file changed
+30
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
58 | 75 | | |
59 | 76 | | |
60 | 77 | | |
| |||
151 | 168 | | |
152 | 169 | | |
153 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
154 | 174 | | |
155 | 175 | | |
156 | 176 | | |
| |||
278 | 298 | | |
279 | 299 | | |
280 | 300 | | |
281 | | - | |
282 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
283 | 311 | | |
284 | 312 | | |
285 | 313 | | |
| |||
0 commit comments