linux-stable/arch/um/kernel
Mike Rapoport 7e1c4e2792 memblock: stop using implicit alignment to SMP_CACHE_BYTES
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>
2018-10-31 08:54:16 -07:00
..
skas um: switch to RAW_COPY_USER 2017-03-28 18:24:03 -04:00
asm-offsets.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
config.c.in um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
dyn.lds.S Construct init thread stack in the linker script rather than by union 2018-01-09 23:21:02 +00:00
early_printk.c early_printk: consolidate random copies of identical code 2013-04-29 18:28:13 -07:00
exec.c sched/headers: Prepare to remove the <linux/mm_types.h> dependency from <linux/sched.h> 2017-03-02 08:42:37 +01:00
exitcode.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
gmon_syms.c um: Fix CONFIG_GCOV for modules. 2017-09-13 22:33:54 +02:00
gprof_syms.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
initrd.c memblock: stop using implicit alignment to SMP_CACHE_BYTES 2018-10-31 08:54:16 -07:00
irq.c um: Add missing EXPORT for free_irq_by_fd() 2018-02-19 19:38:51 +01:00
kmsg_dump.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ksyms.c um: Move syscall() declaration into os.h 2015-05-31 13:14:07 +02:00
maccess.c um: Implement probe_kernel_read() 2013-09-07 10:38:34 +02:00
Makefile um: Support kcov 2016-08-04 00:18:06 +02:00
mem.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
physmem.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
process.c um: Fix FP register size for XSTATE/XSAVE 2017-09-13 22:24:38 +02:00
ptrace.c signal/um: Use force_sig_fault where appropriate 2018-04-25 10:44:11 -05:00
reboot.c sched/headers: Prepare to remove the <linux/mm_types.h> dependency from <linux/sched.h> 2017-03-02 08:42:37 +01:00
sigio.c um: get rid of pointless include "..." where include <...> will do 2012-10-09 22:28:45 +02:00
signal.c Revert "um: Fix get_signal() usage" 2016-03-05 22:16:40 +01:00
stacktrace.c um: Add support for CONFIG_STACKTRACE 2014-10-13 21:46:25 +02:00
syscall.c mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff() 2018-04-02 20:16:11 +02:00
sysrq.c um: Fix _print_addr() 2017-05-03 22:30:20 +02:00
time.c um: time: Use timespec64 for persistent clock 2018-02-19 19:38:51 +01:00
tlb.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h> 2017-03-02 08:42:29 +01:00
trap.c mm: convert return type of handle_mm_fault() caller to vm_fault_t 2018-08-17 16:20:28 -07:00
um_arch.c Construct init thread stack in the linker script rather than by union 2018-01-09 23:21:02 +00:00
umid.c um: Use os_warn to print out pre-boot warning/error messages 2017-07-05 23:18:25 +02:00
uml.lds.S Construct init thread stack in the linker script rather than by union 2018-01-09 23:21:02 +00:00
vmlinux.lds.S arm, cris, mips, sparc, powerpc, um, xtensa: fix build with bash 4.0 2009-09-20 12:28:22 +02:00