Merge branch 'for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 15 Nov 2017 22:17:11 +0000 (14:17 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 15 Nov 2017 22:17:11 +0000 (14:17 -0800)
Pull percpu update from Tejun Heo:
 "Another minor pull request. It only contains one commit which can
  reclaim a bit of memory wasted during boot on UP"

* 'for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
  percpu: don't forget to free the temporary struct pcpu_alloc_info

1  2 
mm/percpu.c

diff --combined mm/percpu.c
@@@ -1329,9 -1329,7 +1329,9 @@@ static struct pcpu_chunk *pcpu_chunk_ad
   * @gfp: allocation flags
   *
   * Allocate percpu area of @size bytes aligned at @align.  If @gfp doesn't
 - * contain %GFP_KERNEL, the allocation is atomic.
 + * contain %GFP_KERNEL, the allocation is atomic. If @gfp has __GFP_NOWARN
 + * then no warning will be triggered on invalid or failed allocation
 + * requests.
   *
   * RETURNS:
   * Percpu pointer to the allocated area on success, NULL on failure.
  static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
                                 gfp_t gfp)
  {
 +      bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
 +      bool do_warn = !(gfp & __GFP_NOWARN);
        static int warn_limit = 10;
        struct pcpu_chunk *chunk;
        const char *err;
 -      bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
        int slot, off, cpu, ret;
        unsigned long flags;
        void __percpu *ptr;
  
        if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE ||
                     !is_power_of_2(align))) {
 -              WARN(true, "illegal size (%zu) or align (%zu) for percpu allocation\n",
 +              WARN(do_warn, "illegal size (%zu) or align (%zu) for percpu allocation\n",
                     size, align);
                return NULL;
        }
@@@ -1485,7 -1482,7 +1485,7 @@@ fail_unlock
  fail:
        trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
  
 -      if (!is_atomic && warn_limit) {
 +      if (!is_atomic && do_warn && warn_limit) {
                pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
                        size, align, is_atomic, err);
                dump_stack();
   *
   * Allocate zero-filled percpu area of @size bytes aligned at @align.  If
   * @gfp doesn't contain %GFP_KERNEL, the allocation doesn't block and can
 - * be called from any context but is a lot more likely to fail.
 + * be called from any context but is a lot more likely to fail. If @gfp
 + * has __GFP_NOWARN then no warning will be triggered on invalid or failed
 + * allocation requests.
   *
   * RETURNS:
   * Percpu pointer to the allocated area on success, NULL on failure.
@@@ -1856,7 -1851,7 +1856,7 @@@ struct pcpu_alloc_info * __init pcpu_al
                          __alignof__(ai->groups[0].cpu_map[0]));
        ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]);
  
-       ptr = memblock_virt_alloc_nopanic(PFN_ALIGN(ai_size), 0);
+       ptr = memblock_virt_alloc_nopanic(PFN_ALIGN(ai_size), PAGE_SIZE);
        if (!ptr)
                return NULL;
        ai = ptr;
@@@ -2719,6 -2714,7 +2719,7 @@@ void __init setup_per_cpu_areas(void
  
        if (pcpu_setup_first_chunk(ai, fc) < 0)
                panic("Failed to initialize percpu areas.");
+       pcpu_free_alloc_info(ai);
  }
  
  #endif        /* CONFIG_SMP */