memblock: stop using implicit alignment to SMP_CACHE_BYTES
authorMike Rapoport <rppt@linux.vnet.ibm.com>
Tue, 30 Oct 2018 22:09:57 +0000 (15:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Oct 2018 15:54:16 +0000 (08:54 -0700)
When a memblock allocation APIs are called with align = 0, the alignment
is implicitly set to SMP_CACHE_BYTES.

Implicit alignment is done deep in the memblock allocator and it can
come as a surprise.  Not that such an alignment would be wrong even
when used incorrectly but it is better to be explicit for the sake of
clarity and the prinicple of the least surprise.

Replace all such uses of memblock APIs with the 'align' parameter
explicitly set to SMP_CACHE_BYTES and stop implicit alignment assignment
in the memblock internal allocation functions.

For the case when memblock APIs are used via helper functions, e.g.  like
iommu_arena_new_node() in Alpha, the helper functions were detected with
Coccinelle's help and then manually examined and updated where
appropriate.

The direct memblock APIs users were updated using the semantic patch below:

@@
expression size, min_addr, max_addr, nid;
@@
(
|
- memblock_alloc_try_nid_raw(size, 0, min_addr, max_addr, nid)
+ memblock_alloc_try_nid_raw(size, SMP_CACHE_BYTES, min_addr, max_addr,
nid)
|
- memblock_alloc_try_nid_nopanic(size, 0, min_addr, max_addr, nid)
+ memblock_alloc_try_nid_nopanic(size, SMP_CACHE_BYTES, min_addr, max_addr,
nid)
|
- memblock_alloc_try_nid(size, 0, min_addr, max_addr, nid)
+ memblock_alloc_try_nid(size, SMP_CACHE_BYTES, min_addr, max_addr, nid)
|
- memblock_alloc(size, 0)
+ memblock_alloc(size, SMP_CACHE_BYTES)
|
- memblock_alloc_raw(size, 0)
+ memblock_alloc_raw(size, SMP_CACHE_BYTES)
|
- memblock_alloc_from(size, 0, min_addr)
+ memblock_alloc_from(size, SMP_CACHE_BYTES, min_addr)
|
- memblock_alloc_nopanic(size, 0)
+ memblock_alloc_nopanic(size, SMP_CACHE_BYTES)
|
- memblock_alloc_low(size, 0)
+ memblock_alloc_low(size, SMP_CACHE_BYTES)
|
- memblock_alloc_low_nopanic(size, 0)
+ memblock_alloc_low_nopanic(size, SMP_CACHE_BYTES)
|
- memblock_alloc_from_nopanic(size, 0, min_addr)
+ memblock_alloc_from_nopanic(size, SMP_CACHE_BYTES, min_addr)
|
- memblock_alloc_node(size, 0, nid)
+ memblock_alloc_node(size, SMP_CACHE_BYTES, nid)
)

[mhocko@suse.com: changelog update]
[akpm@linux-foundation.org: coding-style fixes]
[rppt@linux.ibm.com: fix missed uses of implicit alignment]
Link: http://lkml.kernel.org/r/20181016133656.GA10925@rapoport-lnx
Link: http://lkml.kernel.org/r/1538687224-17535-1-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Suggested-by: Michal Hocko <mhocko@suse.com>
Acked-by: Paul Burton <paul.burton@mips.com> [MIPS]
Acked-by: Michael Ellerman <mpe@ellerman.id.au> [powerpc]
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
50 files changed:
arch/alpha/kernel/core_apecs.c
arch/alpha/kernel/core_lca.c
arch/alpha/kernel/core_marvel.c
arch/alpha/kernel/core_mcpcia.c
arch/alpha/kernel/core_t2.c
arch/alpha/kernel/core_titan.c
arch/alpha/kernel/core_tsunami.c
arch/alpha/kernel/core_wildfire.c
arch/alpha/kernel/pci-noop.c
arch/alpha/kernel/pci.c
arch/alpha/kernel/pci_iommu.c
arch/arm/kernel/setup.c
arch/arm/mach-omap2/omap_hwmod.c
arch/arm64/kernel/setup.c
arch/ia64/kernel/mca.c
arch/ia64/mm/tlb.c
arch/ia64/sn/kernel/io_common.c
arch/ia64/sn/kernel/setup.c
arch/m68k/sun3/sun3dvma.c
arch/microblaze/mm/init.c
arch/mips/kernel/setup.c
arch/powerpc/kernel/paca.c
arch/powerpc/kernel/pci_32.c
arch/powerpc/lib/alloc.c
arch/powerpc/mm/mmu_context_nohash.c
arch/powerpc/platforms/powermac/nvram.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/sysdev/msi_bitmap.c
arch/um/drivers/net_kern.c
arch/um/drivers/vector_kern.c
arch/um/kernel/initrd.c
arch/unicore32/kernel/setup.c
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/e820.c
arch/x86/platform/olpc/olpc_dt.c
arch/xtensa/platforms/iss/network.c
drivers/clk/ti/clk.c
drivers/firmware/efi/memmap.c
drivers/firmware/memmap.c
drivers/macintosh/smu.c
drivers/of/of_reserved_mem.c
include/linux/memblock.h
init/main.c
kernel/power/snapshot.c
lib/cpumask.c
mm/memblock.c
mm/page_alloc.c
mm/percpu.c
mm/sparse.c

index 1bf3eef34c22f6c1203ff7bcde4ec8f0f2f3822f..6df765ff2b1090cb5a7300e7880098f2abb316e7 100644 (file)
@@ -346,7 +346,8 @@ apecs_init_arch(void)
         * Window 1 is direct access 1GB at 1GB
         * Window 2 is scatter-gather 8MB at 8MB (for isa)
         */
-       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
+       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000,
+                                      SMP_CACHE_BYTES);
        hose->sg_pci = NULL;
        __direct_map_base = 0x40000000;
        __direct_map_size = 0x40000000;
