Commit 19023141 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu

Pull percpu updates from Dennis Zhou:
 "A couple of updates to clean up the code with no change in behavior"

* 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu:
  percpu: Use struct_size() helper
  percpu: fix typo in pcpu_setup_first_chunk() comment
  percpu: Make pcpu_setup_first_chunk() void function
parents 3ee8d6c5 14d37612
...@@ -134,10 +134,7 @@ setup_per_cpu_areas(void) ...@@ -134,10 +134,7 @@ setup_per_cpu_areas(void)
ai->atom_size = PAGE_SIZE; ai->atom_size = PAGE_SIZE;
ai->alloc_size = PERCPU_PAGE_SIZE; ai->alloc_size = PERCPU_PAGE_SIZE;
rc = pcpu_setup_first_chunk(ai, __per_cpu_start + __per_cpu_offset[0]); pcpu_setup_first_chunk(ai, __per_cpu_start + __per_cpu_offset[0]);
if (rc)
panic("failed to setup percpu area (err=%d)", rc);
pcpu_free_alloc_info(ai); pcpu_free_alloc_info(ai);
} }
#else #else
......
...@@ -245,10 +245,7 @@ void __init setup_per_cpu_areas(void) ...@@ -245,10 +245,7 @@ void __init setup_per_cpu_areas(void)
gi->cpu_map = &cpu_map[unit]; gi->cpu_map = &cpu_map[unit];
} }
rc = pcpu_setup_first_chunk(ai, base); pcpu_setup_first_chunk(ai, base);
if (rc)
panic("failed to setup percpu area (err=%d)", rc);
pcpu_free_alloc_info(ai); pcpu_free_alloc_info(ai);
} }
#endif #endif
......
...@@ -105,7 +105,7 @@ extern struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups, ...@@ -105,7 +105,7 @@ extern struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
int nr_units); int nr_units);
extern void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai); extern void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai);
extern int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, extern void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
void *base_addr); void *base_addr);
#ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK #ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK
......
...@@ -2125,7 +2125,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups, ...@@ -2125,7 +2125,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
void *ptr; void *ptr;
int unit; int unit;
base_size = ALIGN(sizeof(*ai) + nr_groups * sizeof(ai->groups[0]), base_size = ALIGN(struct_size(ai, groups, nr_groups),
__alignof__(ai->groups[0].cpu_map[0])); __alignof__(ai->groups[0].cpu_map[0]));
ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]); ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]);
...@@ -2220,7 +2220,7 @@ static void pcpu_dump_alloc_info(const char *lvl, ...@@ -2220,7 +2220,7 @@ static void pcpu_dump_alloc_info(const char *lvl,
* @base_addr: mapped address * @base_addr: mapped address
* *
* Initialize the first percpu chunk which contains the kernel static * Initialize the first percpu chunk which contains the kernel static
* perpcu area. This function is to be called from arch percpu area * percpu area. This function is to be called from arch percpu area
* setup path. * setup path.
* *
* @ai contains all information necessary to initialize the first * @ai contains all information necessary to initialize the first
...@@ -2267,12 +2267,9 @@ static void pcpu_dump_alloc_info(const char *lvl, ...@@ -2267,12 +2267,9 @@ static void pcpu_dump_alloc_info(const char *lvl,
* share the same vm, but use offset regions in the area allocation map. * share the same vm, but use offset regions in the area allocation map.
* The chunk serving the dynamic region is circulated in the chunk slots * The chunk serving the dynamic region is circulated in the chunk slots
* and available for dynamic allocation like any other chunk. * and available for dynamic allocation like any other chunk.
*
* RETURNS:
* 0 on success, -errno on failure.
*/ */
int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
void *base_addr) void *base_addr)
{ {
size_t size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; size_t size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
size_t static_size, dyn_size; size_t static_size, dyn_size;
...@@ -2457,7 +2454,6 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, ...@@ -2457,7 +2454,6 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
/* we're done */ /* we're done */
pcpu_base_addr = base_addr; pcpu_base_addr = base_addr;
return 0;
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
...@@ -2710,7 +2706,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size, ...@@ -2710,7 +2706,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
struct pcpu_alloc_info *ai; struct pcpu_alloc_info *ai;
size_t size_sum, areas_size; size_t size_sum, areas_size;
unsigned long max_distance; unsigned long max_distance;
int group, i, highest_group, rc; int group, i, highest_group, rc = 0;
ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size, ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size,
cpu_distance_fn); cpu_distance_fn);
...@@ -2795,7 +2791,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size, ...@@ -2795,7 +2791,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
PFN_DOWN(size_sum), ai->static_size, ai->reserved_size, PFN_DOWN(size_sum), ai->static_size, ai->reserved_size,
ai->dyn_size, ai->unit_size); ai->dyn_size, ai->unit_size);
rc = pcpu_setup_first_chunk(ai, base); pcpu_setup_first_chunk(ai, base);
goto out_free; goto out_free;
out_free_areas: out_free_areas:
...@@ -2839,7 +2835,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size, ...@@ -2839,7 +2835,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
int unit_pages; int unit_pages;
size_t pages_size; size_t pages_size;
struct page **pages; struct page **pages;
int unit, i, j, rc; int unit, i, j, rc = 0;
int upa; int upa;
int nr_g0_units; int nr_g0_units;
...@@ -2920,7 +2916,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size, ...@@ -2920,7 +2916,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
unit_pages, psize_str, ai->static_size, unit_pages, psize_str, ai->static_size,
ai->reserved_size, ai->dyn_size); ai->reserved_size, ai->dyn_size);
rc = pcpu_setup_first_chunk(ai, vm.addr); pcpu_setup_first_chunk(ai, vm.addr);
goto out_free_ar; goto out_free_ar;
enomem: enomem:
...@@ -3014,8 +3010,7 @@ void __init setup_per_cpu_areas(void) ...@@ -3014,8 +3010,7 @@ void __init setup_per_cpu_areas(void)
ai->groups[0].nr_units = 1; ai->groups[0].nr_units = 1;
ai->groups[0].cpu_map[0] = 0; ai->groups[0].cpu_map[0] = 0;
if (pcpu_setup_first_chunk(ai, fc) < 0) pcpu_setup_first_chunk(ai, fc);
panic("Failed to initialize percpu areas.");
pcpu_free_alloc_info(ai); pcpu_free_alloc_info(ai);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment