Revert "adjust -C algorithm to be more aggressive in scaling up" for
authormpi <mpi@openbsd.org>
Sat, 26 Jul 2014 10:48:59 +0000 (10:48 +0000)
committermpi <mpi@openbsd.org>
Sat, 26 Jul 2014 10:48:59 +0000 (10:48 +0000)
the moment, it triggers a race that breaks suspend/resume on some
machines.

ok tedu@, deraadt@, jsg@

usr.sbin/apmd/apmd.c

index 20e141e..75efde8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: apmd.c,v 1.64 2014/07/22 22:09:36 tedu Exp $  */
+/*     $OpenBSD: apmd.c,v 1.65 2014/07/26 10:48:59 mpi Exp $   */
 
 /*
  *  Copyright (c) 1995, 1996 John T. Kohl
@@ -65,8 +65,8 @@ int doperf = PERF_NONE;
 #define PERFDEC 20
 #define PERFMIN 0
 #define PERFMAX 100
-#define PERFINCTHRES 50
-#define PERFDECTHRES 60
+#define PERFINCTHRES 10
+#define PERFDECTHRES 30
 
 extern char *__progname;
 
@@ -339,7 +339,9 @@ perf_status(struct apm_power_info *pinfo, int ncpu)
                syslog(LOG_INFO, "cannot read hw.setperf");
 
        if (forcehi || (avg_idle < PERFINCTHRES && perf < PERFMAX)) {
-               perf = PERFMAX;
+               perf += PERFINC;
+               if (perf > PERFMAX)
+                       perf = PERFMAX;
                setperf(perf);
        } else if (avg_idle > PERFDECTHRES && perf > PERFMIN) {
                perf -= PERFDEC;
@@ -641,12 +643,11 @@ main(int argc, char *argv[])
                sts = ts;
 
                if (doperf == PERF_AUTO || doperf == PERF_COOL) {
-                       sts.tv_sec = 0;
-                       sts.tv_nsec = 200000000;
+                       sts.tv_sec = 1;
                        perf_status(&pinfo, ncpu);
                }
 
-               apmtimeout += 1;
+               apmtimeout += sts.tv_sec;
                if ((rv = kevent(kq, NULL, 0, ev, 1, &sts)) < 0)
                        break;