Example #1
0
void
cmm_set_timeout(long pages, long seconds)
{
	cmm_timeout_pages = pages;
	cmm_timeout_seconds = seconds;
	cmm_set_timer();
}
Example #2
0
void
cmm_set_timeout(long nr, long seconds)
{
	cmm_timeout_pages = nr;
	cmm_timeout_seconds = seconds;
	cmm_set_timer();
}
Example #3
0
static int
cmm_thread(void *dummy)
{
	int rc;

	while (1) {
		rc = wait_event_interruptible(cmm_thread_wait,
			(cmm_pages != cmm_pages_target ||
			 cmm_timed_pages != cmm_timed_pages_target ||
			 kthread_should_stop()));
		if (kthread_should_stop() || rc == -ERESTARTSYS) {
			cmm_pages_target = cmm_pages;
			cmm_timed_pages_target = cmm_timed_pages;
			break;
		}
		if (cmm_pages_target > cmm_pages) {
			if (cmm_alloc_pages(1, &cmm_pages, &cmm_page_list))
				cmm_pages_target = cmm_pages;
		} else if (cmm_pages_target < cmm_pages) {
			cmm_free_pages(1, &cmm_pages, &cmm_page_list);
		}
		if (cmm_timed_pages_target > cmm_timed_pages) {
			if (cmm_alloc_pages(1, &cmm_timed_pages,
					   &cmm_timed_page_list))
				cmm_timed_pages_target = cmm_timed_pages;
		} else if (cmm_timed_pages_target < cmm_timed_pages) {
			cmm_free_pages(1, &cmm_timed_pages,
			       	       &cmm_timed_page_list);
		}
		if (cmm_timed_pages > 0 && !timer_pending(&cmm_timer))
			cmm_set_timer();
	}
	return 0;
}
Example #4
0
static void cmm_timer_fn(unsigned long ignored)
{
	long nr;

	nr = cmm_timed_pages_target - cmm_timeout_pages;
	if (nr < 0)
		cmm_timed_pages_target = 0;
	else
		cmm_timed_pages_target = nr;
	cmm_kick_thread();
	cmm_set_timer();
}
Example #5
0
static void
cmm_timer_fn(unsigned long ignored)
{
	long pages;

	pages = cmm_timed_pages_target - cmm_timeout_pages;
	if (pages < 0)
		cmm_timed_pages_target = 0;
	else
		cmm_timed_pages_target = pages;
	cmm_kick_thread();
	cmm_set_timer();
}
Example #6
0
static int
cmm_thread(void *dummy)
{
	int rc;

	daemonize("cmmthread");
	set_cpus_allowed(current, cpumask_of_cpu(0));
	while (1) {
		rc = wait_event_interruptible(cmm_thread_wait,
			(cmm_pages != cmm_pages_target ||
			 cmm_timed_pages != cmm_timed_pages_target));
		if (rc == -ERESTARTSYS) {
			/* Got kill signal. End thread. */
			clear_bit(0, &cmm_thread_active);
			cmm_pages_target = cmm_pages;
			cmm_timed_pages_target = cmm_timed_pages;
			break;
		}
		if (cmm_pages_target > cmm_pages) {
			if (cmm_alloc_pages(1, &cmm_pages, &cmm_page_list))
				cmm_pages_target = cmm_pages;
		} else if (cmm_pages_target < cmm_pages) {
			cmm_free_pages(1, &cmm_pages, &cmm_page_list);
		}
		if (cmm_timed_pages_target > cmm_timed_pages) {
			if (cmm_alloc_pages(1, &cmm_timed_pages,
					   &cmm_timed_page_list))
				cmm_timed_pages_target = cmm_timed_pages;
		} else if (cmm_timed_pages_target < cmm_timed_pages) {
			cmm_free_pages(1, &cmm_timed_pages,
			       	       &cmm_timed_page_list);
		}
		if (cmm_timed_pages > 0 && !timer_pending(&cmm_timer))
			cmm_set_timer();
	}
	return 0;
}