@@ -2581,14 +2581,12 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
25812581{
25822582 size_t size_sum = ai -> static_size + ai -> reserved_size + ai -> dyn_size ;
25832583 size_t static_size , dyn_size ;
2584- struct pcpu_chunk * chunk ;
25852584 unsigned long * group_offsets ;
25862585 size_t * group_sizes ;
25872586 unsigned long * unit_off ;
25882587 unsigned int cpu ;
25892588 int * unit_map ;
25902589 int group , unit , i ;
2591- int map_size ;
25922590 unsigned long tmp_addr ;
25932591 size_t alloc_size ;
25942592
@@ -2697,7 +2695,7 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
26972695 pcpu_unit_pages = ai -> unit_size >> PAGE_SHIFT ;
26982696 pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT ;
26992697 pcpu_atom_size = ai -> atom_size ;
2700- pcpu_chunk_struct_size = struct_size (chunk , populated ,
2698+ pcpu_chunk_struct_size = struct_size (( struct pcpu_chunk * ) 0 , populated ,
27012699 BITS_TO_LONGS (pcpu_unit_pages ));
27022700
27032701 pcpu_stats_save_ai (ai );
@@ -2734,29 +2732,23 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
27342732 dyn_size = ai -> dyn_size - (static_size - ai -> static_size );
27352733
27362734 /*
2737- * Initialize first chunk.
2738- * If the reserved_size is non-zero, this initializes the reserved
2739- * chunk. If the reserved_size is zero, the reserved chunk is NULL
2740- * and the dynamic region is initialized here. The first chunk,
2741- * pcpu_first_chunk, will always point to the chunk that serves
2742- * the dynamic region.
2735+ * Initialize first chunk:
2736+ * This chunk is broken up into 3 parts:
2737+ * < static | [reserved] | dynamic >
2738+ * - static - there is no backing chunk because these allocations can
2739+ * never be freed.
2740+ * - reserved (pcpu_reserved_chunk) - exists primarily to serve
2741+ * allocations from module load.
2742+ * - dynamic (pcpu_first_chunk) - serves the dynamic part of the first
2743+ * chunk.
27432744 */
27442745 tmp_addr = (unsigned long )base_addr + static_size ;
2745- map_size = ai -> reserved_size ?: dyn_size ;
2746- chunk = pcpu_alloc_first_chunk (tmp_addr , map_size );
2747-
2748- /* init dynamic chunk if necessary */
2749- if (ai -> reserved_size ) {
2750- pcpu_reserved_chunk = chunk ;
2751-
2752- tmp_addr = (unsigned long )base_addr + static_size +
2753- ai -> reserved_size ;
2754- map_size = dyn_size ;
2755- chunk = pcpu_alloc_first_chunk (tmp_addr , map_size );
2756- }
2746+ if (ai -> reserved_size )
2747+ pcpu_reserved_chunk = pcpu_alloc_first_chunk (tmp_addr ,
2748+ ai -> reserved_size );
2749+ tmp_addr = (unsigned long )base_addr + static_size + ai -> reserved_size ;
2750+ pcpu_first_chunk = pcpu_alloc_first_chunk (tmp_addr , dyn_size );
27572751
2758- /* link the first chunk in */
2759- pcpu_first_chunk = chunk ;
27602752 pcpu_nr_empty_pop_pages = pcpu_first_chunk -> nr_empty_pop_pages ;
27612753 pcpu_chunk_relocate (pcpu_first_chunk , -1 );
27622754
0 commit comments