@@ -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-
477303static 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-
14061199static int online_memory_block (struct memory_block * mem , void * arg )
14071200{
14081201 return device_online (& mem -> dev );
0 commit comments