Commit 03afc0e
slab: get_online_mems for kmem_cache_{create,destroy,shrink}
When we create a sl[au]b cache, we allocate kmem_cache_node structures
for each online NUMA node. To handle nodes taken online/offline, we
register memory hotplug notifier and allocate/free kmem_cache_node
corresponding to the node that changes its state for each kmem cache.
To synchronize between the two paths we hold the slab_mutex during both
the cache creationg/destruction path and while tuning per-node parts of
kmem caches in memory hotplug handler, but that's not quite right,
because it does not guarantee that a newly created cache will have all
kmem_cache_nodes initialized in case it races with memory hotplug. For
instance, in case of slub:
CPU0 CPU1
---- ----
kmem_cache_create: online_pages:
__kmem_cache_create: slab_memory_callback:
slab_mem_going_online_callback:
lock slab_mutex
for each slab_caches list entry
allocate kmem_cache node
unlock slab_mutex
lock slab_mutex
init_kmem_cache_nodes:
for_each_node_state(node, N_NORMAL_MEMORY)
allocate kmem_cache node
add kmem_cache to slab_caches list
unlock slab_mutex
online_pages (continued):
node_states_set_node
As a result we'll get a kmem cache with not all kmem_cache_nodes
allocated.
To avoid issues like that we should hold get/put_online_mems() during
the whole kmem cache creation/destruction/shrink paths, just like we
deal with cpu hotplug. This patch does the trick.
Note, that after it's applied, there is no need in taking the slab_mutex
for kmem_cache_shrink any more, so it is removed from there.
Signed-off-by: Vladimir Davydov <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Tang Chen <[email protected]>
Cc: Zhang Yanfei <[email protected]>
Cc: Toshi Kani <[email protected]>
Cc: Xishi Qiu <[email protected]>
Cc: Jiang Liu <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Wen Congyang <[email protected]>
Cc: Yasuaki Ishimatsu <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>1 parent bfc8c90 commit 03afc0e
5 files changed
+39
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2480 | 2480 | | |
2481 | 2481 | | |
2482 | 2482 | | |
2483 | | - | |
2484 | | - | |
| 2483 | + | |
2485 | 2484 | | |
2486 | 2485 | | |
2487 | 2486 | | |
| |||
2502 | 2501 | | |
2503 | 2502 | | |
2504 | 2503 | | |
2505 | | - | |
2506 | | - | |
2507 | | - | |
2508 | | - | |
2509 | | - | |
2510 | | - | |
2511 | | - | |
2512 | | - | |
2513 | | - | |
2514 | | - | |
2515 | | - | |
2516 | | - | |
2517 | | - | |
2518 | | - | |
2519 | | - | |
2520 | | - | |
2521 | | - | |
2522 | | - | |
2523 | | - | |
2524 | | - | |
2525 | | - | |
2526 | 2504 | | |
2527 | 2505 | | |
2528 | 2506 | | |
2529 | 2507 | | |
2530 | | - | |
| 2508 | + | |
2531 | 2509 | | |
2532 | 2510 | | |
2533 | 2511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| |||
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| 244 | + | |
| 245 | + | |
242 | 246 | | |
243 | 247 | | |
244 | 248 | | |
| |||
272 | 276 | | |
273 | 277 | | |
274 | 278 | | |
| 279 | + | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
| |||
295 | 301 | | |
296 | 302 | | |
297 | 303 | | |
| 304 | + | |
| 305 | + | |
298 | 306 | | |
299 | 307 | | |
300 | 308 | | |
| |||
328 | 336 | | |
329 | 337 | | |
330 | 338 | | |
| 339 | + | |
| 340 | + | |
331 | 341 | | |
332 | 342 | | |
333 | 343 | | |
| |||
359 | 369 | | |
360 | 370 | | |
361 | 371 | | |
362 | | - | |
| 372 | + | |
363 | 373 | | |
364 | 374 | | |
365 | 375 | | |
366 | | - | |
| 376 | + | |
| 377 | + | |
367 | 378 | | |
368 | 379 | | |
369 | 380 | | |
370 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
371 | 402 | | |
372 | 403 | | |
373 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
| 623 | + | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
628 | 627 | | |
629 | 628 | | |
630 | 629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3398 | 3398 | | |
3399 | 3399 | | |
3400 | 3400 | | |
3401 | | - | |
| 3401 | + | |
3402 | 3402 | | |
3403 | 3403 | | |
3404 | 3404 | | |
| |||
3454 | 3454 | | |
3455 | 3455 | | |
3456 | 3456 | | |
3457 | | - | |
3458 | 3457 | | |
3459 | 3458 | | |
3460 | 3459 | | |
3461 | 3460 | | |
3462 | 3461 | | |
3463 | 3462 | | |
3464 | 3463 | | |
3465 | | - | |
| 3464 | + | |
3466 | 3465 | | |
3467 | 3466 | | |
3468 | 3467 | | |
| |||
0 commit comments