diff options
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -389,7 +389,6 @@ struct kmem_cache { | |||
389 | unsigned int buffer_size; | 389 | unsigned int buffer_size; |
390 | u32 reciprocal_buffer_size; | 390 | u32 reciprocal_buffer_size; |
391 | /* 3) touched by every alloc & free from the backend */ | 391 | /* 3) touched by every alloc & free from the backend */ |
392 | struct kmem_list3 *nodelists[MAX_NUMNODES]; | ||
393 | 392 | ||
394 | unsigned int flags; /* constant flags */ | 393 | unsigned int flags; /* constant flags */ |
395 | unsigned int num; /* # of objs per slab */ | 394 | unsigned int num; /* # of objs per slab */ |
@@ -444,6 +443,17 @@ struct kmem_cache { | |||
444 | int obj_offset; | 443 | int obj_offset; |
445 | int obj_size; | 444 | int obj_size; |
446 | #endif | 445 | #endif |
446 | /* | ||
447 | * We put nodelists[] at the end of kmem_cache, because we want to size | ||
448 | * this array to nr_node_ids slots instead of MAX_NUMNODES | ||
449 | * (see kmem_cache_init()) | ||
450 | * We still use [MAX_NUMNODES] and not [1] or [0] because cache_cache | ||
451 | * is statically defined, so we reserve the max number of nodes. | ||
452 | */ | ||
453 | struct kmem_list3 *nodelists[MAX_NUMNODES]; | ||
454 | /* | ||
455 | * Do not add fields after nodelists[] | ||
456 | */ | ||
447 | }; | 457 | }; |
448 | 458 | ||
449 | #define CFLGS_OFF_SLAB (0x80000000UL) | 459 | #define CFLGS_OFF_SLAB (0x80000000UL) |
@@ -678,9 +688,6 @@ static struct kmem_cache cache_cache = { | |||
678 | .shared = 1, | 688 | .shared = 1, |
679 | .buffer_size = sizeof(struct kmem_cache), | 689 | .buffer_size = sizeof(struct kmem_cache), |
680 | .name = "kmem_cache", | 690 | .name = "kmem_cache", |
681 | #if DEBUG | ||
682 | .obj_size = sizeof(struct kmem_cache), | ||
683 | #endif | ||
684 | }; | 691 | }; |
685 | 692 | ||
686 | #define BAD_ALIEN_MAGIC 0x01020304ul | 693 | #define BAD_ALIEN_MAGIC 0x01020304ul |
@@ -1440,6 +1447,15 @@ void __init kmem_cache_init(void) | |||
1440 | cache_cache.array[smp_processor_id()] = &initarray_cache.cache; | 1447 | cache_cache.array[smp_processor_id()] = &initarray_cache.cache; |
1441 | cache_cache.nodelists[node] = &initkmem_list3[CACHE_CACHE]; | 1448 | cache_cache.nodelists[node] = &initkmem_list3[CACHE_CACHE]; |
1442 | 1449 | ||
1450 | /* | ||
1451 | * struct kmem_cache size depends on nr_node_ids, which | ||
1452 | * can be less than MAX_NUMNODES. | ||
1453 | */ | ||
1454 | cache_cache.buffer_size = offsetof(struct kmem_cache, nodelists) + | ||
1455 | nr_node_ids * sizeof(struct kmem_list3 *); | ||
1456 | #if DEBUG | ||
1457 | cache_cache.obj_size = cache_cache.buffer_size; | ||
1458 | #endif | ||
1443 | cache_cache.buffer_size = ALIGN(cache_cache.buffer_size, | 1459 | cache_cache.buffer_size = ALIGN(cache_cache.buffer_size, |
1444 | cache_line_size()); | 1460 | cache_line_size()); |
1445 | cache_cache.reciprocal_buffer_size = | 1461 | cache_cache.reciprocal_buffer_size = |