mm/memblock.c: skip kmemleak for kasan_init()
[sfrench/cifs-2.6.git] / mm / memblock.c
index 9a2d5ae81ae1cf4217ed3174d72667be276769da..022d4cbb3618bb3886cec62e69912b4e9a5e8067 100644 (file)
@@ -262,7 +262,8 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,
        phys_addr_t kernel_end, ret;
 
        /* pump up @end */
-       if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
+       if (end == MEMBLOCK_ALLOC_ACCESSIBLE ||
+           end == MEMBLOCK_ALLOC_KASAN)
                end = memblock.current_limit;
 
        /* avoid allocating the first page */
@@ -800,7 +801,14 @@ int __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
        return memblock_remove_range(&memblock.memory, base, size);
 }
 
-
+/**
+ * memblock_free - free boot memory block
+ * @base: phys starting address of the  boot memory block
+ * @size: size of the boot memory block in bytes
+ *
+ * Free boot memory block previously allocated by memblock_alloc_xx() API.
+ * The freeing memory will not be released to the buddy allocator.
+ */
 int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 {
        phys_addr_t end = base + size - 1;
@@ -1412,13 +1420,15 @@ again:
 done:
        ptr = phys_to_virt(alloc);
 
-       /*
-        * The min_count is set to 0 so that bootmem allocated blocks
-        * are never reported as leaks. This is because many of these blocks
-        * are only referred via the physical address which is not
-        * looked up by kmemleak.
-        */
-       kmemleak_alloc(ptr, size, 0, 0);
+       /* Skip kmemleak for kasan_init() due to high volume. */
+       if (max_addr != MEMBLOCK_ALLOC_KASAN)
+               /*
+                * The min_count is set to 0 so that bootmem allocated
+                * blocks are never reported as leaks. This is because many
+                * of these blocks are only referred via the physical
+                * address which is not looked up by kmemleak.
+                */
+               kmemleak_alloc(ptr, size, 0, 0);
 
        return ptr;
 }
@@ -1536,24 +1546,6 @@ void * __init memblock_alloc_try_nid(
        return NULL;
 }
 
-/**
- * __memblock_free_early - free boot memory block
- * @base: phys starting address of the  boot memory block
- * @size: size of the boot memory block in bytes
- *
- * Free boot memory block previously allocated by memblock_alloc_xx() API.
- * The freeing memory will not be released to the buddy allocator.
- */
-void __init __memblock_free_early(phys_addr_t base, phys_addr_t size)
-{
-       phys_addr_t end = base + size - 1;
-
-       memblock_dbg("%s: [%pa-%pa] %pF\n",
-                    __func__, &base, &end, (void *)_RET_IP_);
-       kmemleak_free_part_phys(base, size);
-       memblock_remove_range(&memblock.reserved, base, size);
-}
-
 /**
  * __memblock_free_late - free bootmem block pages directly to buddy allocator
  * @base: phys starting address of the  boot memory block
@@ -1576,7 +1568,7 @@ void __init __memblock_free_late(phys_addr_t base, phys_addr_t size)
 
        for (; cursor < end; cursor++) {
                memblock_free_pages(pfn_to_page(cursor), cursor, 0);
-               totalram_pages++;
+               totalram_pages_inc();
        }
 }
 
@@ -1727,7 +1719,7 @@ static int __init_memblock memblock_search(struct memblock_type *type, phys_addr
        return -1;
 }
 
-bool __init memblock_is_reserved(phys_addr_t addr)
+bool __init_memblock memblock_is_reserved(phys_addr_t addr)
 {
        return memblock_search(&memblock.reserved, addr) != -1;
 }
@@ -1950,7 +1942,7 @@ void reset_node_managed_pages(pg_data_t *pgdat)
        struct zone *z;
 
        for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
-               z->managed_pages = 0;
+               atomic_long_set(&z->managed_pages, 0);
 }
 
 void __init reset_all_zones_managed_pages(void)
@@ -1978,7 +1970,7 @@ unsigned long __init memblock_free_all(void)
        reset_all_zones_managed_pages();
 
        pages = free_low_memory_core_early();
-       totalram_pages += pages;
+       totalram_pages_add(pages);
 
        return pages;
 }