Making kapmd effective

From: Pavel Machek (pavel@suse.cz)
Date: Fri May 05 2000 - 17:07:34 EST


Hi!

Without this patch, kapmd can not get much over 50%, therefore not
saving power properly. Exponential backoff should guarantee that we do
not slow normal system much.

                                                                Pavel

--- clean//arch/i386/kernel/apm.c Fri Mar 10 02:15:02 2000
+++ linux/arch/i386/kernel/apm.c Fri May 5 23:58:31 2000
@@ -1058,6 +1065,7 @@
 
 static void apm_mainloop(void)
 {
+ int timeout = HZ;
         DECLARE_WAITQUEUE(wait, current);
 
         if (smp_num_cpus > 1)
@@ -1067,7 +1075,10 @@
         current->state = TASK_INTERRUPTIBLE;
         for (;;) {
                 /* Nothing to do, just sleep for the timeout */
- schedule_timeout(APM_CHECK_TIMEOUT);
+ timeout = 2*timeout;
+ if (timeout > APM_CHECK_TIMEOUT)
+ timeout = APM_CHECK_TIMEOUT;
+ schedule_timeout(timeout);
                 if (exit_kapmd)
                         break;
 
@@ -1082,13 +1093,16 @@
                         continue;
                 if (apm_do_idle()) {
                         unsigned long start = jiffies;
- while (system_idle()) {
+ while ((!exit_kapmd) && system_idle()) {
                                 apm_do_idle();
- if (jiffies - start > APM_CHECK_TIMEOUT)
- break;
+ if (jiffies - start > APM_CHECK_TIMEOUT) {
+ apm_event_handler();
+ start = jiffies;
+ }
                         }
                         apm_do_busy();
                         apm_event_handler();
+ timeout = 1;
                 }
 #endif
         }

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents me at discuss@linmodems.org

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:11 EST