Skip to content

Commit 559bfc7

Browse files
Michal Hockotorvalds
authored andcommitted
mm, memory_hotplug: remove unused cruft after memory hotplug rework
zone_for_memory doesn't have any user anymore as well as the whole zone shifting infrastructure so drop them all. This shouldn't introduce any functional changes. Link: http://lkml.kernel.org/r/20170515085827.16474-15-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.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: Dan Williams <dan.j.williams@intel.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 cdf72f2 commit 559bfc7

2 files changed

Lines changed: 0 additions & 209 deletions

File tree

‎include/linux/memory_hotplug.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
296296
void *arg, int (*func)(struct memory_block *, void *));
297297
extern int add_memory(int nid, u64 start, u64 size);
298298
extern int add_memory_resource(int nid, struct resource *resource, bool online);
299-
extern int zone_for_memory(int nid, u64 start, u64 size, int zone_default,
300-
bool for_device);
301299
extern int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock);
302300
extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
303301
unsigned long nr_pages);

‎mm/memory_hotplug.c‎

Lines changed: 0 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -300,180 +300,6 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
300300
}
301301
#endif /* CONFIG_HAVE_BOOTMEM_INFO_NODE */
302302

303-
static void __meminit grow_zone_span(struct zone *zone, unsigned long start_pfn,
304-
unsigned long end_pfn)
305-
{
306-
unsigned long old_zone_end_pfn;
307-
308-
zone_span_writelock(zone);
309-
310-
old_zone_end_pfn = zone_end_pfn(zone);
311-
if (zone_is_empty(zone) || start_pfn < zone->zone_start_pfn)
312-
zone->zone_start_pfn = start_pfn;
313-
314-
zone->spanned_pages = max(old_zone_end_pfn, end_pfn) -
315-
zone->zone_start_pfn;
316-
317-
zone_span_writeunlock(zone);
318-
}
319-
320-
static void resize_zone(struct zone *zone, unsigned long start_pfn,
321-
unsigned long end_pfn)
322-
{
323-
zone_span_writelock(zone);
324-
325-
if (end_pfn - start_pfn) {
326-
zone->zone_start_pfn = start_pfn;
327-
zone->spanned_pages = end_pfn - start_pfn;
328-
} else {
329-
/*
330-
* make it consist as free_area_init_core(),
331-
* if spanned_pages = 0, then keep start_pfn = 0
332-
*/
333-
zone->zone_start_pfn = 0;
334-
zone->spanned_pages = 0;
335-
}
336-
337-
zone_span_writeunlock(zone);
338-
}
339-
340-
static void fix_zone_id(struct zone *zone, unsigned long start_pfn,
341-
unsigned long end_pfn)
342-
{
343-
enum zone_type zid = zone_idx(zone);
344-
int nid = zone->zone_pgdat->node_id;
345-
unsigned long pfn;
346-
347-
for (pfn = start_pfn; pfn < end_pfn; pfn++)
348-
set_page_links(pfn_to_page(pfn), zid, nid, pfn);
349-
}
350-
351-
static void __ref ensure_zone_is_initialized(struct zone *zone,
352-
unsigned long start_pfn, unsigned long num_pages)
353-
{
354-
if (!zone_is_initialized(zone))
355-
init_currently_empty_zone(zone, start_pfn, num_pages);
356-
}
357-
358-
static int __meminit move_pfn_range_left(struct zone *z1, struct zone *z2,
359-
unsigned long start_pfn, unsigned long end_pfn)
360-
{
361-
unsigned long flags;
362-
unsigned long z1_start_pfn;
363-
364-
ensure_zone_is_initialized(z1, start_pfn, end_pfn - start_pfn);
365-
366-
pgdat_resize_lock(z1->zone_pgdat, &flags);
367-
368-
/* can't move pfns which are higher than @z2 */
369-
if (end_pfn > zone_end_pfn(z2))
370-
goto out_fail;
371-
/* the move out part must be at the left most of @z2 */
372-
if (start_pfn > z2->zone_start_pfn)
373-
goto out_fail;
374-
/* must included/overlap */
375-
if (end_pfn <= z2->zone_start_pfn)
376-
goto out_fail;
377-
378-
/* use start_pfn for z1's start_pfn if z1 is empty */
379-
if (!zone_is_empty(z1))
380-
z1_start_pfn = z1->zone_start_pfn;
381-
else
382-
z1_start_pfn = start_pfn;
383-
384-
resize_zone(z1, z1_start_pfn, end_pfn);
385-
resize_zone(z2, end_pfn, zone_end_pfn(z2));
386-
387-
pgdat_resize_unlock(z1->zone_pgdat, &flags);
388-
389-
fix_zone_id(z1, start_pfn, end_pfn);
390-
391-
return 0;
392-
out_fail:
393-
pgdat_resize_unlock(z1->zone_pgdat, &flags);
394-
return -1;
395-
}
396-
397-
static int __meminit move_pfn_range_right(struct zone *z1, struct zone *z2,
398-
unsigned long start_pfn, unsigned long end_pfn)
399-
{
400-
unsigned long flags;
401-
unsigned long z2_end_pfn;
402-
403-
ensure_zone_is_initialized(z2, start_pfn, end_pfn - start_pfn);
404-
405-
pgdat_resize_lock(z1->zone_pgdat, &flags);
406-
407-
/* can't move pfns which are lower than @z1 */
408-
if (z1->zone_start_pfn > start_pfn)
409-
goto out_fail;
410-
/* the move out part mast at the right most of @z1 */
411-
if (zone_end_pfn(z1) > end_pfn)
412-
goto out_fail;
413-
/* must included/overlap */
414-
if (start_pfn >= zone_end_pfn(z1))
415-
goto out_fail;
416-
417-
/* use end_pfn for z2's end_pfn if z2 is empty */
418-
if (!zone_is_empty(z2))
419-
z2_end_pfn = zone_end_pfn(z2);
420-
else
421-
z2_end_pfn = end_pfn;
422-
423-
resize_zone(z1, z1->zone_start_pfn, start_pfn);
424-
resize_zone(z2, start_pfn, z2_end_pfn);
425-
426-
pgdat_resize_unlock(z1->zone_pgdat, &flags);
427-
428-
fix_zone_id(z2, start_pfn, end_pfn);
429-
430-
return 0;
431-
out_fail:
432-
pgdat_resize_unlock(z1->zone_pgdat, &flags);
433-
return -1;
434-
}
435-
436-
static void __meminit grow_pgdat_span(struct pglist_data *pgdat, unsigned long start_pfn,
437-
unsigned long end_pfn)
438-
{
439-
unsigned long old_pgdat_end_pfn = pgdat_end_pfn(pgdat);
440-
441-
if (!pgdat->node_spanned_pages || start_pfn < pgdat->node_start_pfn)
442-
pgdat->node_start_pfn = start_pfn;
443-
444-
pgdat->node_spanned_pages = max(old_pgdat_end_pfn, end_pfn) -
445-
pgdat->node_start_pfn;
446-
}
447-
448-
static int __meminit __add_zone(struct zone *zone, unsigned long phys_start_pfn)
449-
{
450-
struct pglist_data *pgdat = zone->zone_pgdat;
451-
int nr_pages = PAGES_PER_SECTION;
452-
int nid = pgdat->node_id;
453-
int zone_type;
454-
unsigned long flags, pfn;
455-
456-
zone_type = zone - pgdat->node_zones;
457-
ensure_zone_is_initialized(zone, phys_start_pfn, nr_pages);
458-
459-
pgdat_resize_lock(zone->zone_pgdat, &flags);
460-
grow_zone_span(zone, phys_start_pfn, phys_start_pfn + nr_pages);
461-
grow_pgdat_span(zone->zone_pgdat, phys_start_pfn,
462-
phys_start_pfn + nr_pages);
463-
pgdat_resize_unlock(zone->zone_pgdat, &flags);
464-
memmap_init_zone(nr_pages, nid, zone_type,
465-
phys_start_pfn, MEMMAP_HOTPLUG);
466-
467-
/* online_page_range is called later and expects pages reserved */
468-
for (pfn = phys_start_pfn; pfn < phys_start_pfn + nr_pages; pfn++) {
469-
if (!pfn_valid(pfn))
470-
continue;
471-
472-
SetPageReserved(pfn_to_page(pfn));
473-
}
474-
return 0;
475-
}
476-
477303
static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
478304
bool want_memblock)
479305
{
@@ -1370,39 +1196,6 @@ static int check_hotplug_memory_range(u64 start, u64 size)
13701196
return 0;
13711197
}
13721198

