static unsigned int calculate_thread_stats(void)
{
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;
	unsigned int threshold_size;
	unsigned int *current_profile;

	threshold_size = max_cpus_online;
	nr_run_hysteresis = max_cpus_online * 2;
	nr_fshift = max_cpus_online - 1;

	for (nr_run = 1; nr_run < threshold_size; nr_run++) {
		unsigned int nr_threshold;
		if (max_cpus_online >= 4)
			current_profile = nr_run_profiles[full_mode_profile];
		else if (max_cpus_online == 3)
			current_profile = nr_run_profiles[4];
		else if (max_cpus_online == 2)
			current_profile = nr_run_profiles[5];
		else
			current_profile = nr_run_profiles[6];

		nr_threshold = current_profile[nr_run - 1];

		if (nr_run_last <= nr_run)
			nr_threshold += nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - nr_fshift)))
			break;
	}
	nr_run_last = nr_run;

	return nr_run;
}
static void update_runnables_state(void)
{
	unsigned int nr_cpus = num_online_cpus();
	unsigned int max_cpus = tegra_cpq_max_cpus();
	unsigned int min_cpus = tegra_cpq_min_cpus();
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;

	if (runnables_state == DISABLED)
		return;

	for (nr_run = 1; nr_run < ARRAY_SIZE(nr_run_thresholds); nr_run++) {
		unsigned int nr_threshold = nr_run_thresholds[nr_run - 1];
		if (nr_run_last <= nr_run)
			nr_threshold += NR_FSHIFT / nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - NR_FSHIFT_EXP)))
			break;
	}
	nr_run_last = nr_run;

	if (nr_run > 1 && (nr_cpus > max_cpus || nr_run < nr_cpus) && nr_cpus > min_cpus) {
		runnables_state = DOWN;
	} else if (nr_cpus < min_cpus || nr_run > nr_cpus) {
		runnables_state =  UP;
	} else {
		runnables_state = IDLE;
	}
}
예제 #3
0
static void update_runnables_state(void)
{
	unsigned int nr_cpus = num_online_cpus();
	int max_cpus = pm_qos_request(PM_QOS_MAX_ONLINE_CPUS) ? : 4;
	int min_cpus = pm_qos_request(PM_QOS_MIN_ONLINE_CPUS);
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;

	if (runnables_state == DISABLED)
		return;

	for (nr_run = 1; nr_run < ARRAY_SIZE(nr_run_thresholds); nr_run++) {
		unsigned int nr_threshold = nr_run_thresholds[nr_run - 1];
		if (nr_run_last <= nr_run)
			nr_threshold += NR_FSHIFT / nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - NR_FSHIFT_EXP)))
			break;
	}
	nr_run_last = nr_run;

	if ((nr_cpus > max_cpus || nr_run < nr_cpus) && nr_cpus >= min_cpus) {
		runnables_state = DOWN;
	} else if (nr_cpus < min_cpus || nr_run > nr_cpus) {
		runnables_state =  UP;
	} else {
		runnables_state = IDLE;
	}
}
예제 #4
0
static unsigned int calculate_thread_stats(void)
{
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;
	unsigned int threshold_size;

	if (!eco_mode_active) {
		threshold_size =  ARRAY_SIZE(nr_run_thresholds_full);
		nr_run_hysteresis = 2;
		nr_fshift = 3;
		//pr_info("intelliplug: full mode active!");
	}
	else {
		threshold_size =  ARRAY_SIZE(nr_run_thresholds_eco);
		nr_run_hysteresis = 4;
		nr_fshift = 1;
		//pr_info("intelliplug: eco mode active!");
	}

	for (nr_run = 1; nr_run < threshold_size; nr_run++) {
		unsigned int nr_threshold;
		if (!eco_mode_active)
			nr_threshold = nr_run_thresholds_full[nr_run - 1];
		else
			nr_threshold = nr_run_thresholds_eco[nr_run - 1];

		if (nr_run_last <= nr_run)
			nr_threshold += nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - nr_fshift)))
			break;
	}
	nr_run_last = nr_run;

	return nr_run;
}
예제 #5
0
static unsigned int calculate_thread_stats(void)
{
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;
	unsigned int threshold_size;
	unsigned int *current_profile;

	unsigned int nr_change_flag = 0;

	if (eco_mode_active && nr_run_profile_sel != 0 && nr_run_profile_sel != NR_RUN_ECO_MODE_PROFILE) {
		eco_mode_active = 0;
		nr_change_flag = 1;
	}

	if (eco_mode_active) {
		if (!profile_flag) {
			nr_run_profile_last = nr_run_profile_sel;
			profile_flag = 1;
		}
		nr_run_profile_sel = NR_RUN_ECO_MODE_PROFILE;
	}

	if (eco_mode_active == 0 && nr_change_flag == 0 && profile_flag == 1) {
		nr_run_profile_sel = nr_run_profile_last;
		profile_flag = 0;
	}

	current_profile = nr_run_profiles[nr_run_profile_sel];

	if (num_possible_cpus() > 2) {
		if (nr_run_profile_sel >= NR_RUN_ECO_MODE_PROFILE)
			threshold_size =
				ARRAY_SIZE(nr_run_thresholds_eco);
		else
			threshold_size =
				ARRAY_SIZE(nr_run_thresholds_balance);
	} else
		threshold_size =
			ARRAY_SIZE(nr_run_thresholds_eco);

	if (nr_run_profile_sel >= NR_RUN_ECO_MODE_PROFILE)
		nr_fshift = 1;
	else
		nr_fshift = num_possible_cpus() - 1;

	for (nr_run = 1; nr_run < threshold_size; nr_run++) {
		unsigned int nr_threshold;
		nr_threshold = current_profile[nr_run - 1];

		if (nr_run_last <= nr_run)
			nr_threshold += nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - nr_fshift)))
			break;
	}
	nr_run_last = nr_run;

	return nr_run;
}
예제 #6
0
static noinline int tegra_cpu_speed_balance(void)
{
	unsigned long highest_speed = tegra_cpu_highest_speed();
	unsigned long balanced_speed = highest_speed * balance_level / 100;
	unsigned long skewed_speed = balanced_speed / 2;
	unsigned int nr_cpus = num_online_cpus();
	unsigned int max_cpus = pm_qos_request(PM_QOS_MAX_ONLINE_CPUS) ? : 4;
	unsigned int min_cpus = pm_qos_request(PM_QOS_MIN_ONLINE_CPUS);
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;

	/* Evaluate:
	 * - distribution of freq targets for already on-lined CPUs
	 * - average number of runnable threads
	 * - effective MIPS available within EDP frequency limits,
	 * and return:
	 * TEGRA_CPU_SPEED_BALANCED to bring one more CPU core on-line
	 * TEGRA_CPU_SPEED_BIASED to keep CPU core composition unchanged
	 * TEGRA_CPU_SPEED_SKEWED to remove CPU core off-line
	 */

	unsigned int *current_profile = rt_profiles[rt_profile_sel];
	for (nr_run = 1; nr_run < ARRAY_SIZE(rt_profile_default); nr_run++) {
		unsigned int nr_threshold = current_profile[nr_run - 1];
		if (nr_run_last <= nr_run)
			nr_threshold += nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - NR_FSHIFT)))
			break;
	}
	nr_run_last = nr_run;

