mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 21:24:08 +08:00
mm/memblock.c: warn if zero alignment was requested
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. [sfr@canb.auug.org.au: use dump_stack() instead of WARN_ON_ONCE for the alignment checks] Link: http://lkml.kernel.org/r/20181016131927.6ceba6ab@canb.auug.org.au [akpm@linux-foundation.org: add apologetic comment] Link: http://lkml.kernel.org/r/20181011060850.GA19822@rapoport-lnx Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
7e1c4e2792
commit
2f770806fd
@ -1247,6 +1247,12 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
|
|||||||
{
|
{
|
||||||
phys_addr_t found;
|
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,
|
found = memblock_find_in_range_node(size, align, start, end, nid,
|
||||||
flags);
|
flags);
|
||||||
if (found && !memblock_reserve(found, size)) {
|
if (found && !memblock_reserve(found, size)) {
|
||||||
@ -1369,6 +1375,11 @@ static void * __init memblock_alloc_internal(
|
|||||||
if (WARN_ON_ONCE(slab_is_available()))
|
if (WARN_ON_ONCE(slab_is_available()))
|
||||||
return kzalloc_node(size, GFP_NOWAIT, nid);
|
return kzalloc_node(size, GFP_NOWAIT, nid);
|
||||||
|
|
||||||
|
if (!align) {
|
||||||
|
dump_stack();
|
||||||
|
align = SMP_CACHE_BYTES;
|
||||||
|
}
|
||||||
|
|
||||||
if (max_addr > memblock.current_limit)
|
if (max_addr > memblock.current_limit)
|
||||||
max_addr = memblock.current_limit;
|
max_addr = memblock.current_limit;
|
||||||
again:
|
again:
|
||||||
|
Loading…
Reference in New Issue
Block a user