View | Details | Raw Unified | Return to bug 246940 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/powerd/powerd.c (-16 / +69 lines)
Lines 24-38 Link Here
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
 * POSSIBILITY OF SUCH DAMAGE.
27
 * POSSIBILITY OF SUCH DAMAGE.
28
 */
28
 */
29
29
30
#include <sys/cdefs.h>
30
#include <sys/cdefs.h>
31
__FBSDID("$FreeBSD: stable/12/usr.sbin/powerd/powerd.c 358990 2020-03-14 06:57:50Z cperciva $");
31
__FBSDID("$FreeBSD: head/usr.sbin/powerd/powerd.c 358478 2020-02-29 22:31:23Z cperciva $");
32
32
33
#include <sys/param.h>
33
#include <sys/param.h>
34
#include <sys/ioctl.h>
34
#include <sys/ioctl.h>
35
#include <sys/sysctl.h>
35
#include <sys/sysctl.h>
36
#include <sys/resource.h>
36
#include <sys/resource.h>
37
#include <sys/socket.h>
37
#include <sys/socket.h>
38
#include <sys/time.h>
38
#include <sys/time.h>
Lines 82-109 Link Here
82
82
83
#define ACPIAC		"hw.acpi.acline"
83
#define ACPIAC		"hw.acpi.acline"
84
#define PMUAC		"dev.pmu.0.acline"
84
#define PMUAC		"dev.pmu.0.acline"
85
#define APMDEV		"/dev/apm"
85
#define APMDEV		"/dev/apm"
86
#define DEVDPIPE	"/var/run/devd.pipe"
86
#define DEVDPIPE	"/var/run/devd.pipe"
87
#define DEVCTL_MAXBUF	1024
87
#define DEVCTL_MAXBUF	1024
88
88
89
static int	read_usage_times(int *load, int nonice);
89
static int	read_usage_times(int *load, int nonice, int noidle);
90
static int	read_freqs(int *numfreqs, int **freqs, int **power,
90
static int	read_freqs(int *numfreqs, int **freqs, int **power,
91
		    int minfreq, int maxfreq);
91
		    int minfreq, int maxfreq);
92
static int	set_freq(int freq);
92
static int	set_freq(int freq);
93
static void	acline_init(void);
93
static void	acline_init(void);
94
static void	acline_read(void);
94
static void	acline_read(void);
95
static int	devd_init(void);
95
static int	devd_init(void);
96
static void	devd_close(void);
96
static void	devd_close(void);
97
static void	handle_sigs(int sig);
97
static void	handle_sigs(int sig);
98
static void	parse_mode(char *arg, int *mode, int ch);
98
static void	parse_mode(char *arg, int *mode, int ch);
99
static void	usage(void);
99
static void	usage(void);
100
100
101
/* Sysctl data structures. */
101
/* Sysctl data structures. */
102
static int	cp_times_mib[2];
102
static int	cp_times_mib[2];
103
static int	cpx_times_mib[2];
103
static int	freq_mib[4];
104
static int	freq_mib[4];
104
static int	levels_mib[4];
105
static int	levels_mib[4];
105
static int	acline_mib[4];
106
static int	acline_mib[4];
106
static size_t	acline_mib_len;
107
static size_t	acline_mib_len;
107
108
108
/* Configuration */
109
/* Configuration */
109
static int	cpu_running_mark;
110
static int	cpu_running_mark;
Lines 132-154 Link Here
132
static struct timeval tried_devd;
133
static struct timeval tried_devd;
133
134
134
/*
135
/*
135
 * This function returns summary load of all CPUs.  It was made so
136
 * This function returns summary load of all CPUs.  It was made so
136
 * intentionally to not reduce performance in scenarios when several
137
 * intentionally to not reduce performance in scenarios when several
137
 * threads are processing requests as a pipeline -- running one at
138
 * threads are processing requests as a pipeline -- running one at
138
 * a time on different CPUs and waiting for each other.  If nonice
139
 * a time on different CPUs and waiting for each other.  If nonice
139
 * is nonzero, only user+sys+intr time will be counted as load; any
140
 * is 100, only user+sys+intr time will be counted as load; any
140
 * nice time will be treated as if idle.
141
 * nice time will be treated as if idle, likewise noidle.  I.e. these
142
 * nice and/or idle loads are weighted by nonice and noidle, resp.
143
 * NOTE nonice and noidle are the "reverse" from the the command line.
141
 */