index 81c0c43635b0710753ec6aaf9470abb651fece79..57e0750419f2900c0c59aae7194dff847cbea3a3 100644 (file)
@@ -275,7 +275,8 @@ lca_init_arch(void)
         * Note that we do not try to save any of the DMA window CSRs
         * before setting them, since we cannot read those CSRs on LCA.
         */
-       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
+       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000,
+                                      SMP_CACHE_BYTES);
        hose->sg_pci = NULL;
        __direct_map_base = 0x40000000;
        __direct_map_size = 0x40000000;
index 8a568c4d8e81cedcb5a9c91c93f32f480e4a0294..c1d0c18c71ca4c7d8523094d4ba4568418754336 100644 (file)
@@ -82,7 +82,7 @@ mk_resource_name(int pe, int port, char *str)
        char *name;
        
        sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port);
-       name = memblock_alloc(strlen(tmp) + 1, 0);
+       name = memblock_alloc(strlen(tmp) + 1, SMP_CACHE_BYTES);
        strcpy(name, tmp);
 
        return name;
@@ -117,7 +117,7 @@ alloc_io7(unsigned int pe)
                return NULL;
        }
 
-       io7 = memblock_alloc(sizeof(*io7), 0);
+       io7 = memblock_alloc(sizeof(*io7), SMP_CACHE_BYTES);
        io7->pe = pe;
        raw_spin_lock_init(&io7->irq_lock);
 
index b1549db54260fe99f6f6a3f36f35dfee22f3d87b..74b1d018124c3a75c7318929a0a6d102f11acff3 100644 (file)
@@ -364,9 +364,11 @@ mcpcia_startup_hose(struct pci_controller *hose)
         * Window 1 is scatter-gather (up to) 1GB at 1GB (for pci)
         * Window 2 is direct access 2GB at 2GB
         */
-       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
+       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000,
+                                      SMP_CACHE_BYTES);
        hose->sg_pci = iommu_arena_new(hose, 0x40000000,
-                                      size_for_memory(0x40000000), 0);
+                                      size_for_memory(0x40000000),
+                                      SMP_CACHE_BYTES);
 
        __direct_map_base = 0x80000000;
        __direct_map_size = 0x80000000;
index 2c00b61ca379e309b41cebad1cbe264b4b4640c5..98d5b6ff8a769632a12304bb165b1e9d06c96d45 100644 (file)
@@ -351,7 +351,7 @@ t2_sg_map_window2(struct pci_controller *hose,
 
        /* Note we can only do 1 SG window, as the other is for direct, so
           do an ISA SG area, especially for the floppy. */
-       hose->sg_isa = iommu_arena_new(hose, base, length, 0);
+       hose->sg_isa = iommu_arena_new(hose, base, length, SMP_CACHE_BYTES);
        hose->sg_pci = NULL;
 
        temp = (base & 0xfff00000UL) | ((base + length - 1) >> 20);
index 97551597581b07fcd96eabf50d3298e428d02f9a..2a2820fb1be63daa7ddf77aa66143dda4151e7fb 100644 (file)
@@ -316,10 +316,12 @@ titan_init_one_pachip_port(titan_pachip_port *port, int index)
         * Window 1 is direct access 1GB at 2GB
         * Window 2 is scatter-gather 1GB at 3GB
         */
-       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
+       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000,
+                                      SMP_CACHE_BYTES);
        hose->sg_isa->align_entry = 8; /* 64KB for ISA */
 
-       hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x40000000, 0);
+       hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x40000000,
+                                      SMP_CACHE_BYTES);
        hose->sg_pci->align_entry = 4; /* Titan caches 4 PTEs at a time */
 
        port->wsba[0].csr = hose->sg_isa->dma_base | 3;
index f334b8928d72a9c2ac68b102775094b55427bb0c..fc1ab73f23ded12f73fea93c16dff3f99780abc7 100644 (file)
@@ -319,12 +319,14 @@ tsunami_init_one_pchip(tsunami_pchip *pchip, int index)
         * NOTE: we need the align_entry settings for Acer devices on ES40,
         * specifically floppy and IDE when memory is larger than 2GB.
         */
-       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
+       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000,
+                                      SMP_CACHE_BYTES);
        /* Initially set for 4 PTEs, but will be overridden to 64K for ISA. */
         hose->sg_isa->align_entry = 4;
 
        hose->sg_pci = iommu_arena_new(hose, 0x40000000,
-                                      size_for_memory(0x40000000), 0);
+                                      size_for_memory(0x40000000),
+                                      SMP_CACHE_BYTES);
         hose->sg_pci->align_entry = 4; /* Tsunami caches 4 PTEs at a time */
 
        __direct_map_base = 0x80000000;
index cad36fc6ed7de05b4db8046ac9d9b0b5733ad955..353c03d1544202348bf5513c4b28977f6021142a 100644 (file)
@@ -111,8 +111,10 @@ wildfire_init_hose(int qbbno, int hoseno)
          * ??? We ought to scale window 3 memory.
          *
          */
-        hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
-        hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x08000000, 0);
+       hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000,
+                                      SMP_CACHE_BYTES);
+       hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x08000000,
+                                      SMP_CACHE_BYTES);
 
        pci = WILDFIRE_pci(qbbno, hoseno);
 
