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

Collapse All | Expand All

(-)usr.sbin/powerd/powerd.c (-14 / +80 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: releng/12.1/usr.sbin/powerd/powerd.c 342981 2019-01-13 02:19:01Z avos $");
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);
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 131-153 Link Here
131
#define DEVD_RETRY_INTERVAL 60 /* seconds */
132
#define DEVD_RETRY_INTERVAL 60 /* seconds */
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.
139
 * a time on different CPUs and waiting for each other.  If nonice
140
 * is 100, only user+sys+intr time will be counted as load; any
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.
139
 */
144
 */
140
static int
145
static int
141
read_usage_times(int *load)
146
read_usage_times(int *load, int nonice, int noidle)
142
{
147
{
143
	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;
144
	static int ncpus = 0;
150
	static int ncpus = 0;
145
	size_t cp_times_len;
151
	size_t cp_times_len, cpx_times_len;
146
	int error, cpu, i, total;
152
	int error, cpu, i, total, excl;
147
153
148
	if (cp_times == NULL) {
154
	if (cp_times == NULL) {
149
		cp_times_len = 0;
155
		cp_times_len = 0;
150
		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);
151
		if (error)
157
		if (error)
152
			return (error);
158
			return (error);
153
		if ((cp_times = malloc(cp_times_len)) == NULL)
159
		if ((cp_times = malloc(cp_times_len)) == NULL)
Lines 155-190 Link Here
155
		if ((cp_times_old = malloc(cp_times_len)) == NULL) {
161
		if ((cp_times_old = malloc(cp_times_len)) == NULL) {
156
			free(cp_times);
162
			free(cp_times);
157
			cp_times = NULL;
163
			cp_times = NULL;
158
			return (errno);
164
			return (errno);
159
		}
165
		}
160
		ncpus = cp_times_len / (sizeof(long) * CPUSTATES);
166
		ncpus = cp_times_len / (sizeof(long) * CPUSTATES);
161
	}
167
	}
162
163
	cp_times_len = sizeof(long) * CPUSTATES * ncpus;
168
	cp_times_len = sizeof(long) * CPUSTATES * ncpus;
164
	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);
165
	if (error)
170
	if (error)
166
		return (error);
171
		return (error);
