Skip to content

Commit

Permalink
mm/memblock.c: warn if zero alignment was requested
Browse files Browse the repository at this point in the history
After updating all memblock users to explicitly specify SMP_CACHE_BYTES
alignment rather than use 0, it is still possible that uncovered users may
sneak in.  Add a WARN_ON_ONCE for such cases.

[[email protected]: use dump_stack() instead of WARN_ON_ONCE for the alignment checks]
  Link: http://lkml.kernel.org/r/[email protected]
[[email protected]: add apologetic comment]
Link: http://lkml.kernel.org/r/20181011060850.GA19822@rapoport-lnx
Signed-off-by: Mike Rapoport <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rppt authored and torvalds committed Oct 31, 2018
1 parent 7e1c4e2 commit 2f77080
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,12 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
{
phys_addr_t found;

if (!align) {
/* Can't use WARNs this early in boot on powerpc */
dump_stack();
align = SMP_CACHE_BYTES;
}

found = memblock_find_in_range_node(size, align, start, end, nid,
flags);
if (found && !memblock_reserve(found, size)) {
Expand Down Expand Up @@ -1369,6 +1375,11 @@ static void * __init memblock_alloc_internal(
if (WARN_ON_ONCE(slab_is_available()))
return kzalloc_node(size, GFP_NOWAIT, nid);

if (!align) {
dump_stack();
align = SMP_CACHE_BYTES;
}

if (max_addr > memblock.current_limit)
max_addr = memblock.current_limit;
again:
Expand Down

0 comments on commit 2f77080

Please sign in to comment.