Skip to content

Commit

Permalink
mm, memory_hotplug: replace for_device by want_memblock in arch_add_m…
Browse files Browse the repository at this point in the history
…emory

arch_add_memory gets for_device argument which then controls whether we
want to create memblocks for created memory sections.  Simplify the
logic by telling whether we want memblocks directly rather than going
through pointless negation.  This also makes the api easier to
understand because it is clear what we want rather than nothing telling
for_device which can mean anything.

This shouldn't introduce any functional change.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Michal Hocko <[email protected]>
Tested-by: Dan Williams <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Daniel Kiper <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Igor Mammedov <[email protected]>
Cc: Jerome Glisse <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Reza Arbab <[email protected]>
Cc: Tobias Regnery <[email protected]>
Cc: Toshi Kani <[email protected]>
Cc: Vitaly Kuznetsov <[email protected]>
Cc: Xishi Qiu <[email protected]>
Cc: Yasuaki Ishimatsu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Michal Hocko authored and torvalds committed Jul 6, 2017
1 parent c246a21 commit 3d79a72
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions arch/ia64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,13 @@ mem_init (void)
}

#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
int ret;

ret = __add_pages(nid, start_pfn, nr_pages, !for_device);
ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
if (ret)
printk("%s: Problem encountered in __add_pages() as ret=%d\n",
__func__, ret);
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/mm/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int __weak remove_section_mapping(unsigned long start, unsigned long end)
return -ENODEV;
}

int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
Expand All @@ -143,7 +143,7 @@ int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
return -EFAULT;
}

return __add_pages(nid, start_pfn, nr_pages, !for_device);
return __add_pages(nid, start_pfn, nr_pages, want_memblock);
}

#ifdef CONFIG_MEMORY_HOTREMOVE
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ unsigned long memory_block_size_bytes(void)
}

#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
unsigned long start_pfn = PFN_DOWN(start);
unsigned long size_pages = PFN_DOWN(size);
Expand All @@ -176,7 +176,7 @@ int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
if (rc)
return rc;

rc = __add_pages(nid, start_pfn, size_pages, !for_device);
rc = __add_pages(nid, start_pfn, size_pages, want_memblock);
if (rc)
vmem_remove_mapping(start, size);
return rc;
Expand Down
4 changes: 2 additions & 2 deletions arch/sh/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,14 @@ void free_initrd_mem(unsigned long start, unsigned long end)
#endif

#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
unsigned long start_pfn = PFN_DOWN(start);
unsigned long nr_pages = size >> PAGE_SHIFT;
int ret;

/* We only have ZONE_NORMAL, so this is easy.. */
ret = __add_pages(nid, start_pfn, nr_pages, !for_device);
ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
if (unlikely(ret))
printk("%s: Failed, __add_pages() == %d\n", __func__, ret);

Expand Down
4 changes: 2 additions & 2 deletions arch/x86/mm/init_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,12 @@ void __init mem_init(void)
}

#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;

return __add_pages(nid, start_pfn, nr_pages, !for_device);
return __add_pages(nid, start_pfn, nr_pages, want_memblock);
}

#ifdef CONFIG_MEMORY_HOTREMOVE
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,15 @@ static void update_end_of_memory_vars(u64 start, u64 size)
}
}

int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
int ret;

init_memory_mapping(start, start + size);

ret = __add_pages(nid, start_pfn, nr_pages, !for_device);
ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
WARN_ON_ONCE(ret);

/* update max_pfn, max_low_pfn and high_memory */
Expand Down
2 changes: 1 addition & 1 deletion include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ extern int add_memory(int nid, u64 start, u64 size);
extern int add_memory_resource(int nid, struct resource *resource, bool online);
extern int zone_for_memory(int nid, u64 start, u64 size, int zone_default,
bool for_device);
extern int arch_add_memory(int nid, u64 start, u64 size, bool for_device);
extern int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock);
extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);
extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
Expand Down
2 changes: 1 addition & 1 deletion kernel/memremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
goto err_pfn_remap;

mem_hotplug_begin();
error = arch_add_memory(nid, align_start, align_size, true);
error = arch_add_memory(nid, align_start, align_size, false);
if (!error)
move_pfn_range_to_zone(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
align_start >> PAGE_SHIFT,
Expand Down
2 changes: 1 addition & 1 deletion mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
}

/* call arch's memory hotadd */
ret = arch_add_memory(nid, start, size, false);
ret = arch_add_memory(nid, start, size, true);

if (ret < 0)
goto error;
Expand Down

0 comments on commit 3d79a72

Please sign in to comment.