167
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
168
	if (load) {
195
	if (load) {
169
		*load = 0;
196
		*load = 0;
170
		for (cpu = 0; cpu < ncpus; cpu++) {
197
		for (cpu = 0; cpu < ncpus; cpu++) {
171
			total = 0;
198
			total = 0;
172
			for (i = 0; i < CPUSTATES; i++) {
199
			for (i = 0; i < CPUSTATES; i++) {
173
			    total += cp_times[cpu * CPUSTATES + i] -
200
			    total += cp_times[cpu * CPUSTATES + i] -
174
				cp_times_old[cpu * CPUSTATES + i];
201
				cp_times_old[cpu * CPUSTATES + i];
175
			}
202
			}
176
			if (total == 0)
203
			if (total == 0)
177
				continue;
204
				continue;
178
			*load += 100 - (cp_times[cpu * CPUSTATES + CP_IDLE] -
205
			excl = cp_times[cpu * CPUSTATES + CP_IDLE] -
179
			    cp_times_old[cpu * CPUSTATES + CP_IDLE]) * 100 / total;
206
			    cp_times_old[cpu * CPUSTATES + CP_IDLE];
207
			if (nonice)
208
				excl += nonice*(cp_times[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
218
			*load += 100 - excl * 100 / total;
180
		}
219
		}
181
	}
220
	}
182
221
183
	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);
184
225
185
	return (0);
226
	return (0);
186
}
227
}
187
228
188
static int
229
static int
189
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)
190
{
231
{
Lines 192-207 Link Here
192
	int i, j;
233
	int i, j;
193
	size_t len = 0;
234
	size_t len = 0;
194
235
195
	if (sysctl(levels_mib, 4, NULL, &len, NULL, 0))
236
	if (sysctl(levels_mib, 4, NULL, &len, NULL, 0))
196
		return (-1);
237
		return (-1);
197
	if ((freqstr = malloc(len)) == NULL)
238
	if ((freqstr = malloc(len)) == NULL)
198
		return (-1);
239
		return (-1);
199
	if (sysctl(levels_mib, 4, freqstr, &len, NULL, 0))
240
	if (sysctl(levels_mib, 4, freqstr, &len, NULL, 0)) {
241
		free(freqstr);
200
		return (-1);
242
		return (-1);
243
	}
201
244
202
	*numfreqs = 1;
245
	*numfreqs = 1;
203
	for (p = freqstr; *p != '\0'; p++)
246
	for (p = freqstr; *p != '\0'; p++)
204
		if (*p == ' ')
247
		if (*p == ' ')
205
			(*numfreqs)++;
248
			(*numfreqs)++;
206
249
207
	if ((*freqs = malloc(*numfreqs * sizeof(int))) == NULL) {
250
	if ((*freqs = malloc(*numfreqs * sizeof(int))) == NULL) {
Lines 467-481 Link Here
467
}
510
}
468
511
469
static void
512
static void
470
usage(void)
513
usage(void)
471
{
514
{
472
515
473
	fprintf(stderr,
516
	fprintf(stderr,
474
"usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-m freq] [-M freq] [-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");
475
	exit(1);
518
	exit(1);
476
}
519
}
477
520
478
int
521
int
479
main(int argc, char * argv[])
522
main(int argc, char * argv[])
480
{
523
{
481
	struct timeval timeout;
524
	struct timeval timeout;
Lines 484-512 Link Here
484
	struct pidfh *pfh = NULL;
527
	struct pidfh *pfh = NULL;
485
	const char *pidfile = NULL;
528
	const char *pidfile = NULL;
486
	int freq, curfreq, initfreq, *freqs, i, j, *mwatts, numfreqs, load;
529
	int freq, curfreq, initfreq, *freqs, i, j, *mwatts, numfreqs, load;
487
	int minfreq = -1, maxfreq = -1;
530
	int minfreq = -1, maxfreq = -1;
488
	int ch, mode, mode_ac, mode_battery, mode_none, idle, to;
531
	int ch, mode, mode_ac, mode_battery, mode_none, idle, to;
489
	uint64_t mjoules_used;
532
	uint64_t mjoules_used;
490
	size_t len;
533
	size_t len;
534
	int nonice, noidle;
491
535
492
	/* Default mode for all AC states is adaptive. */
536
	/* Default mode for all AC states is adaptive. */
493
	mode_ac = mode_none = MODE_HIADAPTIVE;
537
	mode_ac = mode_none = MODE_HIADAPTIVE;
494
	mode_battery = MODE_ADAPTIVE;
538
	mode_battery = MODE_ADAPTIVE;
495
	cpu_running_mark = DEFAULT_ACTIVE_PERCENT;
539
	cpu_running_mark = DEFAULT_ACTIVE_PERCENT;
496
	cpu_idle_mark = DEFAULT_IDLE_PERCENT;
540
	cpu_idle_mark = DEFAULT_IDLE_PERCENT;
497
	poll_ival = DEFAULT_POLL_INTERVAL;
541
	poll_ival = DEFAULT_POLL_INTERVAL;
498
	mjoules_used = 0;
542
	mjoules_used = 0;
499
	vflag = 0;
543
	vflag = 0;
544
	nonice = noidle = 0;
500
545
501
	/* User must be root to control frequencies. */
546
	/* User must be root to control frequencies. */
502
	if (geteuid() != 0)
547
	if (geteuid() != 0)
503
		errx(1, "must be root to run");
548
		errx(1, "must be root to run");
504
549
505
	while ((ch = getopt(argc, argv, "a:b:i:m:M:n: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)
506
		switch (ch) {
551
		switch (ch) {
507
		case 'a':
552
		case 'a':
508
			parse_mode(optarg, &mode_ac, ch);
553
			parse_mode(optarg, &mode_ac, ch);
509
			break;
554
			break;
510
		case 'b':
555
		case 'b':
511
			parse_mode(optarg, &mode_battery, ch);
556
			parse_mode(optarg, &mode_battery, ch);
512
			break;
557
			break;
Lines 533-546 Link Here
533
			maxfreq = atoi(optarg);
578
			maxfreq = atoi(optarg);
534
			if (maxfreq < 0) {
579
			if (maxfreq < 0) {
535
				warnx("%d is not a valid CPU frequency",
580
				warnx("%d is not a valid CPU frequency",
536
				    maxfreq);
581
				    maxfreq);
537
				usage();
582
				usage();
538
			}
583
			}
539
			break;
584
			break;
585
		case 'N':
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;
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;
540
		case 'n':
601
		case 'n':
541
			parse_mode(optarg, &mode_none, ch);
602
			parse_mode(optarg, &mode_none, ch);
542
			break;
603
			break;
543
		case 'p':
604
		case 'p':
544
			poll_ival = atoi(optarg);
605
			poll_ival = atoi(optarg);
545
			if (poll_ival < 5) {
606
			if (poll_ival < 5) {
546
				warnx("poll interval is in units of ms");
607
				warnx("poll interval is in units of ms");
Lines 570-592 Link Here
570
	/* Poll interval is in units of ms. */
631
	/* Poll interval is in units of ms. */
571
	poll_ival *= 1000;
632
	poll_ival *= 1000;
572
633
573
	/* Look up various sysctl MIBs. */
634
	/* Look up various sysctl MIBs. */
574
	len = 2;
635
	len = 2;
575
	if (sysctlnametomib("kern.cp_times", cp_times_mib, &len))
636
	if (sysctlnametomib("kern.cp_times", cp_times_mib, &len))
576
		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
	}
577
	len = 4;
643
	len = 4;
578
	if (sysctlnametomib("dev.cpu.0.freq", freq_mib, &len))
644
	if (sysctlnametomib("dev.cpu.0.freq", freq_mib, &len))
579
		err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
645
		err(EX_UNAVAILABLE, "no cpufreq(4) support -- aborting");
580
	len = 4;
646
	len = 4;
581
	if (sysctlnametomib("dev.cpu.0.freq_levels", levels_mib, &len))
647
	if (sysctlnametomib("dev.cpu.0.freq_levels", levels_mib, &len))
582
		err(1, "lookup freq_levels");
648
		err(1, "lookup freq_levels");
583
649
584
	/* Check if we can read the load and supported freqs. */
650
	/* Check if we can read the load and supported freqs. */
585
	if (read_usage_times(NULL))
651
	if (read_usage_times(NULL, nonice, noidle))
586
		err(1, "read_usage_times");
652
		err(1, "read_usage_times");
587
	if (read_freqs(&numfreqs, &freqs, &mwatts, minfreq, maxfreq))
653
	if (read_freqs(&numfreqs, &freqs, &mwatts, minfreq, maxfreq))
588
		err(1, "error reading supported CPU frequencies");
654
		err(1, "error reading supported CPU frequencies");
589
	if (numfreqs == 0)
655
	if (numfreqs == 0)
590
		errx(1, "no CPU frequencies in user-specified range");
656
		errx(1, "no CPU frequencies in user-specified range");
591
657
592
	/* Run in the background unless in verbose mode. */
658
	/* Run in the background unless in verbose mode. */
Lines 760-774 Link Here
760
					continue;
826
					continue;
761
				}
827
				}
762
			}
828
			}
763
			continue;
829
			continue;
764
		}
830
		}
765
831
766
		/* Adaptive mode; get the current CPU usage times. */
832
		/* Adaptive mode; get the current CPU usage times. */
767
		if (read_usage_times(&load)) {
833
		if (read_usage_times(&load, nonice, noidle)) {
768
			if (vflag)
834
			if (vflag)
769
				warn("read_usage_times() failed");
835
				warn("read_usage_times() failed");
770
			continue;
836
			continue;
771
		}
837
		}
772
838
773
		if (mode == MODE_ADAPTIVE) {
839
		if (mode == MODE_ADAPTIVE) {
774
			if (load > cpu_running_mark) {
840
			if (load > cpu_running_mark) {
(-)usr.sbin/powerd/powerd.8 (-37 / +56 lines)
Lines 18-145 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: releng/12.1/usr.sbin/powerd/powerd.8 342981 2019-01-13 02:19:01Z avos $
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 Ar mode
37
.Op Fl n Ar mode
41
.Op Fl p Ar ival
38
.Op Fl M Ar freq
42
.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
43
.Op Fl r Ar percent
43
.Op Fl r Ar percent
44
.Op Fl p Ar ival
44
.Op Fl s Ar source
45
.Op Fl s Ar source
46
.Op Fl P Ar pidfile
45
.Op Fl v
47
.Op Fl v
46
.Sh DESCRIPTION
48
.Sh DESCRIPTION
47
The
49
The
48
.Nm
50
.Nm
49
utility monitors the system state and sets various power control options
51
utility monitors the system state and sets various power control options
50
accordingly.
52
accordingly.
51
It offers power-saving modes that can be
53
It offers power-saving modes that can be
52
individually selected for operation on AC power or batteries.
54
individually selected for operation on AC power or batteries.
53
.Bl -tag -width ".Ar hiadaptive"
55
.Bl -tag -width "hiadaptive"
54
.It Ar maximum
56
.It Cm maximum
55
Choose the highest performance values.
57
Choose the highest performance values.
56
May be abbreviated as
58
May be abbreviated as
57
.Ar max .
59
.Cm max .
58
.It Ar minimum
60
.It Cm minimum
59
Choose the lowest performance values to get the most power savings.
61
Choose the lowest performance values to get the most power savings.
60
May be abbreviated as
62
May be abbreviated as
61
.Ar min .
63
.Cm min .
62
.It Ar adaptive
64
.It Cm adaptive
63
Attempt to strike a balance by degrading performance when the system
65
Attempt to strike a balance by degrading performance when the system
64
appears idle and increasing it when the system is busy.
66
appears idle and increasing it when the system is busy.
65
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
66
increased power savings.
68
increased power savings.
67
May be abbreviated as
69
May be abbreviated as
68
.Ar adp .
70
.Cm adp .
69
.It Ar hiadaptive
71
.It Cm hiadaptive
70
Like
72
Like
71
.Ar adaptive
73
.Cm adaptive
72
mode, but tuned for systems where performance and interactivity are
74
mode, but tuned for systems where performance and interactivity are
73
more important than power consumption.
75
more important than power consumption.
74
It increases frequency faster, reduces frequency less aggressively, and
76
It increases frequency faster, reduces frequency less aggressively, and
75
will maintain full frequency for longer.
77
will maintain full frequency for longer.
76
May be abbreviated as
78
May be abbreviated as
77
.Ar hadp .
79
.Cm hadp .
78
.El
80
.El
79
.Pp
81
.Pp
80
The default mode is
82
The default mode is
81
.Ar adaptive
83
.Cm adaptive
82
for battery power and
84
for battery power and
83
.Ar hiadaptive
85
.Cm hiadaptive
84
for the rest.
86
for the rest.
85
.Pp
87
.Pp
86
.Nm
88
.Nm
87
recognizes these runtime options:
89
recognizes these runtime options:
88
.Bl -tag -width ".Fl r Ar percent"
90
.Bl -tag -width "-r percent"
89
.It Fl a Ar mode
91
.It Fl a Ar mode
90
Selects the
92
Selects the
91
.Ar mode
93
.Ar mode
92
to use while on AC power.
94
to use while on AC power.
93
.It Fl b Ar mode
95
.It Fl b Ar mode
94
Selects the
96
Selects the
95
.Ar mode
97
.Ar mode
96
to use while on battery power.
98
to use while on battery power.
97
.It Fl i Ar percent
98
Specifies the CPU load percent level when adaptive
99
mode should begin to degrade performance to save power.
100
The default is 50% or lower.
101
.It Fl m Ar freq
102
Specifies the minimum frequency to throttle down to.
103
.It Fl M Ar freq
104
Specifies the maximum frequency to throttle up to.
105
.It Fl n Ar mode
99
.It Fl n Ar mode
106
Selects the
100
Selects the
107
.Ar mode
101
.Ar mode
108
to use normally when the AC line state is unknown.
102
to use normally when the AC line state is unknown.
109
.It Fl p Ar ival
103
.It Fl M Ar freq
110
Specifies a different polling interval (in milliseconds) for AC line state
104
Specifies the maximum frequency to throttle up to.
111
and system idle levels.
105
.It Fl m Ar freq
112
The default is 250 ms.
106
Specifies the minimum frequency to throttle down to.
113
.It Fl P Ar pidfile
107
.It Fl N Ar percent
114
Specifies an alternative file in which the process ID should be stored.
108
Weight "nice" CPU time by the given scale.
115
The default is
109
.It Fl I Ar percent
116
.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.
117
.It Fl r Ar percent
123
.It Fl r Ar percent
118
Specifies the CPU load percent level where adaptive
124
Specifies the CPU load percent level where adaptive
119
mode should consider the CPU running and increase performance.
125
mode should consider the CPU running and increase performance.
120
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.
121
.It Fl s Ar source
131
.It Fl s Ar source
122
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
123
automatically.
133
automatically.
124
The set of valid methods is
134
The set of valid methods is
125
.Cm sysctl , devd
135
.Cm sysctl , devd
126
and
136
and
127
.Cm apm
137
.Cm apm
128
(i386 only).
138
(i386 only).
139
.It Fl P Ar pidfile
140
Specifies an alternative file in which the process ID should be stored.
129
.It Fl v
141
.It Fl v
130
Verbose mode.
142
Verbose mode.
131
Messages about power changes will be printed to stdout and
143
Messages about power changes will be printed to stdout and
132
.Nm
144
.Nm
133
will operate in the foreground.
145
will operate in the foreground.
134
.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
135
.Sh SEE ALSO
152
.Sh SEE ALSO
136
.Xr acpi 4 ,
153
.Xr acpi 4 ,
137
.Xr apm 4 ,
154
.Xr apm 4 ,
138
.Xr cpufreq 4
155
.Xr cpufreq 4 ,
156
.Xr nice 1 ,
157
.Xr idprio 1 .
139
.Sh HISTORY
158
.Sh HISTORY
140
The
159
The
141
.Nm
160
.Nm
142
utility first appeared in
161
utility first appeared in
143
.Fx 6.0 .
162
.Fx 6.0 .
144
.Sh AUTHORS
163
.Sh AUTHORS
145
.An -nosplit
164
.An -nosplit

Return to bug 246940