+ * + * Originally by Dipankar Sarma and Ravikiran Thirumalai,Probably the right approach. slab should use per-cpu for it's internal head arrays, but I've never converted the slab code due to chicken-and-egg problems and due to the additional pointer dereference.
+ * This reimplements alloc_percpu to make it + * 1. Independent of slab/kmalloc
+ * Allocator is slow -- expected to be called during module/subsytemHow slow is slow?
+ * init. alloc_percpu can block.
+ /* Map pages for each cpu by splitting vm_struct for each cpu */That means no large pte entries for the per-cpu allocations, right?
+ for (i = 0; i < NR_CPUS; i++) {
+ if (cpu_possible(i)) {
+ tmppage = &blkp->pages[i*cpu_pages];
+ tmp.addr = area->addr + i * PCPU_BLKSIZE;
+ /* map_vm_area assumes a guard page of size PAGE_SIZE */
+ tmp.size = PCPU_BLKSIZE + PAGE_SIZE; + if (map_vm_area(&tmp, PAGE_KERNEL, &tmppage))
+ goto fail_map;
+ * This allocator is slow as we assume allocs to come"Must not" - it contains down() and thus can sleep.
+ * by during boot/module init.
+ * Should not be called from interrupt context