1373-
/*
1374-
* If movable zone has already been setup, newly added memory should be check.
1375-
* If its address is higher than movable zone, it should be added as movable.
1376-
* Without this check, movable zone may overlap with other zone.
1377-
*/
1378-
static int should_add_memory_movable(int nid, u64 start, u64 size)
1379-
{
1380-
unsigned long start_pfn = start >> PAGE_SHIFT;
1381-
pg_data_t *pgdat = NODE_DATA(nid);
1382-
struct zone *movable_zone = pgdat->node_zones + ZONE_MOVABLE;
1383-
1384-
if (zone_is_empty(movable_zone))
1385-
return 0;
1386-
1387-
if (movable_zone->zone_start_pfn <= start_pfn)
1388-
return 1;
1389-
1390-
return 0;
1391-
}
1392-
1393-
int zone_for_memory(int nid, u64 start, u64 size, int zone_default,
1394-
bool for_device)
1395-
{
1396-
#ifdef CONFIG_ZONE_DEVICE
1397-
if (for_device)
1398-
return ZONE_DEVICE;
1399-
#endif
1400-
if (should_add_memory_movable(nid, start, size))
1401-
return ZONE_MOVABLE;
1402-
1403-
return zone_default;
1404-
}
1405-
14061199
static int online_memory_block(struct memory_block *mem, void *arg)
14071200
{
14081201
return device_online(&mem->dev);

0 commit comments

Comments
 (0)