144
 */
142
static int
145
static int
143
read_usage_times(int *load, int nonice)
146
read_usage_times(int *load, int nonice, int noidle)
144
{
147
{
145
	static long *cp_times = NULL, *cp_times_old = NULL;
148
	static long *cp_times = NULL, *cp_times_old = NULL;
149
	static long *cpx_times = NULL, *cpx_times_old = NULL;
146
	static int ncpus = 0;
150
	static int ncpus = 0;
147
	size_t cp_times_len;
151
	size_t cp_times_len, cpx_times_len;
148
	int error, cpu, i, total, excl;
152
	int error, cpu, i, total, excl;
149
153
150
	if (cp_times == NULL) {
154
	if (cp_times == NULL) {
151
		cp_times_len = 0;
155
		cp_times_len = 0;
152
		error = sysctl(cp_times_mib, 2, NULL, &cp_times_len, NULL, 0);
156
		error = sysctl(cp_times_mib, 2, NULL, &cp_times_len, NULL, 0);
153
		if (error)
157
		if (error)
154
			return (error);
158
			return (error);
Lines 157-196 Link Here
157
		if ((cp_times_old = malloc(cp_times_len)) == NULL) {
161
		if ((cp_times_old = malloc(cp_times_len)) == NULL) {
158
			free(cp_times);
162
			free(cp_times);
159
			cp_times = NULL;
163
			cp_times = NULL;
160
			return (errno);
164
			return (errno);
161
		}
165
		}
162
		ncpus = cp_times_len / (sizeof(long) * CPUSTATES);
166
		ncpus = cp_times_len / (sizeof(long) * CPUSTATES);
163
	}
167
	}
164
165
	cp_times_len = sizeof(long) * CPUSTATES * ncpus;
168
	cp_times_len = sizeof(long) * CPUSTATES * ncpus;
166
	error = sysctl(cp_times_mib, 2, cp_times, &cp_times_len, NULL, 0);
169
	error = sysctl(cp_times_mib, 2, cp_times, &cp_times_len, NULL, 0);
167
	if (error)
170
	if (error)
168
		return (error);
171
		return (error);
169
172
173
	if (noidle) {
174
		if (cpx_times == NULL) {
175
			cpx_times_len = 0;
176
			error = sysctl(cpx_times_mib, 2, NULL, &cpx_times_len, NULL, 0);
177
			if (error)
178
				return (error);
179
			if ((cpx_times = malloc(cpx_times_len)) == NULL)
180
				return (errno);
181
			if ((cpx_times_old = malloc(cpx_times_len)) == NULL) {
182
				free(cpx_times);
183
				cpx_times = NULL;
184
				return (errno);
185
			}
186
		}
187
		/* FIXME This could be as assert (...);				*/
188
		/* ncpus = cpx_times_len / (sizeof(long) * CPUSTATES_EXT);	*/
189
		cpx_times_len = sizeof(long) * CPUSTATES_EXT * ncpus;
190
		error = sysctl(cpx_times_mib, 2, cpx_times, &cpx_times_len, NULL, 0);
191
		if (error)
192
			return (error);
193
	}
194
170
	if (load) {
195
	if (load) {
171
		*load = 0;
196
		*load = 0;
172
		for (cpu = 0; cpu < ncpus; cpu++) {
197
		for (cpu = 0; cpu < ncpus; cpu++) {
173
			total = 0;
198
			total = 0;
174
			for (i = 0; i < CPUSTATES; i++) {
199
			for (i = 0; i < CPUSTATES; i++) {
175
			    total += cp_times[cpu * CPUSTATES + i] -
200
			    total += cp_times[cpu * CPUSTATES + i] -
176
				cp_times_old[cpu * CPUSTATES + i];
201
				cp_times_old[cpu * CPUSTATES + i];
177
			}
202
			}
178
			if (total == 0)
203
			if (total == 0)
179
				continue;
204
				continue;
180
			excl = cp_times[cpu * CPUSTATES + CP_IDLE] -
205
			excl = cp_times[cpu * CPUSTATES + CP_IDLE] -
181
			    cp_times_old[cpu * CPUSTATES + CP_IDLE];
206
			    cp_times_old[cpu * CPUSTATES + CP_IDLE];
182
			if (nonice)
207
			if (nonice)
183
				excl += cp_times[cpu * CPUSTATES + CP_NICE] -
208
				excl += nonice*(cp_times[cpu * CPUSTATES + CP_NICE] -
184
				    cp_times_old[cpu * CPUSTATES + CP_NICE];
209
				    cp_times_old[cpu * CPUSTATES + CP_NICE])/100;
210
			/* These two can overlap: e.g. a command started "nice idprio 5 ..." */
211
			else if (noidle)
212
				excl += noidle*(cpx_times[cpu * CPUSTATES_EXT + CPX_NICE_IDLE] -
213
				    cpx_times_old[cpu * CPUSTATES_EXT + CPX_NICE_IDLE])/100;
214
			if (noidle)
215
				excl += noidle*(cpx_times[cpu * CPUSTATES_EXT + CPX_USER_IDLE] -
216
				    cpx_times_old[cpu * CPUSTATES_EXT + CPX_USER_IDLE])/100;
217
185
			*load += 100 - excl * 100 / total;
218
			*load += 100 - excl * 100 / total;
186
		}
219
		}
187
	}
220
	}
188
221
189
	memcpy(cp_times_old, cp_times, cp_times_len);
222
	memcpy(cp_times_old, cp_times, cp_times_len);
223
	if (noidle)
224
		memcpy(cpx_times_old, cpx_times, cpx_times_len);
190
225
191
	return (0);
226
	return (0);
192
}
227
}
193
228
194
static int
229
static int
195
read_freqs(int *numfreqs, int **freqs, int **power, int minfreq, int maxfreq)
230
read_freqs(int *numfreqs, int **freqs, int **power, int minfreq, int maxfreq)
196
{
231
{
Lines 475-489 Link Here
475
}
510
}
476
511
477
static void
512
static void
478
usage(void)
513
usage(void)
479
{
514
{
480
515
481
	fprintf(stderr,
516
	fprintf(stderr,
482
"usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-m freq] [-M freq] [-N] [-n mode] [-p ival] [-r %%] [-s source] [-P pidfile]\n");
517
"usage: powerd [-v] [-a mode] [-b mode] [-n mode] [-i %%] [-m freq] [-M freq] [-N %%] [-I %%] [-p ival] [-r %%] [-s source] [-P pidfile]\n");
483
	exit(1);
518
	exit(1);
484
}
519
}
485
520
486
int
521
int
487
main(int argc, char * argv[])
522
main(int argc, char * argv[])
488
{
523
{
489
	struct timeval timeout;
524
	struct timeval timeout;
Lines 492-522 Link Here
492
	struct pidfh *pfh = NULL;
527
	struct pidfh *pfh = NULL;
493
	const char *pidfile = NULL;
528
	const char *pidfile = NULL;
494
	int freq, curfreq, initfreq, *freqs, i, j, *mwatts, numfreqs, load;
529
	int freq, curfreq, initfreq, *freqs, i, j, *mwatts, numfreqs, load;
495
	int minfreq = -1, maxfreq = -1;
530
	int minfreq = -1, maxfreq = -1;
496
	int ch, mode, mode_ac, mode_battery, mode_none, idle, to;
531
	int ch, mode, mode_ac, mode_battery, mode_none, idle, to;
497
	uint64_t mjoules_used;
532
	uint64_t mjoules_used;
498
	size_t len;
533
	size_t len;
499
	int nonice;
534
	int nonice, noidle;
500
535
501
	/* Default mode for all AC states is adaptive. */
536
	/* Default mode for all AC states is adaptive. */
502
	mode_ac = mode_none = MODE_HIADAPTIVE;
537
	mode_ac = mode_none = MODE_HIADAPTIVE;
503
	mode_battery = MODE_ADAPTIVE;
538
	mode_battery = MODE_ADAPTIVE;
504
	cpu_running_mark = DEFAULT_ACTIVE_PERCENT;
539
	cpu_running_mark = DEFAULT_ACTIVE_PERCENT;
505
	cpu_idle_mark = DEFAULT_IDLE_PERCENT;
540
	cpu_idle_mark = DEFAULT_IDLE_PERCENT;
506
	poll_ival = DEFAULT_POLL_INTERVAL;
541
	poll_ival = DEFAULT_POLL_INTERVAL;
507
	mjoules_used = 0;
542
	mjoules_used = 0;
508
	vflag = 0;
543
	vflag = 0;
509
	nonice = 0;
544
	nonice = noidle = 0;
510
545
511
	/* User must be root to control frequencies. */
546
	/* User must be root to control frequencies. */
512
	if (geteuid() != 0)
547
	if (geteuid() != 0)
513
		errx(1, "must be root to run");
548
		errx(1, "must be root to run");
514
549
515
	while ((ch = getopt(argc, argv, "a:b:i:m:M:Nn:p:P:r:s:v")) != -1)
550
	while ((ch = getopt(argc, argv, "a:b:i:m:M:N:I:n:p:P:r:s:v")) != -1)
516
		switch (ch) {
551
		switch (ch) {
517
		case 'a':
552
		case 'a':
518
			parse_mode(optarg, &mode_ac, ch);
553
			parse_mode(optarg, &mode_ac, ch);
519
			break;
554
			break;
520
		case 'b':
555
		case 'b':
521
			parse_mode(optarg, &mode_battery, ch);
556
			parse_mode(optarg, &mode_battery, ch);
522
			break;
557
			break;
Lines 544-559 Link Here
544
			if (maxfreq < 0) {
579
			if (maxfreq < 0) {
545
				warnx("%d is not a valid CPU frequency",
580
				warnx("%d is not a valid CPU frequency",
546
				    maxfreq);
581
				    maxfreq);
547
				usage();
582
				usage();
548
			}
583
			}
549
			break;
584
			break;
550
		case 'N':
585
		case 'N':
551
			nonice = 1;
586
			nonice = atoi(optarg);
587
			if (nonice < 0 || nonice > 100) {
588
				warnx("%d is not a valid percent", nonice);
589
				usage();
590
			} else
591
				nonice = 100 - nonice;
552
			break;
592
			break;
593
		case 'I':
594
			noidle = atoi(optarg);
595
			if (noidle < 0 || noidle > 100) {
596
				warnx("%d is not a valid percent", noidle);
597
				usage();
598
			} else
599
				noidle = 100 - noidle;
600
			break;
553
		case 'n':
601
		case 'n':
554
			parse_mode(optarg, &mode_none, ch);
602
			parse_mode(optarg, &mode_none, ch);
555
			break;
603
			break;
556
		case 'p':
604
		case 'p':
557
			poll_ival = atoi(optarg);
605
			poll_ival = atoi(optarg);
558
			if (poll_ival < 5) {
606
			if (poll_ival < 5) {
559
				warnx("poll interval is in units of ms");
607
				warnx("poll interval is in units of ms");
Lines 583-605 Link Here
583
	/* Poll interval is in units of ms. */
631
	/* Poll interval is in units of ms. */
584
	poll_ival *= 1000;
632
	poll_ival *= 1000;
585
633
586
	/* Look up various sysctl MIBs. */
634
	/* Look up various sysctl MIBs. */
587
	len = 2;
635
	len = 2;
588
	if (sysctlnametomib("kern.cp_times", cp_times_mib, &len))
636
	if (sysctlnametomib("kern.cp_times", cp_times_mib, &len))
589
		err(1, "lookup kern.cp_times");
637
		err(1, "lookup kern.cp_times");
638
	if (noidle) {
639
		len = 2;
640
		if (sysctlnametomib("kern.cp_times_ext", cpx_times_mib, &len))
641
			err(1, "lookup kern.cp_times_ext");
642
	}
590
	len = 4;
643
	len = 4;
591
	if (sysctlnametomib("dev.cpu.0.freq", freq_mib, &len))
644
	if (sysctlnametomib("dev.cpu.0.freq", freq_mib, &len))
592
		err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
645
		err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
593
	len = 4;
646
	len = 4;
594
	if (sysctlnametomib("dev.cpu.0.freq_levels", levels_mib, &len))
647
	if (sysctlnametomib("dev.cpu.0.freq_levels", levels_mib, &len))
595
		err(1, "lookup freq_levels");
648
		err(1, "lookup freq_levels");
596
649
597
	/* Check if we can read the load and supported freqs. */
650
	/* Check if we can read the load and supported freqs. */
598
	if (read_usage_times(NULL, nonice))
651
	if (read_usage_times(NULL, nonice, noidle))
599
		err(1, "read_usage_times");
652
		err(1, "read_usage_times");
600
	if (read_freqs(&numfreqs, &freqs, &mwatts, minfreq, maxfreq))
653
	if (read_freqs(&numfreqs, &freqs, &mwatts, minfreq, maxfreq))
601
		err(1, "error reading supported CPU frequencies");
654
		err(1, "error reading supported CPU frequencies");
602
	if (numfreqs == 0)
655
	if (numfreqs == 0)
603
		errx(1, "no CPU frequencies in user-specified range");
656
		errx(1, "no CPU frequencies in user-specified range");
604
657
605
	/* Run in the background unless in verbose mode. */
658
	/* Run in the background unless in verbose mode. */
Lines 773-787 Link Here
773
					continue;
826
					continue;
774
				}
827
				}
775
			}
828
			}
776
			continue;
829
			continue;
777
		}
830
		}