index a9378ee0c2f19b46c398782beacc74e91586921a..091cff3c68fd47cfa860761eade0587b8df43408 100644 (file)
@@ -33,7 +33,7 @@ alloc_pci_controller(void)
 {
        struct pci_controller *hose;
 
-       hose = memblock_alloc(sizeof(*hose), 0);
+       hose = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES);
 
        *hose_tail = hose;
        hose_tail = &hose->next;
@@ -44,7 +44,7 @@ alloc_pci_controller(void)
 struct resource * __init
 alloc_resource(void)
 {
-       return memblock_alloc(sizeof(struct resource), 0);
+       return memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
 }
 
 SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
index 13937e72d875748a0406fc2e17627ada27cc299a..97098127df8389e70a3e74e243728d090744b87e 100644 (file)
@@ -392,7 +392,7 @@ alloc_pci_controller(void)
 {
        struct pci_controller *hose;
 
-       hose = memblock_alloc(sizeof(*hose), 0);
+       hose = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES);
 
        *hose_tail = hose;
        hose_tail = &hose->next;
@@ -403,7 +403,7 @@ alloc_pci_controller(void)
 struct resource * __init
 alloc_resource(void)
 {
-       return memblock_alloc(sizeof(struct resource), 0);
+       return memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
 }
 
 
index 82cf950bda2a1f2f989107324b31583be6099d6c..46e08e0d91818b97d7193e4b045e4aa86904f013 100644 (file)
@@ -79,7 +79,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
                printk("%s: couldn't allocate arena from node %d\n"
                       "    falling back to system-wide allocation\n",
                       __func__, nid);
-               arena = memblock_alloc(sizeof(*arena), 0);
+               arena = memblock_alloc(sizeof(*arena), SMP_CACHE_BYTES);
        }
 
        arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid);
@@ -92,7 +92,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
 
 #else /* CONFIG_DISCONTIGMEM */
 
-       arena = memblock_alloc(sizeof(*arena), 0);
+       arena = memblock_alloc(sizeof(*arena), SMP_CACHE_BYTES);
        arena->ptes = memblock_alloc_from(mem_size, align, 0);
 
 #endif /* CONFIG_DISCONTIGMEM */
index 840a4adc69fcf429310b451d5d60b97211091899..ac7e08886863cfa74855e5b91c4f436e85da1e0a 100644 (file)
@@ -856,7 +856,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
                 */
                boot_alias_start = phys_to_idmap(start);
                if (arm_has_idmap_alias() && boot_alias_start != IDMAP_INVALID_ADDR) {
-                       res = memblock_alloc(sizeof(*res), 0);
+                       res = memblock_alloc(sizeof(*res), SMP_CACHE_BYTES);
                        res->name = "System RAM (boot alias)";
                        res->start = boot_alias_start;
                        res->end = phys_to_idmap(end);
@@ -864,7 +864,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
                        request_resource(&iomem_resource, res);
                }
 
-               res = memblock_alloc(sizeof(*res), 0);
+               res = memblock_alloc(sizeof(*res), SMP_CACHE_BYTES);
                res->name  = "System RAM";
                res->start = start;
                res->end = end;
index cd5732ab0cdf78f9bf5967dc212d5ceeaede08ef..083dcd9942ce5c8643f0f56a8731f722fa514f63 100644 (file)
@@ -726,7 +726,7 @@ static int __init _setup_clkctrl_provider(struct device_node *np)
        u64 size;
        int i;
 
-       provider = memblock_alloc(sizeof(*provider), 0);
+       provider = memblock_alloc(sizeof(*provider), SMP_CACHE_BYTES);
        if (!provider)
                return -ENOMEM;
 
@@ -736,12 +736,14 @@ static int __init _setup_clkctrl_provider(struct device_node *np)
                of_property_count_elems_of_size(np, "reg", sizeof(u32)) / 2;
 
        provider->addr =
-               memblock_alloc(sizeof(void *) * provider->num_addrs, 0);
+               memblock_alloc(sizeof(void *) * provider->num_addrs,
+                              SMP_CACHE_BYTES);
        if (!provider->addr)
                return -ENOMEM;
 
        provider->size =
-               memblock_alloc(sizeof(u32) * provider->num_addrs, 0);
+               memblock_alloc(sizeof(u32) * provider->num_addrs,
+                              SMP_CACHE_BYTES);
        if (!provider->size)
                return -ENOMEM;
 
index 7ce7306f1d75e9582759afb36dff48266ebced21..953e316521fcaa34fcbe26a9ca8ca7de6b9f51e9 100644 (file)
@@ -218,7 +218,7 @@ static void __init request_standard_resources(void)
        num_standard_resources = memblock.memory.cnt;
        standard_resources = memblock_alloc_low(num_standard_resources *
                                                sizeof(*standard_resources),
-                                               0);
+                                               SMP_CACHE_BYTES);
 
        for_each_memblock(memory, region) {
                res = &standard_resources[i++];
index 9a6603f8e409d6245ce921cd6679378a17678962..91bd1e129379db09a7cc0ac60c41d5d94d04fc70 100644 (file)
@@ -361,9 +361,9 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
 
 #define IA64_LOG_ALLOCATE(it, size) \
        {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \
-               (ia64_err_rec_t *)memblock_alloc(size, 0); \
+               (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES); \
        ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \
-               (ia64_err_rec_t *)memblock_alloc(size, 0);}
+               (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES);}
 #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock)
 #define IA64_LOG_LOCK(it)      spin_lock_irqsave(&ia64_state_log[it].isl_lock, s)
 #define IA64_LOG_UNLOCK(it)    spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s)
index ab545daff7c372de29bb5ee41e672593e9cc3547..9340bcb4f29c4ee0f0fa9868ae0571efff635d4a 100644 (file)
@@ -59,8 +59,10 @@ struct ia64_tr_entry *ia64_idtrs[NR_CPUS];
 void __init
 mmu_context_init (void)
 {
-       ia64_ctx.bitmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, 0);
-       ia64_ctx.flushmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3, 0);
+       ia64_ctx.bitmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3,
+                                        SMP_CACHE_BYTES);
+       ia64_ctx.flushmap = memblock_alloc((ia64_ctx.max_ctx + 1) >> 3,
+                                          SMP_CACHE_BYTES);
 }
 
 /*
index 98f55220c67df0cbf5c3c69bde23c01a61d0edd0..8df13d0d96fa30f25ec94040715c3e93978e1d00 100644 (file)
@@ -391,7 +391,9 @@ void __init hubdev_init_node(nodepda_t * npda, cnodeid_t node)
        if (node >= num_online_nodes()) /* Headless/memless IO nodes */
                node = 0;
 
-       hubdev_info = (struct hubdev_info *)memblock_alloc_node(size, 0, node);
+       hubdev_info = (struct hubdev_info *)memblock_alloc_node(size,
+                                                               SMP_CACHE_BYTES,
+                                                               node);
 
        npda->pdinfo = (void *)hubdev_info;
 }
index 71ad6b0ccab4f995c382046f1af5d44eda2a354f..a6d40a2c5bffcc5b19a66311a832a5522af278de 100644 (file)
@@ -511,7 +511,8 @@ static void __init sn_init_pdas(char **cmdline_p)
         */
        for_each_online_node(cnode) {
                nodepdaindr[cnode] =
-                   memblock_alloc_node(sizeof(nodepda_t), 0, cnode);
+                   memblock_alloc_node(sizeof(nodepda_t), SMP_CACHE_BYTES,
+                                       cnode);
                memset(nodepdaindr[cnode]->phys_cpuid, -1,
                    sizeof(nodepdaindr[cnode]->phys_cpuid));
                spin_lock_init(&nodepdaindr[cnode]->ptc_lock);
@@ -522,7 +523,7 @@ static void __init sn_init_pdas(char **cmdline_p)
         */
        for (cnode = num_online_nodes(); cnode < num_cnodes; cnode++)
                nodepdaindr[cnode] =
-                   memblock_alloc_node(sizeof(nodepda_t), 0, 0);
+                   memblock_alloc_node(sizeof(nodepda_t), SMP_CACHE_BYTES, 0);
 
        /*
         * Now copy the array of nodepda pointers to each nodepda.
index 8be8b750c6293d8857b43dcdb9a61cf76950f6cf..4d64711d3d47410cead0940360885ccf22617cae 100644 (file)
@@ -268,7 +268,7 @@ void __init dvma_init(void)
        list_add(&(hole->list), &hole_list);
 
        iommu_use = memblock_alloc(IOMMU_TOTAL_ENTRIES * sizeof(unsigned long),
-                                  0);
+                                  SMP_CACHE_BYTES);
 
        dvma_unmap_iommu(DVMA_START, DVMA_SIZE);
 
index 8c14988f52f24b0d7878ee0d2b3aabf9c29deaea..b17fd8aafd64aabd3c667c81394a81ab6f3b8583 100644 (file)
@@ -376,7 +376,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
        if (mem_init_done)
                p = kzalloc(size, mask);
        else {
-               p = memblock_alloc(size, 0);
+               p = memblock_alloc(size, SMP_CACHE_BYTES);
                if (p)
                        memset(p, 0, size);
        }
index 41c1683761bbd8cad6536e3b9585b09e2ee2121e..ea09ed6a80a9f2dc0aa625e2fcec0b34e2c6acea 100644 (file)
@@ -916,7 +916,7 @@ static void __init resource_init(void)
                if (end >= HIGHMEM_START)
                        end = HIGHMEM_START - 1;
 
-               res = memblock_alloc(sizeof(struct resource), 0);
+               res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
 
                res->start = start;
                res->end = end;
index f331a0054b3a822c0950d498cd9db693c77882bf..913bfca09c4f1f0a19be2e0e87b55257be3321f6 100644 (file)
@@ -198,7 +198,7 @@ void __init allocate_paca_ptrs(void)
        paca_nr_cpu_ids = nr_cpu_ids;
 
        paca_ptrs_size = sizeof(struct paca_struct *) * nr_cpu_ids;
-       paca_ptrs = __va(memblock_phys_alloc(paca_ptrs_size, 0));
+       paca_ptrs = __va(memblock_phys_alloc(paca_ptrs_size, SMP_CACHE_BYTES));
        memset(paca_ptrs, 0x88, paca_ptrs_size);
 }
 
index 274bd1442dd91e29399ac432e5fcabe2c9b54722..d3f04f2d824944d9947993b00fa8aec0bb0fdf08 100644 (file)
@@ -203,7 +203,8 @@ pci_create_OF_bus_map(void)
        struct property* of_prop;
        struct device_node *dn;
 
-       of_prop = memblock_alloc(sizeof(struct property) + 256, 0);
+       of_prop = memblock_alloc(sizeof(struct property) + 256,
+                                SMP_CACHE_BYTES);
        dn = of_find_node_by_path("/");
        if (dn) {
                memset(of_prop, -1, sizeof(struct property) + 256);
index 5b61704447c18bfb54920413ed27e2b60a0f9505..dedf88a76f58cc81c0de00bbb6e8e96420f78094 100644 (file)
@@ -14,7 +14,7 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
        if (slab_is_available())
                p = kzalloc(size, mask);
        else {
-               p = memblock_alloc(size, 0);
+               p = memblock_alloc(size, SMP_CACHE_BYTES);
        }
        return p;
 }
index 67b9d7b669a134cc71a07b06e052cb873723978e..2faca46ad720ca4e24045a14cc18e154feff3f93 100644 (file)
@@ -461,10 +461,11 @@ void __init mmu_context_init(void)
        /*
         * Allocate the maps used by context management
         */
-       context_map = memblock_alloc(CTX_MAP_SIZE, 0);
-       context_mm = memblock_alloc(sizeof(void *) * (LAST_CONTEXT + 1), 0);
+       context_map = memblock_alloc(CTX_MAP_SIZE, SMP_CACHE_BYTES);
+       context_mm = memblock_alloc(sizeof(void *) * (LAST_CONTEXT + 1),
+                                   SMP_CACHE_BYTES);
 #ifdef CONFIG_SMP
-       stale_map[boot_cpuid] = memblock_alloc(CTX_MAP_SIZE, 0);
+       stale_map[boot_cpuid] = memblock_alloc(CTX_MAP_SIZE, SMP_CACHE_BYTES);
 
        cpuhp_setup_state_nocalls(CPUHP_POWERPC_MMU_CTX_PREPARE,
                                  "powerpc/mmu/ctx:prepare",
index f3391be7c762cb4f0fa1272c14bd77f4f00f986c..ae54d7fe68f3628da3a7eaec671c23ae25d208f0 100644 (file)
@@ -513,7 +513,7 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)
                printk(KERN_ERR "nvram: no address\n");
                return -EINVAL;
        }
-       nvram_image = memblock_alloc(NVRAM_SIZE, 0);
+       nvram_image = memblock_alloc(NVRAM_SIZE, SMP_CACHE_BYTES);
        nvram_data = ioremap(addr, NVRAM_SIZE*2);
        nvram_naddrs = 1; /* Make sure we get the correct case */
 
index aba81cbf0b366e64f01daacd2888fbbbc2c0a215..dd807446801efea02ccf1754739608c2854b477c 100644 (file)
@@ -3769,7 +3769,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
        phb_id = be64_to_cpup(prop64);
        pr_debug("  PHB-ID  : 0x%016llx\n", phb_id);
 
-       phb = memblock_alloc(sizeof(*phb), 0);
+       phb = memblock_alloc(sizeof(*phb), SMP_CACHE_BYTES);
 
        /* Allocate PCI controller */
        phb->hose = hose = pcibios_alloc_controller(np);
@@ -3815,7 +3815,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
        else
                phb->diag_data_size = PNV_PCI_DIAG_BUF_SIZE;
 
-       phb->diag_data = memblock_alloc(phb->diag_data_size, 0);
+       phb->diag_data = memblock_alloc(phb->diag_data_size, SMP_CACHE_BYTES);
 
        /* Parse 32-bit and IO ranges (if any) */
        pci_process_bridge_OF_ranges(hose, np, !hose->global_number);
@@ -3874,7 +3874,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
        }
        pemap_off = size;
        size += phb->ioda.total_pe_num * sizeof(struct pnv_ioda_pe);
-       aux = memblock_alloc(size, 0);
+       aux = memblock_alloc(size, SMP_CACHE_BYTES);
        phb->ioda.pe_alloc = aux;
        phb->ioda.m64_segmap = aux + m64map_off;
        phb->ioda.m32_segmap = aux + m32map_off;
index 2444feda831f4ee841acb4756a7a4467a02b8e20..d45450f6666a9966e63eb15c74ed5cb89a9ff98c 100644 (file)
@@ -128,7 +128,7 @@ int __ref msi_bitmap_alloc(struct msi_bitmap *bmp, unsigned int irq_count,
        if (bmp->bitmap_from_slab)
                bmp->bitmap = kzalloc(size, GFP_KERNEL);
        else {
-               bmp->bitmap = memblock_alloc(size, 0);
+               bmp->bitmap = memblock_alloc(size, SMP_CACHE_BYTES);
                /* the bitmap won't be freed from memblock allocator */
                kmemleak_not_leak(bmp->bitmap);
        }
index 673816880cce3454f50c4f35e1589b53728eeb70..624cb47cc9cd35b56c10a27e565c64b078cd84fa 100644 (file)
@@ -650,7 +650,7 @@ static int __init eth_setup(char *str)
                return 1;
        }
 
-       new = memblock_alloc(sizeof(*new), 0);
+       new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES);
 
        INIT_LIST_HEAD(&new->list);
        new->index = n;
index 2b4dded11a7a2fbac27bb89ed5ce236cc5fbf9f8..10d8d20eb9ecff2184663ba3701b02bac1e1e35a 100644 (file)
@@ -1580,7 +1580,7 @@ static int __init vector_setup(char *str)
                                 str, error);
                return 1;
        }
-       new = memblock_alloc(sizeof(*new), 0);
+       new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES);
        INIT_LIST_HEAD(&new->list);
        new->unit = n;
        new->arguments = str;
index 3678f5b05e427f8699eabbee586a751426d2dd8c..ce169ea87e6189e6ca025a41711638ab5ff9d483 100644 (file)
@@ -36,7 +36,7 @@ int __init read_initrd(void)
                return 0;
        }
 
-       area = memblock_alloc(size, 0);
+       area = memblock_alloc(size, SMP_CACHE_BYTES);
 
        if (load_initrd(initrd, area, size) == -1)
                return 0;
index b2c38b32ea57d497d67bc9dc91d8933dd8d3e933..4b0cb68c355ac0458653613be25571f557393e04 100644 (file)
@@ -206,7 +206,7 @@ request_standard_resources(struct meminfo *mi)
                if (mi->bank[i].size == 0)
                        continue;
 
-               res = memblock_alloc_low(sizeof(*res), 0);
+               res = memblock_alloc_low(sizeof(*res), SMP_CACHE_BYTES);
                res->name  = "System RAM";
                res->start = mi->bank[i].start;
                res->end   = mi->bank[i].start + mi->bank[i].size - 1;
index 7f5d212551d4dcea8b2ec28ea8b7971ecbbdf0c0..92c76bf97ad828436405ce27398d48ce25132f65 100644 (file)
@@ -934,7 +934,7 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
         */
 #define HPET_RESOURCE_NAME_SIZE 9
        hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
-                                 0);
+                                 SMP_CACHE_BYTES);
 
        hpet_res->name = (void *)&hpet_res[1];
        hpet_res->flags = IORESOURCE_MEM;
index 5fbc57e4b0b9b4606fa866b06a699805536762db..2953bbf05c0857e36fc11ec7a7ae272e9e63bb63 100644 (file)
@@ -2578,7 +2578,7 @@ static struct resource * __init ioapic_setup_resources(void)
        n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
        n *= nr_ioapics;
 
-       mem = memblock_alloc(n, 0);
+       mem = memblock_alloc(n, SMP_CACHE_BYTES);
        res = (void *)mem;
 
        mem += sizeof(struct resource) * nr_ioapics;
index 68ff62bffbabe089fcfa5049162fa0b4533683aa..50895c2f937d144f9fd2b133c0522aadc7841c9e 100644 (file)
@@ -1093,7 +1093,8 @@ void __init e820__reserve_resources(void)
        struct resource *res;
        u64 end;
 
-       res = memblock_alloc(sizeof(*res) * e820_table->nr_entries, 0);
+       res = memblock_alloc(sizeof(*res) * e820_table->nr_entries,
+                            SMP_CACHE_BYTES);
        e820_res = res;
 
        for (i = 0; i < e820_table->nr_entries; i++) {
index 115c8e4173bb1647756ba54cf7ebc8fae138982b..24d2175a948038a530078540e3e412240d32706e 100644 (file)
@@ -141,7 +141,7 @@ void * __init prom_early_alloc(unsigned long size)
                 * fast enough on the platforms we care about while minimizing
                 * wasted bootmem) and hand off chunks of it to callers.
                 */
-               res = memblock_alloc(chunk_size, 0);
+               res = memblock_alloc(chunk_size, SMP_CACHE_BYTES);
                BUG_ON(!res);
                prom_early_allocated += chunk_size;
                memset(res, 0, chunk_size);
index 190846dddc675747c178a05e781474b93d7f3348..d052712373b660e78cd4234afcc5fabb1917a830 100644 (file)
@@ -646,7 +646,7 @@ static int __init iss_net_setup(char *str)
                return 1;
        }
 
-       new = memblock_alloc(sizeof(*new), 0);
+       new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES);
        if (new == NULL) {
                pr_err("Alloc_bootmem failed\n");
                return 1;
index 5b2867a33b98d76fd09862d5be7f953bd5fcd098..e205af8145821d072d099d657ca9a04325d36ef0 100644 (file)
@@ -342,7 +342,7 @@ void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem)
 {
        struct clk_iomap *io;
 
-       io = memblock_alloc(sizeof(*io), 0);
+       io = memblock_alloc(sizeof(*io), SMP_CACHE_BYTES);
 
        io->mem = mem;
 
index ef618bceb79a4a928c7fe291088a9243d116a9b9..fa2904fb841fe459a6562b9fea237c5213fa97be 100644 (file)
@@ -15,7 +15,7 @@
 
 static phys_addr_t __init __efi_memmap_alloc_early(unsigned long size)
 {
-       return memblock_phys_alloc(size, 0);
+       return memblock_phys_alloc(size, SMP_CACHE_BYTES);
 }
 
 static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size)
index 2a23453f005add9fab3d9bda7fb823b95d9b8f1e..d168c87c7d3085655d1fd627a6b65b792129cb03 100644 (file)
@@ -333,7 +333,8 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type)
 {
        struct firmware_map_entry *entry;
 
-       entry = memblock_alloc(sizeof(struct firmware_map_entry), 0);
+       entry = memblock_alloc(sizeof(struct firmware_map_entry),
+                              SMP_CACHE_BYTES);
        if (WARN_ON(!entry))
                return -ENOMEM;
 
index 880a81c82b7a98a9b96a83841acb6147a22f6d93..0a0b8e1f4236f701640a5c0e7c9056c0c3c88d01 100644 (file)
@@ -492,7 +492,7 @@ int __init smu_init (void)
                goto fail_np;
        }
 
-       smu = memblock_alloc(sizeof(struct smu_device), 0);
+       smu = memblock_alloc(sizeof(struct smu_device), SMP_CACHE_BYTES);
 
        spin_lock_init(&smu->lock);
        INIT_LIST_HEAD(&smu->cmd_list);
