Commit Graph

65 Commits

Author SHA1 Message Date
Mateusz Piotrowski
98b486dc7a powerd.8: Improve style & fix typos
- Sort options.
- Do not use macros (like .Ar) to specify width for Bl (macros within that
  string are not expanded).
- Use Cm instead of Ar for mode names.
- Fix some typos reported by mandoc.
- Move the documentation of the PID file from the -P flag description to
  the FILES section.

Approved by:	bcr (mentor)
Differential Revision:	https://reviews.freebsd.org/D23941
2020-03-03 13:25:08 +00:00
Colin Percival
d91382866f Add -N option to powerd(8) to ignore "nice" time.
With powerd_flags="-N", this makes powerd(8) exclude "nice" time when
computing the CPU utilization.  This makes it possible to prevent
CPU-intensive "background" processes from spinning up the CPU.

Note that only *userland* CPU usage belonging to "nice" processes is
excluded; we do not track whether time spent in the kernel is on behalf
of nice or non-nice processes, so kernel-intensive nice processes can
still result in the CPU being sped up.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D23868
2020-02-29 22:31:23 +00:00
Mark Johnston
2a73387f1c powerd(8): Fix a memory leak when we fail to read frequency levels.
PR:		242967
Submitted by:	Hans Christian Woithe <chwoithe@yahoo.com>
MFC after:	3 days
2019-12-29 20:57:49 +00:00
Andriy Voskoboinyk
5c81ba5ade powerd(8): allow to force a method of battery state query
This change allows to determine power source via sysctl or /dev/apm
when devd(8) is running (used by default).

Based on patch from PR; other changes on top of it:
- '-f' (force) -> '-s' (source) parameter renaming;
- allow 'apm' -> 'devd' transition when '-s devd' is set
(if APM is enabled);
- man page update.

Checked on amd64 with -s devd / sysctl and apm
(an extra build with forced USE_APM define set was done)

PR:		125707
Submitted by:	Konstantin Stepanov <milezv@yandex.ru>
Reviewed by:	bcr, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D18742
2019-01-06 02:39:03 +00:00
Eitan Adler
48c7315619 powerd: correct ifdef check for ppc
Reviewed by:	jhibbits
2018-06-27 01:28:09 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Baptiste Daroussin
79477f3ca1 Directly set the NONBLOCK flags when creating the socket
No functional changes
2016-05-10 11:18:53 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Alexander Motin
0e2a18e657 Add comment explaining existing powerd behavior on SMP systems.
MFC after:	1 week
2015-03-20 15:07:05 +00:00
Baptiste Daroussin
c6db8143ed Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Christian Brueffer
a051bcb130 In acline_init(), initialize ac_line to SRC_UNKNOWN. Previously
this could lead to the -n option effectively being ignored (in case
ac_line happened to be 0 aka SRC_AC), or other undefined behaviour.

PR:		169779
Submitted by:	Alex Gonzalez <loox at e-shell.net>
Reviewed by:	jhb
MFC after:	2 weeks
2014-02-11 15:16:49 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Warren Block
3e01326432 Whitespace fixes: remove tabs on blank links, spaces following content,
tabs after spaces.

Reviewed by:	gjb
MFC after:	1 week
2013-07-04 18:59:58 +00:00
Warren Block
27f90bebef Put the power modes in a list to make them easier to find.
Reviewed by:	joel
MFC after:	1 week
2013-07-04 12:24:39 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Robert Millan
7b3b368344 Improve error reporting when no cpufreq(4) support is available.
Reviewed by:	njl, acpi
2012-04-09 20:59:14 +00:00
Ed Schouten
e120624d32 Add missing static keyword.
All global variables and functions in powerd are marked static, except
this array of strings. Add the keyword, for consistency.
2011-12-11 19:22:42 +00:00
Rebecca Cran
cf2280aca7 Add -m and -M options to control the minimum and maximum frequency.
PR:	bin/145063
Submitted by:	Boris Kochergin <spawk at acm.poly.edu>
Reviewed by:	cperciva
Approved by:	rrs (mentor)
MFC after: 2 weeks
2010-08-17 09:11:38 +00:00
Alexander Motin
773b251c07 Freq sysctls are quite heavy due to set of malloc()/free() calls. Avoid
reading current frequency on every period. Instead do it only after
changing and periodically from time to time if somebody else change it.