778
831
779
		/* Adaptive mode; get the current CPU usage times. */
832
		/* Adaptive mode; get the current CPU usage times. */
780
		if (read_usage_times(&load, nonice)) {
833
		if (read_usage_times(&load, nonice, noidle)) {
781
			if (vflag)
834
			if (vflag)
782
				warn("read_usage_times() failed");
835
				warn("read_usage_times() failed");
783
			continue;
836
			continue;
784
		}
837
		}
785
838
786
		if (mode == MODE_ADAPTIVE) {
839
		if (mode == MODE_ADAPTIVE) {
787
			if (load > cpu_running_mark) {
840
			if (load > cpu_running_mark) {
(-)usr.sbin/powerd/powerd.8 (-42 / +56 lines)
Lines 18-150 Link Here
18
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
.\" SUCH DAMAGE.
23
.\" SUCH DAMAGE.
24
.\"
24
.\"
25
.\" $FreeBSD: stable/12/usr.sbin/powerd/powerd.8 358990 2020-03-14 06:57:50Z cperciva $
25
.\" $FreeBSD: head/usr.sbin/powerd/powerd.8 358574 2020-03-03 13:25:08Z 0mp $
26
.\"
26
.\"
27
.Dd January 13, 2019
27
.Dd Jan 27, 2021
28
.Dt POWERD 8
28
.Dt POWERD 8
29
.Os
29
.Os
30
.Sh NAME
30
.Sh NAME
31
.Nm powerd
31
.Nm powerd
32
.Nd "system power control utility"
32
.Nd "system power control utility"
33
.Sh SYNOPSIS
33
.Sh SYNOPSIS
34
.Nm
34
.Nm
35
.Op Fl a Ar mode
35
.Op Fl a Ar mode
36
.Op Fl b Ar mode
36
.Op Fl b Ar mode
37
.Op Fl i Ar percent
38
.Op Fl m Ar freq
39
.Op Fl M Ar freq
40
.Op Fl N
41
.Op Fl n Ar mode
37
.Op Fl n Ar mode
42
.Op Fl p Ar ival
38
.Op Fl M Ar freq
43
.Op Fl P Ar pidfile
39
.Op Fl m Ar freq
40
.Op Fl N Ar percent
41
.Op Fl I Ar percent
42
.Op Fl i Ar percent
44
.Op Fl r Ar percent
43
.Op Fl r Ar percent
44
.Op Fl p Ar ival
45
.Op Fl s Ar source
45
.Op Fl s Ar source
46
.Op Fl P Ar pidfile
46
.Op Fl v
47
.Op Fl v
47
.Sh DESCRIPTION
48
.Sh DESCRIPTION
48
The
49
The
49
.Nm
50
.Nm
50
utility monitors the system state and sets various power control options
51
utility monitors the system state and sets various power control options
51
accordingly.
52
accordingly.
52
It offers power-saving modes that can be
53
It offers power-saving modes that can be
53
individually selected for operation on AC power or batteries.
54
individually selected for operation on AC power or batteries.
54
.Bl -tag -width ".Ar hiadaptive"
55
.Bl -tag -width "hiadaptive"
55
.It Ar maximum
56
.It Cm maximum
56
Choose the highest performance values.
57
Choose the highest performance values.
57
May be abbreviated as
58
May be abbreviated as
58
.Ar max .
59
.Cm max .
59
.It Ar minimum
60
.It Cm minimum
60
Choose the lowest performance values to get the most power savings.
61
Choose the lowest performance values to get the most power savings.
61
May be abbreviated as
62
May be abbreviated as
62
.Ar min .
63
.Cm min .
63
.It Ar adaptive
64
.It Cm adaptive
64
Attempt to strike a balance by degrading performance when the system
65
Attempt to strike a balance by degrading performance when the system
65
appears idle and increasing it when the system is busy.
66
appears idle and increasing it when the system is busy.
66
It offers a good balance between a small performance loss for greatly
67
It offers a good balance between a small performance loss for greatly
67
increased power savings.
68
increased power savings.
68
May be abbreviated as
69
May be abbreviated as
69
.Ar adp .
70
.Cm adp .
70
.It Ar hiadaptive
71
.It Cm hiadaptive
71
Like
72
Like
72
.Ar adaptive
73
.Cm adaptive
73
mode, but tuned for systems where performance and interactivity are
74
mode, but tuned for systems where performance and interactivity are
74
more important than power consumption.
75
more important than power consumption.
75
It increases frequency faster, reduces frequency less aggressively, and
76
It increases frequency faster, reduces frequency less aggressively, and
76
will maintain full frequency for longer.
77
will maintain full frequency for longer.
77
May be abbreviated as
78
May be abbreviated as
78
.Ar hadp .
79
.Cm hadp .
79
.El
80
.El
80
.Pp
81
.Pp
81
The default mode is
82
The default mode is
82
.Ar adaptive
83
.Cm adaptive
83
for battery power and
84
for battery power and
84
.Ar hiadaptive
85
.Cm hiadaptive
85
for the rest.
86
for the rest.
86
.Pp
87
.Pp
87
.Nm
88
.Nm
88
recognizes these runtime options:
89
recognizes these runtime options:
89
.Bl -tag -width ".Fl r Ar percent"
90
.Bl -tag -width "-r percent"
90
.It Fl a Ar mode
91
.It Fl a Ar mode
91
Selects the
92
Selects the
92
.Ar mode
93
.Ar mode
93
to use while on AC power.
94
to use while on AC power.
94
.It Fl b Ar mode
95
.It Fl b Ar mode
95
Selects the
96
Selects the
96
.Ar mode
97
.Ar mode
97
to use while on battery power.
98
to use while on battery power.
98
.It Fl i Ar percent
99
Specifies the CPU load percent level when adaptive
100
mode should begin to degrade performance to save power.
101
The default is 50% or lower.
102
.It Fl m Ar freq
103
Specifies the minimum frequency to throttle down to.
104
.It Fl M Ar freq
105
Specifies the maximum frequency to throttle up to.
106
.It Fl N
107
Treat "nice" time as idle for the purpose of load calculation;
108
i.e. do not increase the CPU frequency if the CPU is only busy
109
with "nice" processes.
110
.It Fl n Ar mode
99
.It Fl n Ar mode
111
Selects the
100
Selects the
112
.Ar mode
101
.Ar mode
113
to use normally when the AC line state is unknown.
102
to use normally when the AC line state is unknown.
114
.It Fl p Ar ival
103
.It Fl M Ar freq
115
Specifies a different polling interval (in milliseconds) for AC line state
104
Specifies the maximum frequency to throttle up to.
116
and system idle levels.
105
.It Fl m Ar freq
117
The default is 250 ms.
106
Specifies the minimum frequency to throttle down to.
118
.It Fl P Ar pidfile
107
.It Fl N Ar percent
119
Specifies an alternative file in which the process ID should be stored.
108
Weight "nice" CPU time by the given scale.
120
The default is
109
.It Fl I Ar percent
121
.Pa /var/run/powerd.pid .
110
Weight "user idle" CPU time by the given scale.
111
.Pp
112
In both cases, 0 counts like "system idle" for the purpose of
113
.Nm
114
\'s internal load calculation; i.e., do not increase the CPU frequency
115
if the CPU is only busy with "nice" or "user idle" processes.
116
However, the system and interrupt load caused by these processes
117
can not be scaled out.
118
The implied default is 100, to fully count "nice" and "user idle" load.
119
.It Fl i Ar percent
120
Specifies the CPU load percent level when adaptive
121
mode should begin to degrade performance to save power.
122
The default is 50% or lower.
122
.It Fl r Ar percent
123
.It Fl r Ar percent
123
Specifies the CPU load percent level where adaptive
124
Specifies the CPU load percent level where adaptive
124
mode should consider the CPU running and increase performance.
125
mode should consider the CPU running and increase performance.
125
The default is 75% or higher.
126
The default is 75% or higher.
127
.It Fl p Ar ival
128
Specifies a different polling interval (in milliseconds) for AC line state
129
and system idle levels.
130
The default is 250 ms.
126
.It Fl s Ar source
131
.It Fl s Ar source
127
Enforces method for AC line state refresh; by default, it is chosen
132
Enforces method for AC line state refresh; by default, it is chosen
128
automatically.
133
automatically.
129
The set of valid methods is
134
The set of valid methods is
130
.Cm sysctl , devd
135
.Cm sysctl , devd
131
and
136
and
132
.Cm apm
137
.Cm apm
133
(i386 only).
138
(i386 only).
139
.It Fl P Ar pidfile
140
Specifies an alternative file in which the process ID should be stored.
134
.It Fl v
141
.It Fl v
135
Verbose mode.
142
Verbose mode.
136
Messages about power changes will be printed to stdout and
143
Messages about power changes will be printed to stdout and
137
.Nm
144
.Nm
138
will operate in the foreground.
145
will operate in the foreground.
139
.El
146
.El
147
.Sh FILES
148
.Bl -tag -width "/var/run/powerd.pid"
149
.It Pa /var/run/powerd.pid
150
The default PID file.
151
.El
140
.Sh SEE ALSO
152
.Sh SEE ALSO
141
.Xr acpi 4 ,
153
.Xr acpi 4 ,
142
.Xr apm 4 ,
154
.Xr apm 4 ,
143
.Xr cpufreq 4
155
.Xr cpufreq 4 ,
156
.Xr nice 1 ,
157
.Xr idprio 1 .
144
.Sh HISTORY
158
.Sh HISTORY
145
The
159
The
146
.Nm
160
.Nm
147
utility first appeared in
161
utility first appeared in
148
.Fx 6.0 .
162
.Fx 6.0 .
149
.Sh AUTHORS
163
.Sh AUTHORS
150
.An -nosplit
164
.An -nosplit

Return to bug 246940