index d6255c276a41333323f9a4a200bd22d02dafbf02..1977ee0adcb1b46b730d26e8a82fad93ce25beb8 100644 (file)
@@ -36,6 +36,7 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
         * panic()s on allocation failure.
         */
        end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end;
+       align = !align ? SMP_CACHE_BYTES : align;
        base = __memblock_alloc_base(size, align, end);
        if (!base)
                return -ENOMEM;
index 1b4d85879cbe1f923222c5178f1d7e074bf8027c..aee299a6aa76d328f4d0bcf3494a5ad93b496ee9 100644 (file)
@@ -406,7 +406,8 @@ static inline void * __init memblock_alloc_node(phys_addr_t size,
 static inline void * __init memblock_alloc_node_nopanic(phys_addr_t size,
                                                        int nid)
 {
-       return memblock_alloc_try_nid_nopanic(size, 0, MEMBLOCK_LOW_LIMIT,
+       return memblock_alloc_try_nid_nopanic(size, SMP_CACHE_BYTES,
+                                             MEMBLOCK_LOW_LIMIT,
                                              MEMBLOCK_ALLOC_ACCESSIBLE, nid);
 }
 
index 51b8e7b8ae5b6f2635978cbdca1069269155e734..ee147103ba1bae45798b06ba2705a917bc5cc8d6 100644 (file)
@@ -375,10 +375,11 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
 static void __init setup_command_line(char *command_line)
 {
        saved_command_line =
-               memblock_alloc(strlen(boot_command_line) + 1, 0);
+               memblock_alloc(strlen(boot_command_line) + 1, SMP_CACHE_BYTES);
        initcall_command_line =
-               memblock_alloc(strlen(boot_command_line) + 1, 0);
-       static_command_line = memblock_alloc(strlen(command_line) + 1, 0);
+               memblock_alloc(strlen(boot_command_line) + 1, SMP_CACHE_BYTES);
+       static_command_line = memblock_alloc(strlen(command_line) + 1,
+                                            SMP_CACHE_BYTES);
        strcpy(saved_command_line, boot_command_line);
        strcpy(static_command_line, command_line);
 }
@@ -773,8 +774,10 @@ static int __init initcall_blacklist(char *str)
                str_entry = strsep(&str, ",");
                if (str_entry) {
                        pr_debug("blacklisting initcall %s\n", str_entry);
-                       entry = memblock_alloc(sizeof(*entry), 0);
-                       entry->buf = memblock_alloc(strlen(str_entry) + 1, 0);
+                       entry = memblock_alloc(sizeof(*entry),
+                                              SMP_CACHE_BYTES);
+                       entry->buf = memblock_alloc(strlen(str_entry) + 1,
+                                                   SMP_CACHE_BYTES);
                        strcpy(entry->buf, str_entry);
                        list_add(&entry->next, &blacklisted_initcalls);
                }
index 3c9e365438ad2491c3dab28ba2cc2386a2b5d40a..b0308a2c6000d3bf34b897a5a2d248049cb4c492 100644 (file)
@@ -963,7 +963,8 @@ void __init __register_nosave_region(unsigned long start_pfn,
                BUG_ON(!region);
        } else {
                /* This allocation cannot fail */
-               region = memblock_alloc(sizeof(struct nosave_region), 0);
+               region = memblock_alloc(sizeof(struct nosave_region),
+                                       SMP_CACHE_BYTES);
        }
        region->start_pfn = start_pfn;
        region->end_pfn = end_pfn;
index 75b5e7672c4c215c3c54e4105fb9586d95a70b27..8d666ab84b5c38fbcc0df25d7e6b0dbe0e81d68c 100644 (file)
@@ -163,7 +163,7 @@ EXPORT_SYMBOL(zalloc_cpumask_var);
  */
 void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask)
 {
-       *mask = memblock_alloc(cpumask_size(), 0);
+       *mask = memblock_alloc(cpumask_size(), SMP_CACHE_BYTES);
 }
 
 /**
index c655342569f886fca976929f6e3086caa4d8c7e5..8395311338167196a6747cf867ceb578e61d160c 100644 (file)
@@ -1247,9 +1247,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
 {
        phys_addr_t found;
 
-       if (!align)
-               align = SMP_CACHE_BYTES;
-
        found = memblock_find_in_range_node(size, align, start, end, nid,
                                            flags);
        if (found && !memblock_reserve(found, size)) {
@@ -1343,8 +1340,6 @@ phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t ali
  * The allocation is performed from memory region limited by
  * memblock.current_limit if @max_addr == %MEMBLOCK_ALLOC_ACCESSIBLE.
  *
- * The memory block is aligned on %SMP_CACHE_BYTES if @align == 0.
- *
  * The phys address of allocated boot memory block is converted to virtual and
  * allocated memory is reset to 0.
  *
@@ -1374,9 +1369,6 @@ static void * __init memblock_alloc_internal(
        if (WARN_ON_ONCE(slab_is_available()))
                return kzalloc_node(size, GFP_NOWAIT, nid);
 
-       if (!align)
-               align = SMP_CACHE_BYTES;
-
        if (max_addr > memblock.current_limit)
                max_addr = memblock.current_limit;
 again:
index ef289fadec0e44fdc16cd594eba1533924f69d36..a919ba5cb3c845e03e4a070eff354acf19ec7c4a 100644 (file)
@@ -7710,9 +7710,11 @@ void *__init alloc_large_system_hash(const char *tablename,
                size = bucketsize << log2qty;
                if (flags & HASH_EARLY) {
                        if (flags & HASH_ZERO)
-                               table = memblock_alloc_nopanic(size, 0);
+                               table = memblock_alloc_nopanic(size,
+                                                              SMP_CACHE_BYTES);
                        else
-                               table = memblock_alloc_raw(size, 0);
+                               table = memblock_alloc_raw(size,
+                                                          SMP_CACHE_BYTES);
                } else if (hashdist) {
                        table = __vmalloc(size, gfp_flags, PAGE_KERNEL);
                } else {
index 61cdbb3b373664f7ae54f1f51539ec29e58bbeb7..a6b74c6fe0becd3ef42284aa643933ae4fb7f0cf 100644 (file)
@@ -1102,8 +1102,8 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr,
 
        /* allocate chunk */
        chunk = memblock_alloc(sizeof(struct pcpu_chunk) +
-                                   BITS_TO_LONGS(region_size >> PAGE_SHIFT),
-                                   0);
+                              BITS_TO_LONGS(region_size >> PAGE_SHIFT),
+                              SMP_CACHE_BYTES);
 
        INIT_LIST_HEAD(&chunk->list);
 