Also dynamically decrease sampling frequency up to 4 times on inactivity,
2010-06-16 15:09:45 +00:00
Joerg Wunsch
0a47b5f57f then -> than
MFC after:	1 day
2010-03-15 16:06:52 +00:00
Warner Losh
7a377edc31 Since APM is a legacy technology, that won't be adapted to other
platforms, move the test for i386 from the Makefile to powerd.c.  The
powerpc specific checks are already done this way...
2010-02-04 07:26:26 +00:00
Ed Schouten
71ccf09269 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
Ed Schouten
10bc3a7f42 ANSIfy almost all applications that use WARNS=6.
I was considering committing all these patches one by one, but as
discussed with brooks@, there is no need to do this. If we ever
need/want to merge these changes back, it is still possible to do this
per application.
2009-12-29 22:53:27 +00:00
Gavin Atkinson
484b7a091f Grammar and minor tweaks to powerd(8) man page.
PR:		docs/133186
Approved by:	ed (mentor)
MFC after:	2 weeks
2009-12-21 22:56:06 +00:00
Nathan Whitehorn
ebcc3763a8 Teach powerd how to query the PMU AC line state on PowerPC. 2009-05-31 10:27:24 +00:00
Tom Rhodes
5d8e279e37 Fix a typo higter->higher.
Spotted by:	ganbold
2008-12-24 09:17:30 +00:00
Alexander Motin
8cb16fdbea Restore original frequency on exit.
PR:		bin/113813
2008-11-18 15:48:23 +00:00
Alexander Motin
dbd3197760 Set of powerd enchancements:
1. Make it more SMP polite. Previous version uses average CPU load that
often leads to load underestimation. It make powerd with default
configuration unusable on systems with more then 2 CPUs. I propose to use
summary load instead of average one. IMO this is the best we can do without
specially tuned scheduler. Also as soon as measuring total load on SMP
systems is more useful then total idle, I have switched to it.

2. Make powerd's operation independent from number and size of frequency
levels. I have added internal frequency counter which translated into real
frequencies only on a last stage and only as good as gone. Some systems may
have only several power levels, while others - many of them, so adaptation
time with previous approach was completely different.

3. As part of previous I have changed adaptive mode to rise frequency on
demand up to 2 times and fall on 1/8 per time internal.

4. For desktop (AC-powered) systems I have added one more mode - "hiadaptive".
It rises frequency twice faster, drops it 4 times slower, prefers twice
lower CPU load and has additional delay before leaving the highest frequency
after the period of maximum load. This mode was specially made to improve
interactivity of the systems where operation capabilities are more
significant then power consumption, but keeping maximum frequency all the
time is not needed.

5. I have reduced default polling interval from 1/2 to 1/4 of second.
It is not so important for algorithm math now, but gives better system
interactivity.

Discussed on:	mobile@
2008-11-18 13:24:38 +00:00
David E. O'Brien
dc70a966e3 Add an abbreviation for adaptive mode, and document all the abreviations. 2008-06-22 17:52:57 +00:00
Kevin Lo
8f9872ccb3 getopt(3) returns -1, not EOF. 2008-02-18 03:19:25 +00:00
Dmitry Morozovsky
89a630d080 Failing to set new frequency should not lead to powerd exiting.
Change err(3) to warn(3) as three other cases.

Approved by:	njl, des
2007-06-13 19:05:11 +00:00
Dag-Erling Smørgrav
f1e58a9ac4 Back out revs 1.18 and 1.19; they were based on incorrect assumptions.
Requested by:	nate
2006-02-19 00:40:28 +00:00
Dag-Erling Smørgrav
af2cde52b3 Look for cpu/ichss instead of cpu/p4tcc, which is i386/amd64-only. 2006-02-18 16:01:07 +00:00
Dag-Erling Smørgrav
aa5cfd0420 Load cpufreq at startup if it isn't there already. 2006-02-18 11:35:12 +00:00
Dag-Erling Smørgrav
2f7a934c4f Don't use threads when there's no real reason to.
MFC after:	2 weeks
2006-01-03 21:32:02 +00:00
Joel Dahl
19797b2256 s/5.5/6.0/ in HISTORY section.
Discussed with:	ru
2005-11-24 09:25:10 +00:00
Ruslan Ermilov
78ad54210f -mdoc sweep. 2005-11-18 10:56:28 +00:00
Pawel Jakub Dawidek
177b9d3b7b Be more consistent with the rest of the manual page. 2005-11-06 20:01:47 +00:00
Nate Lawson
33a00fc0b1 Create the devd thread after we have called daemon(). Otherwise, it would
be killed when the parent exits.

Submitted by:	Rudolf Cejka <cejkar / fit.vutbr.cz>
2005-10-24 18:34:54 +00:00
Nate Lawson
b194bdc2ae Whitespace fix. 2005-10-23 00:55:56 +00:00
Nate Lawson
72699a2216 Set the signal handlers before creating the thread. This is so it inherits
the parent's signal mask.  Once daemon() forked, signals would be ignored
in the child thread.  While I'm here, check the return value of daemon().
This fixes termination in the daemon case (bug introduced in last commit).

Noticed by:	Frederik Lindberg
2005-10-20 05:12:20 +00:00
Nate Lawson
a1819ab598 Use a pipe for reading devd events as another method of getting the AC line
status.  Add a thread that waits for events on the named pipe instead of
polling the line status via apm or the ACPI sysctl.  Additionally, use
robust error handling in case devd goes away or we temporarily can't set
a frequency (i.e., passive cooling has preempted our setting).

Later, this should be improved so that if adaptive control is not being used,
we will block while waiting for AC line events, saving a little CPU.

Submitted by:	Frederik Lindberg <fli+freebsd-current/shapeshifter.se>
2005-10-19 04:48:44 +00:00