diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2020-09-28 21:35:15 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2020-09-28 21:35:15 +0000 |
commit | d104e482263f6b6bbff58c5689e761deb8b0c395 (patch) | |
tree | f8c9e47256196137f56163b10a4ac856cb820a78 /usr.sbin/apmd | |
parent | 94df3e39f27c6f14c61621f18dfd9d35442e3b94 (diff) |
Set hw.perfpolicy to "manual" and hw.setperf to max when handling -H
This is better than using hw.perfpolicy="high" for a number of reasons:
- matches the manpage
- apm(8) reporting becomes accurate
- more symmetry with -L ("low")
- lets the user tweak hw.setperf with sysctl(8) later
ok tedu@
Diffstat (limited to 'usr.sbin/apmd')
-rw-r--r-- | usr.sbin/apmd/apmd.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 7bf018f8014..f5206568959 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.98 2020/09/24 07:23:41 jca Exp $ */ +/* $OpenBSD: apmd.c,v 1.99 2020/09/28 21:35:14 jca Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -650,27 +650,27 @@ void setperfpolicy(char *policy) { int hw_perfpol_mib[] = { CTL_HW, HW_PERFPOLICY }; - char oldpolicy[32]; - size_t oldsz = sizeof(oldpolicy); - int setlo = 0; + int hw_perf_mib[] = { CTL_HW, HW_SETPERF }; + int new_perf = -1; if (strcmp(policy, "low") == 0) { policy = "manual"; - setlo = 1; + new_perf = 0; + } else if (strcmp(policy, "high") == 0) { + policy = "manual"; + new_perf = 100; } - if (sysctl(hw_perfpol_mib, 2, oldpolicy, &oldsz, + if (sysctl(hw_perfpol_mib, 2, NULL, NULL, policy, strlen(policy) + 1) == -1) logmsg(LOG_INFO, "cannot set hw.perfpolicy"); - if (setlo == 1) { - int hw_perf_mib[] = {CTL_HW, HW_SETPERF}; - int perf; - int new_perf = 0; - size_t perf_sz = sizeof(perf); - if (sysctl(hw_perf_mib, 2, &perf, &perf_sz, &new_perf, perf_sz) == -1) - logmsg(LOG_INFO, "cannot set hw.setperf"); - } + if (new_perf == -1) + return; + + if (sysctl(hw_perf_mib, 2, NULL, NULL, + &new_perf, sizeof(new_perf)) == -1) + logmsg(LOG_INFO, "cannot set hw.setperf"); } void |