From: Kirill A. Korinsky Subject: Re: cpu perfpolicy To: "Ted Unangst" Cc: tech@openbsd.org Date: Sun, 01 Jun 2025 21:52:51 +0200 On Sun, 01 Jun 2025 21:22:59 +0200, "Ted Unangst" wrote: > > This introduces a helper function for hw.perfpolicy that allows more > machine specific policies to be set. > > On my laptop, there's also a fan policy. This affects performance, but > it's not really related to the existing hw.setperf mechanism. For > example, a "silent" fan setting and "high" CPU setting is reasonable. > Exactly what I want, in fact. > > Fortunately, perfpolicy takes a string, which makes it flexible. > This uses two new optional functions to parse and append the policy. > > hw.perfpolicy=silent,auto > It looks like as a very good direction to support things like Intel Hardware P-state via dedicated driver. I like it! > @@ -671,18 +673,22 @@ sysctl_hwperfpolicy(void *oldp, size_t * > if (!cpu_setperf) > return EOPNOTSUPP; > > + policy[0] = 0; > + if (cpu_getpolicy) > + cpu_getpolicy(policy, sizeof(policy)); > + > switch (current_perfpolicy()) { > case PERFPOL_MANUAL: > - strlcpy(policy, "manual", sizeof(policy)); > + strlcat(policy, "manual", sizeof(policy)); > break; > case PERFPOL_AUTO: > - strlcpy(policy, "auto", sizeof(policy)); > + strlcat(policy, "auto", sizeof(policy)); > break; > case PERFPOL_HIGH: > - strlcpy(policy, "high", sizeof(policy)); > + strlcat(policy, "high", sizeof(policy)); > break; > default: > - strlcpy(policy, "unknown", sizeof(policy)); > + strlcat(policy, "unknown", sizeof(policy)); > break; > } > I haven't tried it but after reading the diff I think that after sysctl hw.perfpolicy=silent,auto you'll have result of sysctl hw.perfpolicy as: - auto on AC - unknown on battery -- wbr, Kirill