static void balloon_append(struct page *page) { __balloon_append(page); if (PageHighMem(page)) dec_totalhigh_pages(); totalram_pages--; }
static int __init balloon_init(void) { unsigned long pfn, extra_pfn_end; struct page *page; if (!xen_pv_domain()) return -ENODEV; pr_info("xen_balloon: Initialising balloon driver.\n"); balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn); balloon_stats.target_pages = balloon_stats.current_pages; balloon_stats.balloon_low = 0; balloon_stats.balloon_high = 0; init_timer(&balloon_timer); balloon_timer.data = 0; balloon_timer.function = balloon_alarm; register_balloon(&balloon_sysdev); /* * Initialise the balloon with excess memory space. We need * to make sure we don't add memory which doesn't exist or * logically exist. The E820 map can be trimmed to be smaller * than the amount of physical memory due to the mem= command * line parameter. And if this is a 32-bit non-HIGHMEM kernel * on a system with memory which requires highmem to access, * don't try to use it. */ extra_pfn_end = min(min(max_pfn, e820_end_of_ram_pfn()), (unsigned long)PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size)); for (pfn = PFN_UP(xen_extra_mem_start); pfn < extra_pfn_end; pfn++) { page = pfn_to_page(pfn); /* totalram_pages and totalhigh_pages do not include the boot-time balloon extension, so don't subtract from it. */ __balloon_append(page); } target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }
static void balloon_append(struct page *page) { __balloon_append(page); adjust_managed_page_count(page, -1); }