Пример #1
0
static int kswapd_balance_pgdat(pg_data_t * pgdat)
{
	int need_more_balance = 0, i;
	zone_t * zone;

	for (i = pgdat->nr_zones-1; i >= 0; i--) {
		zone = pgdat->node_zones + i;
		debug_lock_break(0);
#ifndef CONFIG_PREEMPT
		if (unlikely(current->need_resched))
			schedule();
#endif
		if (!zone->need_balance)
			continue;
		if (!try_to_free_pages(zone, GFP_KSWAPD, 0)) {
			zone->need_balance = 0;
			__set_current_state(TASK_INTERRUPTIBLE);
			schedule_timeout(HZ);
			continue;
		}
		if (check_classzone_need_balance(zone))
			need_more_balance = 1;
		else
			zone->need_balance = 0;
	}

	return need_more_balance;
}
Пример #2
0
struct page *alloc_page (enum palloc_flags flags)
{
	struct page *page;
	void *kaddr = palloc_get_page(flags);

	while (kaddr == NULL)
	{
		kaddr = try_to_free_pages(flags);
	}

	page = (struct page*)malloc(sizeof(struct page));
	page->kaddr = kaddr;
	page->thread = thread_current();

	add_page_to_lru_list(page);

	return page;
}