Lines Matching refs:ai
1583 static int __init pcpu_verify_alloc_info(const struct pcpu_alloc_info *ai);
2433 struct pcpu_alloc_info *ai; in pcpu_alloc_alloc_info() local
2438 base_size = ALIGN(struct_size(ai, groups, nr_groups), in pcpu_alloc_alloc_info()
2439 __alignof__(ai->groups[0].cpu_map[0])); in pcpu_alloc_alloc_info()
2440 ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]); in pcpu_alloc_alloc_info()
2445 ai = ptr; in pcpu_alloc_alloc_info()
2448 ai->groups[0].cpu_map = ptr; in pcpu_alloc_alloc_info()
2451 ai->groups[0].cpu_map[unit] = NR_CPUS; in pcpu_alloc_alloc_info()
2453 ai->nr_groups = nr_groups; in pcpu_alloc_alloc_info()
2454 ai->__ai_size = PFN_ALIGN(ai_size); in pcpu_alloc_alloc_info()
2456 return ai; in pcpu_alloc_alloc_info()
2465 void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai) in pcpu_free_alloc_info() argument
2467 memblock_free(ai, ai->__ai_size); in pcpu_free_alloc_info()
2478 const struct pcpu_alloc_info *ai) in pcpu_dump_alloc_info() argument
2486 v = ai->nr_groups; in pcpu_dump_alloc_info()
2495 upa = ai->alloc_size / ai->unit_size; in pcpu_dump_alloc_info()
2500 lvl, ai->static_size, ai->reserved_size, ai->dyn_size, in pcpu_dump_alloc_info()
2501 ai->unit_size, ai->alloc_size / ai->atom_size, ai->atom_size); in pcpu_dump_alloc_info()
2503 for (group = 0; group < ai->nr_groups; group++) { in pcpu_dump_alloc_info()
2504 const struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_dump_alloc_info()
2581 void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, in pcpu_setup_first_chunk() argument
2584 size_t size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; in pcpu_setup_first_chunk()
2600 pcpu_dump_alloc_info(KERN_EMERG, ai); \ in pcpu_setup_first_chunk()
2606 PCPU_SETUP_BUG_ON(ai->nr_groups <= 0); in pcpu_setup_first_chunk()
2608 PCPU_SETUP_BUG_ON(!ai->static_size); in pcpu_setup_first_chunk()
2613 PCPU_SETUP_BUG_ON(ai->unit_size < size_sum); in pcpu_setup_first_chunk()
2614 PCPU_SETUP_BUG_ON(offset_in_page(ai->unit_size)); in pcpu_setup_first_chunk()
2615 PCPU_SETUP_BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE); in pcpu_setup_first_chunk()
2616 PCPU_SETUP_BUG_ON(!IS_ALIGNED(ai->unit_size, PCPU_BITMAP_BLOCK_SIZE)); in pcpu_setup_first_chunk()
2617 PCPU_SETUP_BUG_ON(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE); in pcpu_setup_first_chunk()
2618 PCPU_SETUP_BUG_ON(!IS_ALIGNED(ai->reserved_size, PCPU_MIN_ALLOC_SIZE)); in pcpu_setup_first_chunk()
2621 PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0); in pcpu_setup_first_chunk()
2624 alloc_size = ai->nr_groups * sizeof(group_offsets[0]); in pcpu_setup_first_chunk()
2630 alloc_size = ai->nr_groups * sizeof(group_sizes[0]); in pcpu_setup_first_chunk()
2654 for (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) { in pcpu_setup_first_chunk()
2655 const struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_setup_first_chunk()
2658 group_sizes[group] = gi->nr_units * ai->unit_size; in pcpu_setup_first_chunk()
2670 unit_off[cpu] = gi->base_offset + i * ai->unit_size; in pcpu_setup_first_chunk()
2688 pcpu_dump_alloc_info(KERN_DEBUG, ai); in pcpu_setup_first_chunk()
2690 pcpu_nr_groups = ai->nr_groups; in pcpu_setup_first_chunk()
2697 pcpu_unit_pages = ai->unit_size >> PAGE_SHIFT; in pcpu_setup_first_chunk()
2699 pcpu_atom_size = ai->atom_size; in pcpu_setup_first_chunk()
2703 pcpu_stats_save_ai(ai); in pcpu_setup_first_chunk()
2733 static_size = ALIGN(ai->static_size, PCPU_MIN_ALLOC_SIZE); in pcpu_setup_first_chunk()
2734 dyn_size = ai->dyn_size - (static_size - ai->static_size); in pcpu_setup_first_chunk()
2748 if (ai->reserved_size) in pcpu_setup_first_chunk()
2750 ai->reserved_size); in pcpu_setup_first_chunk()
2751 tmp_addr = (unsigned long)base_addr + static_size + ai->reserved_size; in pcpu_setup_first_chunk()
2851 struct pcpu_alloc_info *ai; in pcpu_build_alloc_info() local
2941 ai = pcpu_alloc_alloc_info(nr_groups, nr_units); in pcpu_build_alloc_info()
2942 if (!ai) in pcpu_build_alloc_info()
2944 cpu_map = ai->groups[0].cpu_map; in pcpu_build_alloc_info()
2947 ai->groups[group].cpu_map = cpu_map; in pcpu_build_alloc_info()
2951 ai->static_size = static_size; in pcpu_build_alloc_info()
2952 ai->reserved_size = reserved_size; in pcpu_build_alloc_info()
2953 ai->dyn_size = dyn_size; in pcpu_build_alloc_info()
2954 ai->unit_size = alloc_size / upa; in pcpu_build_alloc_info()
2955 ai->atom_size = atom_size; in pcpu_build_alloc_info()
2956 ai->alloc_size = alloc_size; in pcpu_build_alloc_info()
2959 struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_build_alloc_info()
2966 gi->base_offset = unit * ai->unit_size; in pcpu_build_alloc_info()
2976 return ai; in pcpu_build_alloc_info()
3055 struct pcpu_alloc_info *ai; in pcpu_embed_first_chunk() local
3060 ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size, in pcpu_embed_first_chunk()
3062 if (IS_ERR(ai)) in pcpu_embed_first_chunk()
3063 return PTR_ERR(ai); in pcpu_embed_first_chunk()
3065 size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; in pcpu_embed_first_chunk()
3066 areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *)); in pcpu_embed_first_chunk()
3076 for (group = 0; group < ai->nr_groups; group++) { in pcpu_embed_first_chunk()
3077 struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_embed_first_chunk()
3086 ptr = pcpu_fc_alloc(cpu, gi->nr_units * ai->unit_size, atom_size, cpu_to_nd_fn); in pcpu_embed_first_chunk()
3100 max_distance += ai->unit_size * ai->groups[highest_group].nr_units; in pcpu_embed_first_chunk()
3118 for (group = 0; group < ai->nr_groups; group++) { in pcpu_embed_first_chunk()
3119 struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_embed_first_chunk()
3122 for (i = 0; i < gi->nr_units; i++, ptr += ai->unit_size) { in pcpu_embed_first_chunk()
3125 pcpu_fc_free(ptr, ai->unit_size); in pcpu_embed_first_chunk()
3129 memcpy(ptr, __per_cpu_load, ai->static_size); in pcpu_embed_first_chunk()
3130 pcpu_fc_free(ptr + size_sum, ai->unit_size - size_sum); in pcpu_embed_first_chunk()
3135 for (group = 0; group < ai->nr_groups; group++) { in pcpu_embed_first_chunk()
3136 ai->groups[group].base_offset = areas[group] - base; in pcpu_embed_first_chunk()
3140 PFN_DOWN(size_sum), ai->static_size, ai->reserved_size, in pcpu_embed_first_chunk()
3141 ai->dyn_size, ai->unit_size); in pcpu_embed_first_chunk()
3143 pcpu_setup_first_chunk(ai, base); in pcpu_embed_first_chunk()
3147 for (group = 0; group < ai->nr_groups; group++) in pcpu_embed_first_chunk()
3150 ai->groups[group].nr_units * ai->unit_size); in pcpu_embed_first_chunk()
3152 pcpu_free_alloc_info(ai); in pcpu_embed_first_chunk()
3240 struct pcpu_alloc_info *ai; in pcpu_page_first_chunk() local
3251 ai = pcpu_build_alloc_info(reserved_size, 0, PAGE_SIZE, NULL); in pcpu_page_first_chunk()
3252 if (IS_ERR(ai)) in pcpu_page_first_chunk()
3253 return PTR_ERR(ai); in pcpu_page_first_chunk()
3254 BUG_ON(ai->nr_groups != 1); in pcpu_page_first_chunk()
3255 upa = ai->alloc_size/ai->unit_size; in pcpu_page_first_chunk()
3257 if (WARN_ON(ai->groups[0].nr_units != nr_g0_units)) { in pcpu_page_first_chunk()
3258 pcpu_free_alloc_info(ai); in pcpu_page_first_chunk()
3262 unit_pages = ai->unit_size >> PAGE_SHIFT; in pcpu_page_first_chunk()
3275 unsigned int cpu = ai->groups[0].cpu_map[unit]; in pcpu_page_first_chunk()
3293 vm.size = num_possible_cpus() * ai->unit_size; in pcpu_page_first_chunk()
3298 (unsigned long)vm.addr + unit * ai->unit_size; in pcpu_page_first_chunk()
3309 flush_cache_vmap_early(unit_addr, unit_addr + ai->unit_size); in pcpu_page_first_chunk()
3312 memcpy((void *)unit_addr, __per_cpu_load, ai->static_size); in pcpu_page_first_chunk()
3317 unit_pages, psize_str, ai->static_size, in pcpu_page_first_chunk()
3318 ai->reserved_size, ai->dyn_size); in pcpu_page_first_chunk()
3320 pcpu_setup_first_chunk(ai, vm.addr); in pcpu_page_first_chunk()
3329 pcpu_free_alloc_info(ai); in pcpu_page_first_chunk()
3385 struct pcpu_alloc_info *ai; in setup_per_cpu_areas() local
3388 ai = pcpu_alloc_alloc_info(1, 1); in setup_per_cpu_areas()
3390 if (!ai || !fc) in setup_per_cpu_areas()
3395 ai->dyn_size = unit_size; in setup_per_cpu_areas()
3396 ai->unit_size = unit_size; in setup_per_cpu_areas()
3397 ai->atom_size = unit_size; in setup_per_cpu_areas()
3398 ai->alloc_size = unit_size; in setup_per_cpu_areas()
3399 ai->groups[0].nr_units = 1; in setup_per_cpu_areas()
3400 ai->groups[0].cpu_map[0] = 0; in setup_per_cpu_areas()
3402 pcpu_setup_first_chunk(ai, fc); in setup_per_cpu_areas()
3403 pcpu_free_alloc_info(ai); in setup_per_cpu_areas()