Commit Graph

62 Commits

Author SHA1 Message Date
avos
bfe253bacb 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
eadler
f5b5222c63 powerd: correct ifdef check for ppc
Reviewed by:	jhibbits
2018-06-27 01:28:09 +00:00
pfg
7551d83c35 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
bdrewery
a598c4b809 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
bapt
a1770aa8e4 Directly set the NONBLOCK flags when creating the socket
No functional changes
2016-05-10 11:18:53 +00:00
sjg
008d7c831f 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
sjg
75a137820d dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
sjg
65145fa4c8 Merge sync of head 2015-05-27 01:19:58 +00:00
mav
7904a438e5 Add comment explaining existing powerd behavior on SMP systems.
MFC after:	1 week
2015-03-20 15:07:05 +00:00
bapt
a191ba5195 Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +00:00
sjg
5860f0d106 Updated dependencies 2014-05-16 14:09:51 +00:00
sjg
1a7e48acf1 Updated dependencies 2014-05-10 05:16:28 +00:00
sjg
5e568154a0 Merge head 2014-04-28 07:50:45 +00:00
brueffer
b14752021b 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
sjg
62bb106222 Merge from head 2013-09-05 20:18:59 +00:00
wblock
3b474fdbb5 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
wblock
e4c0895368 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
sjg
6d37b86f2b Updated dependencies 2013-03-11 17:21:52 +00:00
sjg
0ee5295509 Updated dependencies 2013-02-16 01:23:54 +00:00
marcel
9dd41e3647 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
rmh
5178ecbf89 Improve error reporting when no cpufreq(4) support is available.
Reviewed by:	njl, acpi
2012-04-09 20:59:14 +00:00
ed
674bf2b68f 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
brucec
680fe863d9 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
mav
0df344c42a 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
ea8a7d9989 then -> than
MFC after:	1 day
2010-03-15 16:06:52 +00:00
imp
6db2453429 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
073cafdd42 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
ed
b9ca89bfc4 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
ff11c95c02 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
nwhitehorn
4feecabff8 Teach powerd how to query the PMU AC line state on PowerPC. 2009-05-31 10:27:24 +00:00
trhodes
bc9f9a22f1 Fix a typo higter->higher.
Spotted by:	ganbold
2008-12-24 09:17:30 +00:00
mav
bb609f07ed Restore original frequency on exit.
PR:		bin/113813
2008-11-18 15:48:23 +00:00
mav
faa047f97d 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
obrien
d2b669d980 Add an abbreviation for adaptive mode, and document all the abreviations. 2008-06-22 17:52:57 +00:00
kevlo
c74ac9adc1 getopt(3) returns -1, not EOF. 2008-02-18 03:19:25 +00:00
marck
d5c48380b2 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
des
2c73974f3f 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
des
733ad39b75 Look for cpu/ichss instead of cpu/p4tcc, which is i386/amd64-only. 2006-02-18 16:01:07 +00:00
des
8fe6e13e40 Load cpufreq at startup if it isn't there already. 2006-02-18 11:35:12 +00:00
des
c5944732d8 Don't use threads when there's no real reason to.
MFC after:	2 weeks
2006-01-03 21:32:02 +00:00
joel
7eed0b9958 s/5.5/6.0/ in HISTORY section.
Discussed with:	ru
2005-11-24 09:25:10 +00:00
ru
8a2652d669 -mdoc sweep. 2005-11-18 10:56:28 +00:00
pjd
59d6dffbb0 Be more consistent with the rest of the manual page. 2005-11-06 20:01:47 +00:00
njl
427aeb138a 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
njl
39560838ba Whitespace fix. 2005-10-23 00:55:56 +00:00
njl
cd579e831a 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
njl
d5e033e83c 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
des
953bbe6a0d Accept "maximum" and "minimum" modes as well as their abbreviations.
MFC after:	2 weeks
2005-09-26 12:16:27 +00:00
pjd
3d2323799f Test last minute changes, as gcc isn't too smart.
Reported by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
2005-08-24 19:42:40 +00:00
pjd
6de559363a Add '-P' option which allows to specify pidfile. 2005-08-24 17:32:41 +00:00