示例#1
0
/** 
 * adjust_speed:
 * @iface:	struct with the userspace interface
 *
 * Returns:	TRUE/FALSE
 *
 * increases and decreases speeds
 */
static gboolean adjust_speed(struct userspace_interface *iface)
{
	GSList		*cpus	 = (GSList*)iface->cpus;
	GSList		*it	 = NULL;
	int		cpu_load = 0;

	for (it = cpus; it != NULL; it = g_slist_next(it)) {
		HAL_DEBUG(("checking cpu %d: cpu_core: %d",
			   GPOINTER_TO_INT(it->data), GPOINTER_TO_INT(it->data)));
		if (get_cpu_load(GPOINTER_TO_INT(it->data)) > cpu_load)
			 cpu_load = get_cpu_load(GPOINTER_TO_INT(it->data));
	}

	HAL_DEBUG(("cpu_max: %d cpu_high_limit: %d consider_nice: %d",
		   config.up_threshold, config.cpu_high_limit,
		   config.consider_nice));
	HAL_DEBUG(("Current: %u; current speed: %u MHz", 
		   iface->current_speed, g_a_i(iface->speeds_kHz, iface->current_speed)));
	HAL_DEBUG(("CPU load: %d, Previous CPU load %d, cpu_load diff: %d, last_step: %d, demotion: %u",
		   cpu_load, iface->prev_cpu_load, cpu_load - iface->prev_cpu_load, iface->last_step,
		   g_a_i(iface->demotion, iface->current_speed)));

	/* directly increase speed to maximum if cpu load jumped */
	if (config.cpu_high_limit &&
	    (cpu_load - iface->prev_cpu_load) > config.cpu_high_limit) {
		if (iface->current_speed != 0) {
			set_speed(iface, 0);
			iface->current_speed = 0;
			HAL_DEBUG(("jumped to max (%d kHz)", 
				   g_a_i(iface->speeds_kHz, iface->current_speed)));
		}
	} else if (cpu_load > config.up_threshold && iface->current_speed > 0) {
		iface->current_speed = increase_speed(iface);
		HAL_DEBUG(("increased to %d kHz", g_a_i(iface->speeds_kHz, iface->current_speed)));
	} else if (cpu_load < (int)g_a_i(iface->demotion, iface->current_speed) &&
		   iface->current_speed < iface->last_step) {
		iface->current_speed = decrease_speed(iface);
		HAL_DEBUG(("decreased to %d kHz", g_a_i(iface->speeds_kHz, iface->current_speed)));
	} else {
		HAL_DEBUG(("Speed not changed"));
	}

	iface->prev_cpu_load = cpu_load;
	return TRUE;
}
示例#2
0
void stub_decreasespeed(void) {
  decrease_speed();
}