static void __ref intelli_plug_work_fn(struct work_struct *work) { unsigned int nr_run_stat; unsigned int cpu_count = 0; unsigned int nr_cpus = 0; int i; if (intelli_plug_active) { nr_run_stat = calculate_thread_stats(); update_per_cpu_stat(); #ifdef DEBUG_INTELLI_PLUG pr_info("nr_run_stat: %u\n", nr_run_stat); #endif cpu_count = nr_run_stat; nr_cpus = num_online_cpus(); if (!suspended) { if (persist_count > 0) persist_count--; switch (cpu_count) { case 1: if (persist_count == 0) { //take down everyone unplug_cpu(0); } #ifdef DEBUG_INTELLI_PLUG pr_info("case 1: %u\n", persist_count); #endif break; case 2: if (persist_count == 0) persist_count = DUAL_PERSISTENCE; if (nr_cpus < 2) { for (i = 1; i < cpu_count; i++) cpu_up(i); } else { unplug_cpu(1); } #ifdef DEBUG_INTELLI_PLUG pr_info("case 2: %u\n", persist_count); #endif break; default: pr_err("Run Stat Error: Bad value %u\n", nr_run_stat); break; } } #ifdef DEBUG_INTELLI_PLUG else pr_info("intelli_plug is suspened!\n"); #endif } queue_delayed_work_on(0, intelliplug_wq, &intelli_plug_work, msecs_to_jiffies(sampling_time)); }
static void __cpuinit intelli_plug_work_fn(struct work_struct *work) { unsigned int nr_run_stat, sampling_rate, online_cpus; unsigned int min_sampling_rate_jiffies = 0; if (intelli_plug_active == 1 && !excluded_governor) { online_cpus = num_online_cpus(); nr_run_stat = calculate_thread_stats(); if (!suspended) { switch (nr_run_stat) { case 1: if (persist_count > 0) { persist_count--; } else if (online_cpus == 2) { cpu_down(1); } #ifdef DEBUG_INTELLI_PLUG pr_info("case 1: %u\n", persist_count); #endif break; case 2: persist_count = DUAL_CORE_PERSISTENCE / CPU_DOWN_FACTOR; if (online_cpus == 1) cpu_up(1); #ifdef DEBUG_INTELLI_PLUG pr_info("case 2: %u\n", persist_count); #endif break; default: pr_err("Run Stat Error: Bad value %u\n", nr_run_stat); break; } } /* increase the sampling rate dynamically based on online cpus */ min_sampling_rate_jiffies = msecs_to_jiffies(min_sampling_rate); sampling_rate = min_sampling_rate_jiffies * online_cpus; } else { /* increase the sampling rate for screen-off */ sampling_rate = msecs_to_jiffies(min_sampling_rate) << 3; #ifdef DEBUG_INTELLI_PLUG pr_info("intelli_plug is suspened!\n"); #endif } #ifdef DEBUG_INTELLI_PLUG pr_info("sampling_rate is: %d\n", jiffies_to_msecs(sampling_rate)); #endif schedule_delayed_work_on(0, &intelli_plug_work, sampling_rate); }
static void __cpuinit intelli_plug_work_fn(struct work_struct *work) { unsigned int nr_run_stat; unsigned int cpu_count = 0; unsigned int nr_cpus = 0; int decision = 0; int i; if (intelli_plug_active == 1) { nr_run_stat = calculate_thread_stats(); #ifdef DEBUG_INTELLI_PLUG pr_info("nr_run_stat: %u\n", nr_run_stat); #endif cpu_count = nr_run_stat; // detect artificial loads or constant loads // using msm rqstats nr_cpus = num_online_cpus(); if (!eco_mode_active && (nr_cpus >= 1 && nr_cpus < 4)) { decision = mp_decision(); if (decision) { switch (nr_cpus) { case 2: cpu_count = 3; #ifdef DEBUG_INTELLI_PLUG pr_info("nr_run(2) => %u\n", nr_run_stat); #endif break; case 3: cpu_count = 4; #ifdef DEBUG_INTELLI_PLUG pr_info("nr_run(3) => %u\n", nr_run_stat); #endif break; } } } /* it's busy.. lets help it a bit */ if (cpu_count > 2) { if (busy_persist_count == 0) { sampling_time = BUSY_SAMPLING_MS; busy_persist_count = BUSY_PERSISTENCE; } } else { if (busy_persist_count > 0) busy_persist_count--; else sampling_time = DEF_SAMPLING_MS; } if (!suspended) { switch (cpu_count) { case 1: if (persist_count > 0) persist_count--; if (persist_count == 0) { //take down everyone for (i = 3; i > 0; i--) cpu_down(i); } #ifdef DEBUG_INTELLI_PLUG pr_info("case 1: %u\n", persist_count); #endif break; case 2: persist_count = DUAL_CORE_PERSISTENCE; if (!decision) persist_count = DUAL_CORE_PERSISTENCE / CPU_DOWN_FACTOR; if (nr_cpus < 2) { for (i = 1; i < cpu_count; i++) cpu_up(i); } else { for (i = 3; i > 1; i--) cpu_down(i); } #ifdef DEBUG_INTELLI_PLUG pr_info("case 2: %u\n", persist_count); #endif break; case 3: persist_count = TRI_CORE_PERSISTENCE; if (!decision) persist_count = TRI_CORE_PERSISTENCE / CPU_DOWN_FACTOR; if (nr_cpus < 3) { for (i = 1; i < cpu_count; i++) cpu_up(i); } else { for (i = 3; i > 2; i--) cpu_down(i); } #ifdef DEBUG_INTELLI_PLUG pr_info("case 3: %u\n", persist_count); #endif break; case 4: persist_count = QUAD_CORE_PERSISTENCE; if (!decision) persist_count = QUAD_CORE_PERSISTENCE / CPU_DOWN_FACTOR; if (nr_cpus < 4) for (i = 1; i < cpu_count; i++) cpu_up(i); #ifdef DEBUG_INTELLI_PLUG pr_info("case 4: %u\n", persist_count); #endif break; default: pr_err("Run Stat Error: Bad value %u\n", nr_run_stat); break; } } #ifdef DEBUG_INTELLI_PLUG else pr_info("intelli_plug is suspened!\n"); #endif } schedule_delayed_work_on(0, &intelli_plug_work, msecs_to_jiffies(sampling_time)); }
static void __ref intelli_plug_work_fn(struct work_struct *work) { unsigned int nr_run_stat; unsigned int cpu_count = 0; unsigned int nr_cpus = 0; int decision = 0; int i; nr_run_stat = calculate_thread_stats(); if (debug_intelli_plug) pr_info("nr_run_stat: %u\n", nr_run_stat); cpu_count = nr_run_stat; /* detect artificial loads or constant loads * using msm rqstats */ nr_cpus = num_online_cpus(); if (!eco_mode_active && !strict_mode_active && (nr_cpus >= 1 && nr_cpus < 4)) { decision = mp_decision(); if (decision) { switch (nr_cpus) { case 2: cpu_count = 3; if (debug_intelli_plug) pr_info("nr_run(2) => %u\n", nr_run_stat); break; case 3: cpu_count = 4; if (debug_intelli_plug) pr_info("nr_run(3) => %u\n", nr_run_stat); break; } } } /* it's busy.. lets help it a bit */ if (cpu_count > 2) { if (busy_persist_count == 0) { sampling_time = busy_sampling_ms; busy_persist_count = busy_persistence; } } else { if (busy_persist_count > 0) busy_persist_count--; else sampling_time = def_sampling_ms; } if (!hotplug_suspended) { switch (cpu_count) { case 1: if (persist_count > 0) persist_count--; if (persist_count == 0) { /* take down everyone */ for (i = 3; i > 0; i--) cpu_down(i); } if (debug_intelli_plug) pr_info("case 1: %u\n", persist_count); break; case 2: persist_count = dual_core_persistence; if (!decision) persist_count = dual_core_persistence / cpu_down_factor; if (nr_cpus < 2) { for (i = 1; i < cpu_count; i++) cpu_up(i); } else { for (i = 3; i > 1; i--) cpu_down(i); } if (debug_intelli_plug) pr_info("case 2: %u\n", persist_count); break; case 3: persist_count = tri_core_persistence; if (!decision) persist_count = tri_core_persistence / cpu_down_factor; if (nr_cpus < 3) { for (i = 1; i < cpu_count; i++) cpu_up(i); } else { for (i = 3; i > 2; i--) cpu_down(i); } if (debug_intelli_plug) pr_info("case 3: %u\n", persist_count); break; case 4: persist_count = quad_core_persistence; if (!decision) persist_count = quad_core_persistence / cpu_down_factor; if (nr_cpus < 4) for (i = 1; i < cpu_count; i++) cpu_up(i); if (debug_intelli_plug) pr_info("case 4: %u\n", persist_count); break; default: pr_err("Run Stat Error: Bad value %u\n", nr_run_stat); break; } } else if (debug_intelli_plug) pr_info("intelli_plug is suspened!\n"); queue_delayed_work_on(0, intelliplug_wq, &intelli_plug_work, msecs_to_jiffies(sampling_time)); }
static void __cpuinit intelli_plug_work_fn(struct work_struct *work) { unsigned int nr_run_stat; if (intelli_plug_active == 1) { nr_run_stat = calculate_thread_stats(); //pr_info("nr_run_stat: %u\n", nr_run_stat); if (!suspended) { switch (nr_run_stat) { case 1: if (persist_count > 0) persist_count--; if (num_online_cpus() == 2 && persist_count == 0) cpu_down(1); if (eco_mode_active) { cpu_down(3); cpu_down(2); } //pr_info("case 1: %u\n", persist_count); break; case 2: persist_count = DUAL_CORE_PERSISTENCE; if (num_online_cpus() == 1) cpu_up(1); else { cpu_down(3); cpu_down(2); } //pr_info("case 2: %u\n", persist_count); break; case 3: persist_count = TRI_CORE_PERSISTENCE; if (num_online_cpus() == 1) cpu_up(1); if (num_online_cpus() == 2) cpu_up(2); else cpu_down(3); //pr_info("case 3: %u\n", persist_count); break; case 4: persist_count = QUAD_CORE_PERSISTENCE; if (num_online_cpus() == 1) cpu_up(1); if (num_online_cpus() == 2) cpu_up(2); if (num_online_cpus() == 3) cpu_up(3); //pr_info("case 4: %u\n", persist_count); break; default: pr_err("Run Stat Error: Bad value %u\n", nr_run_stat); break; } } //else //pr_info("intelli_plug is suspened!\n"); } schedule_delayed_work_on(0, &intelli_plug_work, msecs_to_jiffies(DEF_SAMPLING_MS)); }