Skip to content

Commit 3d79a72

Browse files
Michal Hockotorvalds
authored andcommitted
mm, memory_hotplug: replace for_device by want_memblock in arch_add_memory
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/20170515085827.16474-13-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Tested-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Daniel Kiper <daniel.kiper@oracle.com> Cc: David Rientjes <rientjes@google.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Reza Arbab <arbab@linux.vnet.ibm.com> Cc: Tobias Regnery <tobias.regnery@gmail.com> Cc: Toshi Kani <toshi.kani@hpe.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: Xishi Qiu <qiuxishi@huawei.com> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c246a21 commit 3d79a72

9 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎arch/ia64/mm/init.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,13 @@ mem_init (void)
646646
}
647647

648648
#ifdef CONFIG_MEMORY_HOTPLUG
649-
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
649+
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
650650
{
651651
unsigned long start_pfn = start >> PAGE_SHIFT;
652652
unsigned long nr_pages = size >> PAGE_SHIFT;
653653
int ret;
654654

655-
ret = __add_pages(nid, start_pfn, nr_pages, !for_device);
655+
ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
656656
if (ret)
657657
printk("%s: Problem encountered in __add_pages() as ret=%d\n",
658658
__func__, ret);

‎arch/powerpc/mm/mem.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int __weak remove_section_mapping(unsigned long start, unsigned long end)
126126
return -ENODEV;
127127
}
128128

129-
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
129+
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
130130
{
131131
unsigned long start_pfn = start >> PAGE_SHIFT;
132132
unsigned long nr_pages = size >> PAGE_SHIFT;
@@ -143,7 +143,7 @@ int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
143143
return -EFAULT;
144144
}
145145

146-
return __add_pages(nid, start_pfn, nr_pages, !for_device);
146+
return __add_pages(nid, start_pfn, nr_pages, want_memblock);
147147
}
148148

149149
#ifdef CONFIG_MEMORY_HOTREMOVE

‎arch/s390/mm/init.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ unsigned long memory_block_size_bytes(void)
166166
}
167167

168168
#ifdef CONFIG_MEMORY_HOTPLUG
169-
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
169+
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
170170
{
171171
unsigned long start_pfn = PFN_DOWN(start);
172172
unsigned long size_pages = PFN_DOWN(size);
@@ -176,7 +176,7 @@ int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
176176
if (rc)
177177
return rc;
178178

179-
rc = __add_pages(nid, start_pfn, size_pages, !for_device);
179+
rc = __add_pages(nid, start_pfn, size_pages, want_memblock);
180180
if (rc)
181181
vmem_remove_mapping(start, size);
182182
return rc;

‎arch/sh/mm/init.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,14 @@ void free_initrd_mem(unsigned long start, unsigned long end)
485485
#endif
486486

487487
#ifdef CONFIG_MEMORY_HOTPLUG
488-
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
488+
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
489489
{
490490
unsigned long start_pfn = PFN_DOWN(start);
491491
unsigned long nr_pages = size >> PAGE_SHIFT;
492492
int ret;
493493

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

‎arch/x86/mm/init_32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,12 @@ void __init mem_init(void)
823823
}
824824

825825
#ifdef CONFIG_MEMORY_HOTPLUG
826-
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
826+
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
827827
{
828828
unsigned long start_pfn = start >> PAGE_SHIFT;
829829
unsigned long nr_pages = size >> PAGE_SHIFT;
830830

831-
return __add_pages(nid, start_pfn, nr_pages, !for_device);
831+
return __add_pages(nid, start_pfn, nr_pages, want_memblock);
832832
}
833833

834834
#ifdef CONFIG_MEMORY_HOTREMOVE

‎arch/x86/mm/init_64.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,15 @@ static void update_end_of_memory_vars(u64 start, u64 size)
772772
}
773773
}
774774

775-
int arch_add_memory(int nid, u64 start, u64 size, bool for_device)
775+
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
776776
{
777777
unsigned long start_pfn = start >> PAGE_SHIFT;
778778
unsigned long nr_pages = size >> PAGE_SHIFT;
779779
int ret;
780780

781781
init_memory_mapping(start, start + size);
782782

783-
ret = __add_pages(nid, start_pfn, nr_pages, !for_device);
783+
ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
784784
WARN_ON_ONCE(ret);
785785

786786
/* update max_pfn, max_low_pfn and high_memory */

‎include/linux/memory_hotplug.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ extern int add_memory(int nid, u64 start, u64 size);
298298
extern int add_memory_resource(int nid, struct resource *resource, bool online);
299299
extern int zone_for_memory(int nid, u64 start, u64 size, int zone_default,
300300
bool for_device);
301-
extern int arch_add_memory(int nid, u64 start, u64 size, bool for_device);
301+
extern int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock);
302302
extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
303303
unsigned long nr_pages);
304304
extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);

‎kernel/memremap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
358358
goto err_pfn_remap;
359359

360360
mem_hotplug_begin();
361-
error = arch_add_memory(nid, align_start, align_size, true);
361+
error = arch_add_memory(nid, align_start, align_size, false);
362362
if (!error)
363363
move_pfn_range_to_zone(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
364364
align_start >> PAGE_SHIFT,

‎mm/memory_hotplug.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
14481448
}
14491449

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

14531453
if (ret < 0)
14541454
goto error;

0 commit comments

Comments
 (0)