Lines Matching refs:ai

655 static int __init pcpu_verify_alloc_info(const struct pcpu_alloc_info *ai);
1037 struct pcpu_alloc_info *ai; in pcpu_alloc_alloc_info() local
1042 base_size = ALIGN(sizeof(*ai) + nr_groups * sizeof(ai->groups[0]), in pcpu_alloc_alloc_info()
1043 __alignof__(ai->groups[0].cpu_map[0])); in pcpu_alloc_alloc_info()
1044 ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]); in pcpu_alloc_alloc_info()
1049 ai = ptr; in pcpu_alloc_alloc_info()
1052 ai->groups[0].cpu_map = ptr; in pcpu_alloc_alloc_info()
1055 ai->groups[0].cpu_map[unit] = NR_CPUS; in pcpu_alloc_alloc_info()
1057 ai->nr_groups = nr_groups; in pcpu_alloc_alloc_info()
1058 ai->__ai_size = PFN_ALIGN(ai_size); in pcpu_alloc_alloc_info()
1060 return ai; in pcpu_alloc_alloc_info()
1069 void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai) in pcpu_free_alloc_info() argument
1071 free_bootmem(__pa(ai), ai->__ai_size); in pcpu_free_alloc_info()
1082 const struct pcpu_alloc_info *ai) in pcpu_dump_alloc_info() argument
1090 v = ai->nr_groups; in pcpu_dump_alloc_info()
1099 upa = ai->alloc_size / ai->unit_size; in pcpu_dump_alloc_info()
1104 lvl, ai->static_size, ai->reserved_size, ai->dyn_size, in pcpu_dump_alloc_info()
1105 ai->unit_size, ai->alloc_size / ai->atom_size, ai->atom_size); in pcpu_dump_alloc_info()
1107 for (group = 0; group < ai->nr_groups; group++) { in pcpu_dump_alloc_info()
1108 const struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_dump_alloc_info()
1187 int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, in pcpu_setup_first_chunk() argument
1193 size_t dyn_size = ai->dyn_size; in pcpu_setup_first_chunk()
1194 size_t size_sum = ai->static_size + ai->reserved_size + dyn_size; in pcpu_setup_first_chunk()
1209 pcpu_dump_alloc_info(KERN_EMERG, ai); \ in pcpu_setup_first_chunk()
1215 PCPU_SETUP_BUG_ON(ai->nr_groups <= 0); in pcpu_setup_first_chunk()
1217 PCPU_SETUP_BUG_ON(!ai->static_size); in pcpu_setup_first_chunk()
1220 PCPU_SETUP_BUG_ON(ai->unit_size < size_sum); in pcpu_setup_first_chunk()
1221 PCPU_SETUP_BUG_ON(ai->unit_size & ~PAGE_MASK); in pcpu_setup_first_chunk()
1222 PCPU_SETUP_BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE); in pcpu_setup_first_chunk()
1223 PCPU_SETUP_BUG_ON(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE); in pcpu_setup_first_chunk()
1224 PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0); in pcpu_setup_first_chunk()
1227 group_offsets = alloc_bootmem(ai->nr_groups * sizeof(group_offsets[0])); in pcpu_setup_first_chunk()
1228 group_sizes = alloc_bootmem(ai->nr_groups * sizeof(group_sizes[0])); in pcpu_setup_first_chunk()
1236 for (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) { in pcpu_setup_first_chunk()
1237 const struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_setup_first_chunk()
1240 group_sizes[group] = gi->nr_units * ai->unit_size; in pcpu_setup_first_chunk()
1252 unit_off[cpu] = gi->base_offset + i * ai->unit_size; in pcpu_setup_first_chunk()
1266 pcpu_dump_alloc_info(KERN_DEBUG, ai); in pcpu_setup_first_chunk()
1268 pcpu_nr_groups = ai->nr_groups; in pcpu_setup_first_chunk()
1275 pcpu_unit_pages = ai->unit_size >> PAGE_SHIFT; in pcpu_setup_first_chunk()
1277 pcpu_atom_size = ai->atom_size; in pcpu_setup_first_chunk()
1305 if (ai->reserved_size) { in pcpu_setup_first_chunk()
1306 schunk->free_size = ai->reserved_size; in pcpu_setup_first_chunk()
1308 pcpu_reserved_chunk_limit = ai->static_size + ai->reserved_size; in pcpu_setup_first_chunk()
1315 schunk->map[schunk->map_used++] = -ai->static_size; in pcpu_setup_first_chunk()
1423 struct pcpu_alloc_info *ai; in pcpu_build_alloc_info() local
1506 ai = pcpu_alloc_alloc_info(nr_groups, nr_units); in pcpu_build_alloc_info()
1507 if (!ai) in pcpu_build_alloc_info()
1509 cpu_map = ai->groups[0].cpu_map; in pcpu_build_alloc_info()
1512 ai->groups[group].cpu_map = cpu_map; in pcpu_build_alloc_info()
1516 ai->static_size = static_size; in pcpu_build_alloc_info()
1517 ai->reserved_size = reserved_size; in pcpu_build_alloc_info()
1518 ai->dyn_size = dyn_size; in pcpu_build_alloc_info()
1519 ai->unit_size = alloc_size / upa; in pcpu_build_alloc_info()
1520 ai->atom_size = atom_size; in pcpu_build_alloc_info()
1521 ai->alloc_size = alloc_size; in pcpu_build_alloc_info()
1524 struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_build_alloc_info()
1531 gi->base_offset = unit * ai->unit_size; in pcpu_build_alloc_info()
1541 return ai; in pcpu_build_alloc_info()
1586 struct pcpu_alloc_info *ai; in pcpu_embed_first_chunk() local
1590 ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size, in pcpu_embed_first_chunk()
1592 if (IS_ERR(ai)) in pcpu_embed_first_chunk()
1593 return PTR_ERR(ai); in pcpu_embed_first_chunk()
1595 size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; in pcpu_embed_first_chunk()
1596 areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *)); in pcpu_embed_first_chunk()
1605 for (group = 0; group < ai->nr_groups; group++) { in pcpu_embed_first_chunk()
1606 struct pcpu_group_info *gi = &ai->groups[group]; in pcpu_embed_first_chunk()
1615 ptr = alloc_fn(cpu, gi->nr_units * ai->unit_size, atom_size); in pcpu_embed_first_chunk()
1624 for (i = 0; i < gi->nr_units; i++, ptr += ai->unit_size) { in pcpu_embed_first_chunk()
1627 free_fn(ptr, ai->unit_size); in pcpu_embed_first_chunk()
1631 memcpy(ptr, __per_cpu_load, ai->static_size); in pcpu_embed_first_chunk()
1632 free_fn(ptr + size_sum, ai->unit_size - size_sum); in pcpu_embed_first_chunk()
1638 for (group = 0; group < ai->nr_groups; group++) { in pcpu_embed_first_chunk()
1639 ai->groups[group].base_offset = areas[group] - base; in pcpu_embed_first_chunk()
1641 ai->groups[group].base_offset); in pcpu_embed_first_chunk()
1643 max_distance += ai->unit_size; in pcpu_embed_first_chunk()
1658 PFN_DOWN(size_sum), base, ai->static_size, ai->reserved_size, in pcpu_embed_first_chunk()
1659 ai->dyn_size, ai->unit_size); in pcpu_embed_first_chunk()
1661 rc = pcpu_setup_first_chunk(ai, base); in pcpu_embed_first_chunk()
1665 for (group = 0; group < ai->nr_groups; group++) in pcpu_embed_first_chunk()
1667 ai->groups[group].nr_units * ai->unit_size); in pcpu_embed_first_chunk()
1669 pcpu_free_alloc_info(ai); in pcpu_embed_first_chunk()
1699 struct pcpu_alloc_info *ai; in pcpu_page_first_chunk() local
1708 ai = pcpu_build_alloc_info(reserved_size, 0, PAGE_SIZE, NULL); in pcpu_page_first_chunk()
1709 if (IS_ERR(ai)) in pcpu_page_first_chunk()
1710 return PTR_ERR(ai); in pcpu_page_first_chunk()
1711 BUG_ON(ai->nr_groups != 1); in pcpu_page_first_chunk()
1712 BUG_ON(ai->groups[0].nr_units != num_possible_cpus()); in pcpu_page_first_chunk()
1714 unit_pages = ai->unit_size >> PAGE_SHIFT; in pcpu_page_first_chunk()
1725 unsigned int cpu = ai->groups[0].cpu_map[unit]; in pcpu_page_first_chunk()
1739 vm.size = num_possible_cpus() * ai->unit_size; in pcpu_page_first_chunk()
1744 (unsigned long)vm.addr + unit * ai->unit_size; in pcpu_page_first_chunk()
1764 memcpy((void *)unit_addr, __per_cpu_load, ai->static_size); in pcpu_page_first_chunk()
1769 unit_pages, psize_str, vm.addr, ai->static_size, in pcpu_page_first_chunk()
1770 ai->reserved_size, ai->dyn_size); in pcpu_page_first_chunk()
1772 rc = pcpu_setup_first_chunk(ai, vm.addr); in pcpu_page_first_chunk()
1781 pcpu_free_alloc_info(ai); in pcpu_page_first_chunk()
1849 struct pcpu_alloc_info *ai; in setup_per_cpu_areas() local
1852 ai = pcpu_alloc_alloc_info(1, 1); in setup_per_cpu_areas()
1854 if (!ai || !fc) in setup_per_cpu_areas()
1857 ai->dyn_size = unit_size; in setup_per_cpu_areas()
1858 ai->unit_size = unit_size; in setup_per_cpu_areas()
1859 ai->atom_size = unit_size; in setup_per_cpu_areas()
1860 ai->alloc_size = unit_size; in setup_per_cpu_areas()
1861 ai->groups[0].nr_units = 1; in setup_per_cpu_areas()
1862 ai->groups[0].cpu_map[0] = 0; in setup_per_cpu_areas()
1864 if (pcpu_setup_first_chunk(ai, fc) < 0) in setup_per_cpu_areas()