@@ -2581,14 +2581,12 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
2581
2581
{
2582
2582
size_t size_sum = ai -> static_size + ai -> reserved_size + ai -> dyn_size ;
2583
2583
size_t static_size , dyn_size ;
2584
- struct pcpu_chunk * chunk ;
2585
2584
unsigned long * group_offsets ;
2586
2585
size_t * group_sizes ;
2587
2586
unsigned long * unit_off ;
2588
2587
unsigned int cpu ;
2589
2588
int * unit_map ;
2590
2589
int group , unit , i ;
2591
- int map_size ;
2592
2590
unsigned long tmp_addr ;
2593
2591
size_t alloc_size ;
2594
2592
@@ -2697,7 +2695,7 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
2697
2695
pcpu_unit_pages = ai -> unit_size >> PAGE_SHIFT ;
2698
2696
pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT ;
2699
2697
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 ,
2701
2699
BITS_TO_LONGS (pcpu_unit_pages ));
2702
2700
2703
2701
pcpu_stats_save_ai (ai );
@@ -2734,29 +2732,23 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
2734
2732
dyn_size = ai -> dyn_size - (static_size - ai -> static_size );
2735
2733
2736
2734
/*
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.
2743
2744
*/
2744
2745
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 );
2757
2751
2758
- /* link the first chunk in */
2759
- pcpu_first_chunk = chunk ;
2760
2752
pcpu_nr_empty_pop_pages = pcpu_first_chunk -> nr_empty_pop_pages ;
2761
2753
pcpu_chunk_relocate (pcpu_first_chunk , -1 );
2762
2754
0 commit comments