@@ -1114,12 +1114,12 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr,
        chunk->nr_pages = region_size >> PAGE_SHIFT;
        region_bits = pcpu_chunk_map_bits(chunk);
 
-       chunk->alloc_map = memblock_alloc(BITS_TO_LONGS(region_bits) *
-                                              sizeof(chunk->alloc_map[0]), 0);
-       chunk->bound_map = memblock_alloc(BITS_TO_LONGS(region_bits + 1) *
-                                              sizeof(chunk->bound_map[0]), 0);
-       chunk->md_blocks = memblock_alloc(pcpu_chunk_nr_blocks(chunk) *
-                                              sizeof(chunk->md_blocks[0]), 0);
+       chunk->alloc_map = memblock_alloc(BITS_TO_LONGS(region_bits) * sizeof(chunk->alloc_map[0]),
+                                         SMP_CACHE_BYTES);
+       chunk->bound_map = memblock_alloc(BITS_TO_LONGS(region_bits + 1) * sizeof(chunk->bound_map[0]),
+                                         SMP_CACHE_BYTES);
+       chunk->md_blocks = memblock_alloc(pcpu_chunk_nr_blocks(chunk) * sizeof(chunk->md_blocks[0]),
+                                         SMP_CACHE_BYTES);
        pcpu_init_md_blocks(chunk);
 
        /* manage populated page bitmap */
@@ -2075,12 +2075,14 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
        PCPU_SETUP_BUG_ON(pcpu_verify_alloc_info(ai) < 0);
 
        /* process group information and build config tables accordingly */
-       group_offsets = memblock_alloc(ai->nr_groups *
-                                            sizeof(group_offsets[0]), 0);
-       group_sizes = memblock_alloc(ai->nr_groups *
-                                          sizeof(group_sizes[0]), 0);
-       unit_map = memblock_alloc(nr_cpu_ids * sizeof(unit_map[0]), 0);
-       unit_off = memblock_alloc(nr_cpu_ids * sizeof(unit_off[0]), 0);
+       group_offsets = memblock_alloc(ai->nr_groups * sizeof(group_offsets[0]),
+                                      SMP_CACHE_BYTES);
+       group_sizes = memblock_alloc(ai->nr_groups * sizeof(group_sizes[0]),
+                                    SMP_CACHE_BYTES);
+       unit_map = memblock_alloc(nr_cpu_ids * sizeof(unit_map[0]),
+                                 SMP_CACHE_BYTES);
+       unit_off = memblock_alloc(nr_cpu_ids * sizeof(unit_off[0]),
+                                 SMP_CACHE_BYTES);
 
        for (cpu = 0; cpu < nr_cpu_ids; cpu++)
                unit_map[cpu] = UINT_MAX;
@@ -2144,8 +2146,8 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
         * empty chunks.
         */
        pcpu_nr_slots = __pcpu_size_to_slot(pcpu_unit_size) + 2;
-       pcpu_slot = memblock_alloc(
-                       pcpu_nr_slots * sizeof(pcpu_slot[0]), 0);
+       pcpu_slot = memblock_alloc(pcpu_nr_slots * sizeof(pcpu_slot[0]),
+                                  SMP_CACHE_BYTES);
        for (i = 0; i < pcpu_nr_slots; i++)
                INIT_LIST_HEAD(&pcpu_slot[i]);
 
@@ -2458,7 +2460,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
        size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
        areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *));
 
-       areas = memblock_alloc_nopanic(areas_size, 0);
+       areas = memblock_alloc_nopanic(areas_size, SMP_CACHE_BYTES);
        if (!areas) {
                rc = -ENOMEM;
                goto out_free;
@@ -2599,7 +2601,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
        /* unaligned allocations can't be freed, round up to page size */
        pages_size = PFN_ALIGN(unit_pages * num_possible_cpus() *
                               sizeof(pages[0]));
-       pages = memblock_alloc(pages_size, 0);
+       pages = memblock_alloc(pages_size, SMP_CACHE_BYTES);
 
        /* allocate pages */
        j = 0;
index ab2ac45e044091357751cb71e204b573128708cc..33307fc05c4d3372d5e4746116330532765e61d7 100644 (file)
@@ -68,7 +68,8 @@ static noinline struct mem_section __ref *sparse_index_alloc(int nid)
        if (slab_is_available())
                section = kzalloc_node(array_size, GFP_KERNEL, nid);
        else
-               section = memblock_alloc_node(array_size, 0, nid);
+               section = memblock_alloc_node(array_size, SMP_CACHE_BYTES,
+                                             nid);
 
        return section;
 }