diff options
author | Tejun Heo <tj@kernel.org> | 2009-08-14 02:00:51 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2009-08-14 02:00:51 -0400 |
commit | fd1e8a1fe2b54df6c185b4fa65f181f50b9c4d4e (patch) | |
tree | d4411507baacaa33c68be7813ad6f9e0d93a74e2 /arch/sparc | |
parent | 033e48fb82958053113178264ddb9d5038d5e38b (diff) |
percpu: introduce pcpu_alloc_info and pcpu_group_info
Till now, non-linear cpu->unit map was expressed using an integer
array which maps each cpu to a unit and used only by lpage allocator.
Although how many units have been placed in a single contiguos area
(group) is known while building unit_map, the information is lost when
the result is recorded into the unit_map array. For lpage allocator,
as all allocations are done by lpages and whether two adjacent lpages
are in the same group or not is irrelevant, this didn't cause any
problem. Non-linear cpu->unit mapping will be used for sparse
embedding and this grouping information is necessary for that.
This patch introduces pcpu_alloc_info which contains all the
information necessary for initializing percpu allocator.
pcpu_alloc_info contains array of pcpu_group_info which describes how
units are grouped and mapped to cpus. pcpu_group_info also has
base_offset field to specify its offset from the chunk's base address.
pcpu_build_alloc_info() initializes this field as if all groups are
allocated back-to-back as is currently done but this will be used to
sparsely place groups.
pcpu_alloc_info is a rather complex data structure which contains a
flexible array which in turn points to nested cpu_map arrays.
* pcpu_alloc_alloc_info() and pcpu_free_alloc_info() are provided to
help dealing with pcpu_alloc_info.
* pcpu_lpage_build_unit_map() is updated to build pcpu_alloc_info,
generalized and renamed to pcpu_build_alloc_info().
@cpu_distance_fn may be NULL indicating that all cpus are of
LOCAL_DISTANCE.
* pcpul_lpage_dump_cfg() is updated to process pcpu_alloc_info,
generalized and renamed to pcpu_dump_alloc_info(). It now also
prints which group each alloc unit belongs to.
* pcpu_setup_first_chunk() now takes pcpu_alloc_info instead of the
separate parameters. All first chunk allocators are updated to use
pcpu_build_alloc_info() to build alloc_info and call
pcpu_setup_first_chunk() with it. This has the side effect of
packing units for sparse possible cpus. ie. if cpus 0, 2 and 4 are
possible, they'll be assigned unit 0, 1 and 2 instead of 0, 2 and 4.
* x86 setup_pcpu_lpage() is updated to deal with alloc_info.
* sparc64 setup_per_cpu_areas() is updated to build alloc_info.
Although the changes made by this patch are pretty pervasive, it
doesn't cause any behavior difference other than packing of sparse
cpus. It mostly changes how information is passed among
initialization functions and makes room for more flexibility.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: David Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/smp_64.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index 9856d866b77b..a42a4a744d14 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c | |||
@@ -1475,17 +1475,29 @@ static void __init pcpu_map_range(unsigned long start, unsigned long end, | |||
1475 | 1475 | ||
1476 | void __init setup_per_cpu_areas(void) | 1476 | void __init setup_per_cpu_areas(void) |
1477 | { | 1477 | { |
1478 | size_t dyn_size, static_size = __per_cpu_end - __per_cpu_start; | ||
1479 | static struct vm_struct vm; | 1478 | static struct vm_struct vm; |
1479 | struct pcpu_alloc_info *ai; | ||
1480 | unsigned long delta, cpu; | 1480 | unsigned long delta, cpu; |
1481 | size_t size_sum, pcpu_unit_size; | 1481 | size_t size_sum, pcpu_unit_size; |
1482 | size_t ptrs_size; | 1482 | size_t ptrs_size; |
1483 | void **ptrs; | 1483 | void **ptrs; |
1484 | 1484 | ||
1485 | size_sum = PFN_ALIGN(static_size + PERCPU_MODULE_RESERVE + | 1485 | ai = pcpu_alloc_alloc_info(1, nr_cpu_ids); |
1486 | |||
1487 | ai->static_size = __per_cpu_end - __per_cpu_start; | ||
1488 | ai->reserved_size = PERCPU_MODULE_RESERVE; | ||
1489 | |||
1490 | size_sum = PFN_ALIGN(ai->static_size + ai->reserved_size + | ||
1486 | PERCPU_DYNAMIC_RESERVE); | 1491 | PERCPU_DYNAMIC_RESERVE); |
1487 | dyn_size = size_sum - static_size - PERCPU_MODULE_RESERVE; | ||
1488 | 1492 | ||
1493 | ai->dyn_size = size_sum - ai->static_size - ai->reserved_size; | ||
1494 | ai->unit_size = PCPU_CHUNK_SIZE; | ||
1495 | ai->atom_size = PCPU_CHUNK_SIZE; | ||
1496 | ai->alloc_size = PCPU_CHUNK_SIZE; | ||
1497 | ai->groups[0].nr_units = nr_cpu_ids; | ||
1498 | |||
1499 | for_each_possible_cpu(cpu) | ||
1500 | ai->groups[0].cpu_map[cpu] = cpu; | ||
1489 | 1501 | ||
1490 | ptrs_size = PFN_ALIGN(nr_cpu_ids * sizeof(ptrs[0])); | 1502 | ptrs_size = PFN_ALIGN(nr_cpu_ids * sizeof(ptrs[0])); |
1491 | ptrs = alloc_bootmem(ptrs_size); | 1503 | ptrs = alloc_bootmem(ptrs_size); |
@@ -1497,7 +1509,7 @@ void __init setup_per_cpu_areas(void) | |||
1497 | free_bootmem(__pa(ptrs[cpu] + size_sum), | 1509 | free_bootmem(__pa(ptrs[cpu] + size_sum), |
1498 | PCPU_CHUNK_SIZE - size_sum); | 1510 | PCPU_CHUNK_SIZE - size_sum); |
1499 | 1511 | ||
1500 | memcpy(ptrs[cpu], __per_cpu_load, static_size); | 1512 | memcpy(ptrs[cpu], __per_cpu_load, ai->static_size); |
1501 | } | 1513 | } |
1502 | 1514 | ||
1503 | /* allocate address and map */ | 1515 | /* allocate address and map */ |
@@ -1514,9 +1526,7 @@ void __init setup_per_cpu_areas(void) | |||
1514 | pcpu_map_range(start, end, virt_to_page(ptrs[cpu])); | 1526 | pcpu_map_range(start, end, virt_to_page(ptrs[cpu])); |
1515 | } | 1527 | } |
1516 | 1528 | ||
1517 | pcpu_unit_size = pcpu_setup_first_chunk(static_size, | 1529 | pcpu_unit_size = pcpu_setup_first_chunk(ai, vm.addr); |
1518 | PERCPU_MODULE_RESERVE, dyn_size, | ||
1519 | PCPU_CHUNK_SIZE, vm.addr, NULL); | ||
1520 | 1530 | ||
1521 | free_bootmem(__pa(ptrs), ptrs_size); | 1531 | free_bootmem(__pa(ptrs), ptrs_size); |
1522 | 1532 | ||