//                           
#ifdef CONFIG_MACH_X3
	if(threads_count_hotplug_control_enable == 0 && highest_speed >= 640000 )
		nr_run++;
#endif

	if (((tegra_count_slow_cpus(skewed_speed) >= 2) ||
	     (nr_run < nr_cpus) ||
	     tegra_cpu_edp_favor_down(nr_cpus, mp_overhead) ||
	     (highest_speed <= idle_bottom_freq) || (nr_cpus > max_cpus)) &&
	    (nr_cpus > min_cpus))
		return TEGRA_CPU_SPEED_SKEWED;

	if (((tegra_count_slow_cpus(balanced_speed) >= 1) ||
	     (nr_run <= nr_cpus) ||
	     (!tegra_cpu_edp_favor_up(nr_cpus, mp_overhead)) ||
	     (highest_speed <= idle_bottom_freq) || (nr_cpus == max_cpus)) &&
	    (nr_cpus >= min_cpus))
		return TEGRA_CPU_SPEED_BIASED;

	return TEGRA_CPU_SPEED_BALANCED;
}
static unsigned int calculate_thread_stats(void)
{
	unsigned int avg_nr_run = avg_nr_running();
	unsigned int nr_run;
	unsigned int threshold_size;
	unsigned int *current_profile;

	current_profile = nr_run_profiles[intelli_plug_nr_run_profile_sel];
	if (num_possible_cpus() > 2) {
		if (intelli_plug_nr_run_profile_sel >= NR_RUN_ECO_MODE_PROFILE)
			threshold_size =
				ARRAY_SIZE(nr_run_thresholds_eco);
		else
			threshold_size =
				ARRAY_SIZE(nr_run_thresholds_balance);
	} else
		threshold_size =
			ARRAY_SIZE(nr_run_thresholds_eco);

	if (intelli_plug_nr_run_profile_sel >= NR_RUN_ECO_MODE_PROFILE)
		nr_fshift = 1;
	else
		nr_fshift = num_possible_cpus() - 1;

	for (nr_run = 1; nr_run < threshold_size; nr_run++) {
		unsigned int nr_threshold;
		nr_threshold = current_profile[nr_run - 1];

		if (nr_run_last <= nr_run)
			nr_threshold += nr_run_hysteresis;
		if (avg_nr_run <= (nr_threshold << (FSHIFT - nr_fshift)))
			break;
	}
	nr_run_last = nr_run;

	return nr_run;
}
예제 #8
0
static unsigned int calculate_thread_stats(void)
{
        unsigned int avg_nr_run = avg_nr_running();
        unsigned int nr_run;
        unsigned int threshold_size;

        if (!eco_mode_active) {
                threshold_size =  ARRAY_SIZE(nr_run_thresholds_full);
                nr_run_hysteresis = 8;
                nr_fshift = 3;
#ifdef DEBUG_INTELLI_PLUG
                pr_info("intelliplug: full mode active!");
#endif
        }

	if (eco_cores_enabled == 3) {
		threshold_size =  ARRAY_SIZE(nr_run_thresholds_eco_minimal);
                nr_run_hysteresis = 6;
                nr_fshift = 2;
#ifdef DEBUG_INTELLI_PLUG
                pr_info("intelliplug: eco-minimal mode active!");
#endif
        }

	if (eco_cores_enabled == 1) {
		threshold_size =  ARRAY_SIZE(nr_run_thresholds_eco_extreme);
                nr_run_hysteresis = 2;
                nr_fshift = 1;
#ifdef DEBUG_INTELLI_PLUG
                pr_info("intelliplug: eco-extreme mode active!");
#endif
        }

        else {
                threshold_size =  ARRAY_SIZE(nr_run_thresholds_eco);
                nr_run_hysteresis = 4;
                nr_fshift = 1;
#ifdef DEBUG_INTELLI_PLUG
                pr_info("intelliplug: eco mode active!");
#endif
        }

        for (nr_run = 1; nr_run < threshold_size; nr_run++) {
                unsigned int nr_threshold;
                if (!eco_mode_active)
                        nr_threshold = nr_run_thresholds_full[nr_run - 1];
		if (eco_cores_enabled == 3)
			nr_threshold = nr_run_thresholds_eco_minimal[nr_run - 1];
		if (eco_cores_enabled == 1)
			nr_threshold = nr_run_thresholds_eco_extreme[nr_run - 1];
                else
                        nr_threshold = nr_run_thresholds_eco[nr_run - 1];

                if (nr_run_last <= nr_run)
                        nr_threshold += nr_run_hysteresis;
                if (avg_nr_run <= (nr_threshold << (FSHIFT - nr_fshift)))
                        break;
        }
        nr_run_last = nr_run;

        return nr_run;
}