/* * linux/mm/memory_hotplug.c * * Copyright (C) */#include<linux/stddef.h>#include<linux/mm.h>#include<linux/swap.h>#include<linux/interrupt.h>#include<linux/pagemap.h>#include<linux/bootmem.h>#include<linux/compiler.h>#include<linux/export.h>#include<linux/pagevec.h>#include<linux/writeback.h>#include<linux/slab.h>#include<linux/sysctl.h>#include<linux/cpu.h>#include<linux/memory.h>#include<linux/memory_hotplug.h>#include<linux/highmem.h>#include<linux/vmalloc.h>#include<linux/ioport.h>#include<linux/delay.h>#include<linux/migrate.h>#include<linux/page-isolation.h>#include<linux/pfn.h>#include<linux/suspend.h>#include<linux/mm_inline.h>#include<linux/firmware-map.h>#include<asm/tlbflush.h>#include"internal.h"/* * online_page_callback contains pointer to current page onlining function. * Initially it is generic_online_page(). If it is required it could be * changed by calling set_online_page_callback() for callback registration * and restore_online_page_callback() for generic callback restore. */staticvoidgeneric_online_page(structpage*page);staticonline_page_callback_tonline_page_callback=generic_online_page;DEFINE_MUTEX(mem_hotplug_mutex);voidlock_memory_hotplug(void){mutex_lock(&mem_hotplug_mutex);/* for exclusive hibernation if CONFIG_HIBERNATION=y */lock_system_sleep();}voidunlock_memory_hotplug(void){unlock_system_sleep();mutex_unlock(&mem_hotplug_mutex);}/* add this memory to iomem resource */staticstructresource*register_memory_resource(u64start,u64size){structresource*res;res=kzalloc(sizeof(structresource),GFP_KERNEL);BUG_ON(!res);res->name="System RAM";res->start=start;res->end=start+size-1;res->flags=IORESOURCE_MEM|IORESOURCE_BUSY;if(request_resource(&iomem_resource,res)<0){printk("System RAM resource %pR cannot be added\n",res);kfree(res);res=NULL;}returnres;}staticvoidrelease_memory_resource(structresource*res){if(!res)return;release_resource(res);kfree(res);return;}#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE#ifndef CONFIG_SPARSEMEM_VMEMMAPstaticvoidget_page_bootmem(unsignedlonginfo