- ai = pcpu_alloc_alloc_info(1, nr_cpu_ids);
-
- ai->static_size = __per_cpu_end - __per_cpu_start;
- ai->reserved_size = PERCPU_MODULE_RESERVE;
-
- size_sum = PFN_ALIGN(ai->static_size + ai->reserved_size +
- PERCPU_DYNAMIC_RESERVE);
-
- ai->dyn_size = size_sum - ai->static_size - ai->reserved_size;
- ai->unit_size = PCPU_CHUNK_SIZE;
- ai->atom_size = PCPU_CHUNK_SIZE;
- ai->alloc_size = PCPU_CHUNK_SIZE;
- ai->groups[0].nr_units = nr_cpu_ids;
-
- for_each_possible_cpu(cpu)
- ai->groups[0].cpu_map[cpu] = cpu;
-
- ptrs_size = PFN_ALIGN(nr_cpu_ids * sizeof(ptrs[0]));
- ptrs = alloc_bootmem(ptrs_size);
-
- for_each_possible_cpu(cpu) {
- ptrs[cpu] = pcpu_alloc_bootmem(cpu, PCPU_CHUNK_SIZE,
- PCPU_CHUNK_SIZE);
-
- free_bootmem(__pa(ptrs[cpu] + size_sum),
- PCPU_CHUNK_SIZE - size_sum);
-
- memcpy(ptrs[cpu], __per_cpu_load, ai->static_size);
- }
-
- /* allocate address and map */
- vm.flags = VM_ALLOC;
- vm.size = nr_cpu_ids * PCPU_CHUNK_SIZE;
- vm_area_register_early(&vm, PCPU_CHUNK_SIZE);
-
- for_each_possible_cpu(cpu) {
- unsigned long start = (unsigned long) vm.addr;
- unsigned long end;
-
- start += cpu * PCPU_CHUNK_SIZE;
- end = start + PCPU_CHUNK_SIZE;
- pcpu_map_range(start, end, virt_to_page(ptrs[cpu]));
- }
-
- rc = pcpu_setup_first_chunk(ai, vm.addr);
+ rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
+ PERCPU_DYNAMIC_RESERVE, 4 << 20,
+ pcpu_cpu_distance, pcpu_alloc_bootmem,
+ pcpu_free_bootmem);