Power consumption increased with kernel 3.2.5
The new kernel 3.2.5 supposedly fixed the old power regression introduced in 2.6.39 (or so). On my T60 laptop (Core 2 Duo) not only that the power consumption stayed high, but the pcie_aspm=force option passed to the kernel is not working anymore. The result: my laptop consumes 20W on idle (I use KDE, kmail and firefox on with 2 tabs open). That's 25% more than what I had with the older 3.2.4 kernel and pcie_aspm=force enabled.
powertop2 does not show anything unusual, the CPU is basically idle on the lowest available frequency 98% of the time (I'm using the ondemand governor).
Did you guys experience something similar or is it just me?
If you don't use Skype then I'd delete it.
PIM services is a bit high. I'd remove each of your accounts under Settings >Accounts. Then reboot the device. Monitor the PIM services battery drain for a while with no accounts added and see how it goes. Then add each account back, one at a time, and monitor for a couple hours to see the PIM services usage. It should be a bit high for the first hour while information syncs to the device then it should settle down. Once you're satisfied the account is working OK you can add the next account. Find the one that keeps the PIM services drainage high.
If the device doesn't show 4G, then what does it show?
Similar Messages
-
Since I have upgraded from 7.1 then the power consumption increased slightly unbelievable. I have new batteries in my iphone 5 and when I had at ios 7 so was consumption that allows the battery envelope in two days and with ios 7.1 so is it only 12 hours before I need to recharge the battery.
Wrote a little wrong the first time!
Then I upgraded to 7.1 so have power consumption increased slightly unbelievable. I have new batteries in my iphone 5 and when I had at ios 7 so was consumption that allows the battery envelope in two days and with ios 7.1 so is it only 12 hours before I need to recharge the battery. -
[SOLVED] Speed increase with kernel compilation?
I'm planning on compiling my own kernel, to optimise as much as possible.
As a first step, I am planning on compiling the stock arch kernel from ABS, with the compiler flags for my CPU (core 2 duo), i686.
Am I likely to notice any kind of performance boost at all doing this, compared to what I assume is a standard compile to basic i686 instruction set in the arch repos?
Last edited by chrispoole (2009-04-08 17:13:07)chrispoole wrote:...Am I likely to notice any kind of performance boost at all doing this, compared to what I assume is a standard compile to basic i686 instruction set in the arch repos?
No...but there's no harm in ricing, so go for it. -
Airport Express Power Consumption
Hi guys.
I'm thinking about buying the Airport Express since I'm in need of a new router. My current router (Netgear N150) can't reach my bedroom with a decent signal though my apartment is only 50 kvm.
As I went to go through the specs of the Airport Express I couldn't find a simple answer to the power consumption. With help from Google on how to turn the given information into something useful I figured out that:
220V * 0,2A = 44 watts
44 watts / 1000 = 0,044 kWh
0,044 kWh * 24 = 1,056 kWh a day.
1,056 * 365 = 385,44 kWh a year.
It seems crazy since I've read that most other routers only use about 8-10 watts.
The reason why I used 220V is because I'm from Denmark. Here our power outlet runs 220-240 V.
With these numbers my annual cost for the Airport Express alone would be: DKK 770 or $141.
My question is:
Does it really use this much power? Or is the numbers sort of based on a constant, massive use?
I really hope you could give me some numbers - especially if you'r from Denmark - that would tell me if this is true.
Thanks guys.Hi,
The technical specifications (http://www.apple.com/airport-express/specs/) confirm the 0.2 A input current. However, an AirPort Express Environmental Report (http://images.apple.com/environment/reports/docs/AirPortExpress_PER_feb2014.pdf) mentions 2.1/2.2 W (idle/active) power at 230 V, which would correspond to a substantially lower current.
I do not know the reason for this difference. A guess could possibly be that the 0.2 A is some kind of temporary/peak value.
The following discussion could perhaps also be of some interest in this context.
https://discussions.apple.com/thread/5101912
Jan -
+5W power consumption when playing audio on X201 with Linux
Hi folks!
My Thinkpad X201’s power consumption raises from ~10W to ~15W when playing any kind of audio under linux. This problem does not seem to be CPU-related (for example when streaming with pulseaudio over ethernet instead of playing directly on the X201 the power consumption does hardly increase) and does not occur under Windows. I’m using Fedora x86_64 16 with Kernel v3.2.1 but it also occured with a v3.2.1 vanilla kernel; Fedora 14 and 15; Ubuntu 11.10 and 12.04 and so on.
I’ve allready posted my problem several months ago here: http://forum.thinkpads.com/viewtopic.php?f=9&t=99246 but haven’t gotten any useful answers.
I measured power consumption with powertop but also confirmed with readings from /sys:
while true; do bc -l <<< "$(cat /sys/class/power_supply/BAT0/current_now)/10^6*$(cat /sys/class/power_supply/BAT0/voltage_now)/10^6"; sleep 1; done
The output of lspci -vvv:
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 06)
Subsystem: Lenovo Device 215e
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin B routed to IRQ 43
Region 0: Memory at f2520000 (64-bit, non-prefetchable) [size=16K]
Capabilities: [50] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000fee0f00c Data: 41c1
Capabilities: [70] Express (v1) Root Complex Integrated Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- RBE- FLReset+
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #0, Speed unknown, Width x0, ASPM unknown, Latency L0 <64ns, L1 <1us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed unknown, Width x0, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=01
Status: NegoPending- InProgress-
VC1: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=1 ArbSelect=Fixed TC/VC=02
Status: NegoPending- InProgress-
Capabilities: [130 v1] Root Complex Link
Desc: PortNumber=0f ComponentID=00 EltType=Config
Link0: Desc: TargetPort=00 TargetComponent=00 AssocRCRB- LinkType=MemMapped LinkValid+
Addr: 00000000fed1c000
Kernel driver in use: snd_hda_intel
Kernel modules: snd-hda-intel
cat /proc/asound/card0/codec#0:
Codec: Conexant CX20585
Address: 0
AFG Function Id: 0x1 (unsol 1)
Vendor Id: 0x14f15069
Subsystem Id: 0x17aa2155
Revision Id: 0x100302
No Modem Function Group found
Default PCM:
rates [0x160]: 44100 48000 96000
bits [0xe]: 16 20 24
formats [0x1]: PCM
Default Amp-In caps: N/A
Default Amp-Out caps: N/A
GPIO: io=4, o=0, i=0, unsolicited=1, wake=0
IO[0]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
IO[1]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
IO[2]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
IO[3]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
Node 0x10 [Audio Output] wcaps 0xc1d: Stereo Amp-Out R/L
Control: name="Master Playback Volume", index=0, device=0
ControlAmp: chs=3, dir=Out, idx=0, ofs=0
Device: name="CONEXANT Analog", type="Audio", device=0
Amp-Out caps: ofs=0x4a, nsteps=0x4a, stepsize=0x03, mute=1
Amp-Out vals: [0x3b 0x3b]
Converter: stream=8, channel=0
PCM:
rates [0x560]: 44100 48000 96000 192000
bits [0xe]: 16 20 24
formats [0x1]: PCM
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x11 [Audio Output] wcaps 0xc1d: Stereo Amp-Out R/L
Amp-Out caps: ofs=0x4a, nsteps=0x4a, stepsize=0x03, mute=1
Amp-Out vals: [0x3c 0x3c]
Converter: stream=0, channel=0
PCM:
rates [0x560]: 44100 48000 96000 192000
bits [0xe]: 16 20 24
formats [0x1]: PCM
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x12 [Audio Output] wcaps 0x611: Stereo Digital
Converter: stream=0, channel=0
Digital:
Digital category: 0x0
PCM:
rates [0x160]: 44100 48000 96000
bits [0xe]: 16 20 24
formats [0x5]: PCM AC3
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x13 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out
Control: name="Beep Playback Volume", index=0, device=0
ControlAmp: chs=1, dir=Out, idx=0, ofs=0
Control: name="Beep Playback Switch", index=0, device=0
ControlAmp: chs=1, dir=Out, idx=0, ofs=0
Amp-Out caps: ofs=0x07, nsteps=0x07, stepsize=0x0f, mute=0
Amp-Out vals: [0x00]
Node 0x14 [Audio Input] wcaps 0x100d1b: Stereo Amp-In R/L
Device: name="CONEXANT Analog", type="Audio", device=0
Amp-In caps: ofs=0x4a, nsteps=0x50, stepsize=0x03, mute=1
Amp-In vals: [0x81 0x81] [0x80 0x80] [0x81 0x81] [0x80 0x80]
Converter: stream=0, channel=0
SDI-Select: 0
PCM:
rates [0x160]: 44100 48000 96000
bits [0xe]: 16 20 24
formats [0x1]: PCM
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 4
0x17 0x18 0x23* 0x24
Node 0x15 [Audio Input] wcaps 0x100d1b: Stereo Amp-In R/L
Amp-In caps: ofs=0x4a, nsteps=0x50, stepsize=0x03, mute=1
Amp-In vals: [0x4a 0x4a] [0x4a 0x4a] [0x4a 0x4a] [0x4a 0x4a]
Converter: stream=0, channel=0
SDI-Select: 0
PCM:
rates [0x160]: 44100 48000 96000
bits [0xe]: 16 20 24
formats [0x1]: PCM
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 4
0x17* 0x18 0x23 0x24
Node 0x16 [Audio Input] wcaps 0x100d1b: Stereo Amp-In R/L
Amp-In caps: ofs=0x4a, nsteps=0x50, stepsize=0x03, mute=1
Amp-In vals: [0x4a 0x4a] [0x4a 0x4a] [0x4a 0x4a] [0x4a 0x4a]
Converter: stream=0, channel=0
SDI-Select: 0
PCM:
rates [0x160]: 44100 48000 96000
bits [0xe]: 16 20 24
formats [0x1]: PCM
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 4
0x17* 0x18 0x23 0x24
Node 0x17 [Audio Selector] wcaps 0x30050d: Stereo Amp-Out
Amp-Out caps: ofs=0x00, nsteps=0x04, stepsize=0x27, mute=0
Amp-Out vals: [0x02 0x02]
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 4
0x1a 0x1b* 0x1d 0x1e
Node 0x18 [Audio Selector] wcaps 0x30050d: Stereo Amp-Out
Amp-Out caps: ofs=0x00, nsteps=0x04, stepsize=0x27, mute=0
Amp-Out vals: [0x00 0x00]
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 4
0x1a* 0x1b 0x1d 0x1e
Node 0x19 [Pin Complex] wcaps 0x400581: Stereo
Pincap 0x0000001c: OUT HP Detect
Pin Default 0x042140f0: [Jack] HP Out at Ext Right
Conn = 1/8, Color = Green
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x00:
Unsolicited: tag=37, enabled=1
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 2
0x10* 0x11
Node 0x1a [Pin Complex] wcaps 0x400481: Stereo
Pincap 0x00001324: IN Detect
Vref caps: HIZ 50 80
Pin Default 0x61a190f0: [N/A] Mic at Sep Rear
Conn = 1/8, Color = Pink
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x00: VREF_HIZ
Unsolicited: tag=38, enabled=1
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x1b [Pin Complex] wcaps 0x400581: Stereo
Pincap 0x00011334: IN OUT EAPD Detect
Vref caps: HIZ 50 80
EAPD 0x2: EAPD
Pin Default 0x04a190f0: [Jack] Mic at Ext Right
Conn = 1/8, Color = Pink
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x00: VREF_HIZ
Unsolicited: tag=38, enabled=1
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 2
0x10* 0x11
Node 0x1c [Pin Complex] wcaps 0x400581: Stereo
Pincap 0x00000014: OUT Detect
Pin Default 0x612140f0: [N/A] HP Out at Sep Rear
Conn = 1/8, Color = Green
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x40: OUT
Unsolicited: tag=37, enabled=1
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 2
0x10* 0x11
Node 0x1d [Pin Complex] wcaps 0x400581: Stereo
Pincap 0x00010034: IN OUT EAPD Detect
EAPD 0x2: EAPD
Pin Default 0x601700f0: [N/A] Speaker at Sep N/A
Conn = Analog, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x20: IN
Unsolicited: tag=00, enabled=0
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 2
0x10* 0x11
Node 0x1e [Pin Complex] wcaps 0x400481: Stereo
Pincap 0x00000024: IN Detect
Pin Default 0x40f001f0: [N/A] Other at Ext N/A
Conn = Unknown, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x20: IN
Unsolicited: tag=00, enabled=0
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x1f [Pin Complex] wcaps 0x400501: Stereo
Pincap 0x00000010: OUT
Pin Default 0x901701f0: [Fixed] Speaker at Int N/A
Conn = Analog, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x40: OUT
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 2
0x10* 0x11
Node 0x20 [Pin Complex] wcaps 0x400781: Stereo Digital
Pincap 0x00000010: OUT
Pin Default 0x40f001f0: [N/A] Other at Ext N/A
Conn = Unknown, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x40: OUT
Unsolicited: tag=00, enabled=0
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 1
0x12
Node 0x21 [Audio Output] wcaps 0x611: Stereo Digital
Converter: stream=0, channel=0
Digital:
Digital category: 0x0
PCM:
rates [0x160]: 44100 48000 96000
bits [0xe]: 16 20 24
formats [0x5]: PCM AC3
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x22 [Pin Complex] wcaps 0x400781: Stereo Digital
Pincap 0x00000010: OUT
Pin Default 0x40f001f0: [N/A] Other at Ext N/A
Conn = Unknown, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x40: OUT
Unsolicited: tag=00, enabled=0
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 1
0x21
Node 0x23 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x04, stepsize=0x2f, mute=0
Amp-In vals: [0x02 0x02]
Pincap 0x00000020: IN
Pin Default 0x90a601f0: [Fixed] Mic at Int N/A
Conn = Digital, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x20: IN
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Node 0x24 [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x4a, nsteps=0x4a, stepsize=0x03, mute=1
Amp-In vals: [0x00 0x00] [0x00 0x00]
Power states: D0 D1 D2 D3 D3cold
Power: setting=D0, actual=D0
Connection: 2
0x10 0x11
Node 0x25 [Vendor Defined Widget] wcaps 0xf00000: Mono
Is anyone able to confirm this problem or does anyone have a solution? I’m really desperate since I often use my Thinkpad as a big but wonderful portable music player (with headphones of course! Don’t want to annoy my fellow trainpassengers …).
Thanks in advance
MichaelAny updates on this?
-
[SOLVED] Huge power consumption after kernel upgrade.
Dear All,
I have recently bought the new lenovo thinkpad X1 equipped with a Core I5 processors and 4GB of RAM.
I am quite satisfied with this machine except for the fact that the fan is extremely loud (but perhaps a bios upgrade will fix problem).
Now my problem:
When I first installed Arch (first days of August) I ran powertop and the power consumption was around 10 Watts when idle with wifi card turned off.
Now, after some upgrades, the power consumption raises to 18W in idle and consequently the battery lasts less than 2h.
Here my current configuration:
Linux think-x1 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 08:53:25 CEST 2011 x86_64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz GenuineIntel GNU/Linux
and here the powertop output obtained with the cpu frequency governor set to "On demand":
Cn Avg residency P-states (frequencies)
C0 (cpu running) ( 5.3%) Turbo Mode 0.1%
polling 0.0ms ( 0.0%) 2.50 Ghz 0.0%
C1 mwait 0.2ms ( 0.1%) 2.21 Ghz 0.0%
C2 mwait 0.3ms ( 0.0%) 1200 Mhz 0.1%
C3 mwait 2.4ms ( 0.0%) 800 Mhz 99.8%
C4 mwait 13.1ms (94.6%)
Wakeups-from-idle per second : 76.1 interval: 3.0s
Power usage (ACPI estimate): 15.7W (2.8 hours)
Top causes for wakeups:
46.5% (135.7) kworker/0:0
17.7% ( 51.7) PS/2 keyboard/mouse/touchpad interrupt
11.9% ( 34.7) [kernel scheduler] Load balancing tick
8.6% ( 25.0) [iwlagn] <interrupt>
2.9% ( 8.3) [i915] <interrupt>
2.6% ( 7.7) [acpi] <interrupt>
1.8% ( 5.3) chromium
1.6% ( 4.7) [kernel core] hrtimer_start (tick_sched_timer)
1.5% ( 4.3) kworker/0:1
0.7% ( 2.0) minilogd
0.7% ( 2.0) [kernel core] iwl_bg_watchdog (iwl_bg_watchdog)
0.6% ( 1.7) X
0.6% ( 1.7) [kernel core] intel_gpu_idle_timer (intel_gpu_idle_timer)
0.3% ( 1.0) Terminal
0.3% ( 1.0) [kernel core] tpt_trig_timer (tpt_trig_timer)
0.2% ( 0.7) [mmc0, mei, ehci_hcd:usb3] <interrupt>
0.2% ( 0.7) upowerd
0.1% ( 0.3) init
0.1% ( 0.3) gpg-agent
0.1% ( 0.3) [kernel core] ieee80211_sta_reset_conn_monitor (ieee80211_sta_conn_mon_timer)
0.1% ( 0.3) wicd-client
0.1% ( 0.3) kworker/u:3
0.1% ( 0.3) watchdog/0
I have also tried to disable most of the running daemons and unload some modules, but I have never got less than 14/15W when idle, which in my opinion is definitely too much!
As far as I'm concerned, the kworker process is responsible most of the wakeups.
Any ideas?
Last edited by jacopo_c (2011-09-05 13:12:16)pogeymanz wrote:I read somewhere that the kernel devs really don't see this as an issue. They just expect that laptop owners should know to try these boot parameters. So, definitely not by 3.1.
from https://bugzilla.redhat.com/show_bug.cgi?id=727579:
Dave Jones 2011-08-03 15:32:21 EDT
enabling it by default in 3.0 caused regressions for some people, so it was
disabled. Hopefully Intel figures it out, and we can switch it back on by
default in 3.1 / 2.6.41 (until then, you'll have to set it by hand).
Interesting stuff, also recommend this thread on phoronix:
http://phoronix.com/forums/showthread.p … Regression
Last edited by masteryod (2011-09-12 00:30:00) -
Thinkwatt: record power consumption and visualize it with gnuplot
https://github.com/mikar/thinkwatt wrote:
Thinkwatt is a bash script for use with thinkpad laptops. However, as of v0.2, it works with all kinds of laptops as long as they've got a battery attached.
Thinkwatt can
* record your power consumption,
* calculate an average of that consumption
* and visualize that data in a 2D gnuplot graphic.
options:
-r, --record record power consumption and optionally create a graph from the gathered data
-p, --plot create a plot image from a specified data file
-a, --average calculate the average power consumption from a specified data file
-q, --quiet makes thinkwatt less chatty
-o, --output the output file. can be prepended by a path.
-h, --help show this help text
examples:
thinkwatt -r (will record to a temp file until cancelled)
thinkwatt -r 300 -o /foo/bar/consumption.dat (will record for 5 minutes to the specified file)
thinkwatt -p /foo/bar/consumption.dat (will create a graph from the specified file)
Thinkwatt works with all laptops, not just Thinkpads.
If you're running thinkwatt on a Thinkpad it is still recommended to use tp_smapi as it provides more accurate results than the generic acpi.
This is an example of what the graph can look like:
It's mainly useful for retracing power consumption during certain situations (e.g. measuring the influence of certain hardware or software (kernel comes to mind), or simply reliably gather typical power consumption for certain activity profiles like surfing, working, watching movies etc.)
I guess I'll add to the script when and if time and my bash skills allow it. Suggestions for improvement are always welcome.
You can get thinkwatt from my git repository here or the AUR here.
Regards,
demian
Last edited by demian (2011-05-28 21:10:30)akurei@joel: ~ $ LANG=C thinkwatt -r 60 /home/akurei/test
recording power consumption for the next 60 seconds
/usr/bin/thinkwatt: line 100: /tmp/thinkwatt/28606.dat: No such file or directory
mv: cannot stat `/tmp/thinkwatt/28606.dat': No such file or directory
error: file not found.
average consumption during the last 60 seconds was W
do you want to create a graphic now, too? y/n y
error: file not found.
akurei@joel: ~ $ LANG=C thinkwatt -r 60
recording power consumption for the next 60 seconds
/usr/bin/thinkwatt: line 100: /tmp/thinkwatt/29019.dat: No such file or directory
error: file not found.
average consumption during the last 60 seconds was W
do you want to create a graphic now, too? y/n y
error: file not found.
akurei@joel: ~ $ yaourt -Qi gnuplot
Name : gnuplot
Version : 4.4.3-1
URL : http://www.gnuplot.info
Licenses : custom
Groups : None
Provides : None
Depends On : readline gd wxgtk cairo libjpeg lua
Optional Deps : None
Required By : None
Conflicts With : None
Replaces : None
Installed Size : 3016.00 K
Packager : Ronald van Haren <[email protected]>
Architecture : x86_64
Build Date : Fri May 6 10:55:29 2011
Install Date : Mon May 16 17:04:26 2011
Install Reason : Explicitly installed
Install Script : Yes
Description : Plotting package which outputs to X11, PostScript, PNG, GIF, and others
akurei@joel: ~ $ yaourt -Qi tp_smapi
Name : tp_smapi
Version : 0.40-5
URL : http://tpctl.sourceforge.net/
Licenses : GPL
Groups : None
Provides : None
Depends On : mkinitcpio>=0.6.8 module-init-tools>=3.12-2
Optional Deps : None
Required By : None
Conflicts With : None
Replaces : None
Installed Size : 220.00 K
Packager : Michael Duell <[email protected]>
Architecture : x86_64
Build Date : Mon May 16 17:03:41 2011
Install Date : Mon May 16 17:03:50 2011
Install Reason : Explicitly installed
Install Script : Yes
Description : Modules for ThinkPad's SMAPI functionality
akurei@joel: ~ $ yaourt -Qi gawk
Name : gawk
Version : 3.1.8-2
URL : http://www.gnu.org/directory/GNU/gawk.html
Licenses : GPL
Groups : base
Provides : awk
Depends On : sh glibc
Optional Deps : None
Required By : autoconf syslog-ng sysvinit thinkwatt
Conflicts With : None
Replaces : None
Installed Size : 2224.00 K
Packager : St
Architecture : x86_64
Build Date : Sat Nov 20 04:00:45 2010
Install Date : Thu May 5 19:05:55 2011
Install Reason : Explicitly installed
Install Script : Yes
Description : Gnu version of awk
akurei@joel: ~ $ yaourt -Qi sed
Name : sed
Version : 4.2.1-3
URL : http://www.gnu.org/software/sed
Licenses : GPL3
Groups : base
Provides : None
Depends On : acl sh
Optional Deps : None
Required By : ca-certificates fakeroot grub mkinitcpio packer thinkwatt
Conflicts With : None
Replaces : None
Installed Size : 804.00 K
Packager : St
Architecture : x86_64
Build Date : Fri Nov 19 22:35:32 2010
Install Date : Thu May 5 19:05:55 2011
Install Reason : Explicitly installed
Install Script : Yes
Description : GNU stream editor
akurei@joel: ~ $ lsmod|grep tp_smapi
tp_smapi 20043 0
thinkpad_ec 4085 2 hdaps,tp_smapi
Last edited by akurei (2011-05-16 15:36:40) -
[Request] cryogenic kernel module to reduce power consumption
Hi there,
I found a very interesting kernel module to reduce power consumption. It is called cryogenic:
Cryogenic is a Linux kernel module that allows to reduce energy consumption by means of enabling cooperative clustering of I/O operations among the various applications that make use of the same hardware device. In order to achieve this target, Cryogenic provides an API that enables applications to schedule I/O operations on SCSI and network devices at times where the impact the operations have on energy consumption is small.
https://gnunet.org/cryogenic
Is someone interested in packaging this for the AUR?
Thanks!What part of that document led you to think it would automagically reduce power consumption without application support?
I saw that document (and it is the same as your first post... 106 pages..meh), all points me to (still) think that applications have to explicitely support cryogenic to take advantage from it, is pretty clear:
Page 28
In this section we present the way developers should use Cryoge nic’s API in order to
benefit from its capabilities . We illustrate with examples the code that must be added to modify the behaviour of any application and give a clearer idea of the execution flow .
Did you read that document, yes?
Last edited by kokoko3k (2014-03-29 16:04:11) -
I am writting to ask for help with my old version MacBook Pro early 2008 with Kernel Panic 9C2028 10.5.2 Darwin 9.2.1. My MacBook Pro freezes up with a panic and have to shut it down by pressing and holding the power button. When I restard the comp it keep showing the same Kernel Panic. Will any body outthere heppe me get out this freezes up panic kernel Darwin 9.2.1.
Thanks YouLooks like a RAM failure or maybe another hardware failure.
Can you take out the battery and with the charger connected start up? Same failure?
Have you tried the SMC reset and PRAM reset? do both twice. -
Customized kernel for reducing laptop power consumption
Do there exist any custom kernels that reduce power consumption, possible even geared towards laptop (e.g. 2nd gen sandybridge) users?
For instance if one uses the stock kernel vs. linux-ck, etc... are there any drastic differences in power consumption, or are most of these custom kernels geared towards performance improvements?I know you were looking for a customized kernel that reduces power consumption but have you looked at https://wiki.archlinux.org/index.php/Laptop_Mode_Tools ?
-
Power consumption with 5 Cisco CISCO AP1131G etc.
Hello everyone
I need to calculate our Cisco's network equipment's total max power consumption to choose UPS model.
We have following equipments in house.
CISCO 1941 integrated service router with WIC-1T-Use serial interface card (it says max 110w)
CISCO ASA5505 Firewall (it says max 96w)
Linksys slm224p unknown Wattage with 5 Cisco access Point AP1131G (18w each) connected through PoE ports
There is spec sheet of slm224P which doesn't specify it's own power consumption. (attached PDF)
On rear panel of SLM224p it says 3A, if this is his consumption being connected to 220v power line, it might consume 660W
but it seems too much for a single switch without PoE ?
Any idea or comments would be appreciated.
Best Regards
tomoakiHere's some links:
Overview:
http://www.cisco.com/en/US/prod/collateral/wireless/ps5679/ps8368/product_data_sheet0900aecd8066a16c.html
Installation:
http://www.cisco.com/en/US/docs/wireless/access_point/1520/installation/guide/1520_ch1.html
The following document says 25 Watts typical (~2 amps @ 12VDC) with a Max of 50 Watts (~4 amps @ 12 VDC)
(Quote)
Q. What is the power draw from the Cisco Aironet 1520 Series?
A. The power draw varies with the type of options specified with the Cisco Aironet 1520 Series. Typical power draw is less than 25 watts. Maximum power draw can be up to 50 watts.
(End Quote)
From here:
http://www.cisco.com/en/US/prod/collateral/wireless/ps5679/ps8368/prod_qas0900aecd8066a17b_ns756_Networking_Solutions_Q_and_A.html
Good Luck
Scott -
Power consumption with dual power supply
Hi,
I need to know how dual power supply works, I mean, when you have two power supplies in a router if both of them are working at the same time, or if one of them is working while the other one only begin to work when the first one stops.
And if both of them are working at the same time, what is the power consumption, the same as if only one of them was working?
Thanksmarianares0001 wrote:Hi,I need to know how dual power supply works, I mean, when you have two power supplies in a router if both of them are working at the same time, or if one of them is working while the other one only begin to work when the first one stops.And if both of them are working at the same time, what is the power consumption, the same as if only one of them was working?Thanks
The implementation details can potentially differ per product category but usually the following is applicable:
The product provides configurable power redundancy modes and choosing a mode dictates whether load will be shared across supplies or whether a particular supply will be dedicated for redundancy.
If both (or more) supplies are working at the same time then both share the power load.
The actual power consumption depends on the power required to run the installed components and is the same whether you use power supplies in redundant or power sharing mode.
Atif -
I915 power consumption issue after switch to systemd?
After switching to systemd I noticed a massive increase of power consumption on my Thinkpad X220 (i5 Sandy Bridge).
The strange thing is, that after some reboots it randomly seems to catch the i915 power saving mode and the consumption gets from ~24W to ~7W at idle. But only after several reboots.
Adding the good old i915.i915_enable_rc6=1 to the boot parameters doesn't make any differences. But looking at the powertop detail outputs it seems to be a i915 issue.
Using the latest linux kernel from core (3.6.4) and latest intel drivers (2.20.12).I started to get suspicious because I have only ever had the issue in my office. Last week, when I encrypted my drive, my machine wrote to disk for more than 14 hours solid. I then did all the set up and all the restoring from backup etc. with no issue whatsoever. Lenovo ran the thing for 48 hours straight with no problem. But once in my office...
So I asked the local IT people if they could think of anything other than overheating and explained the issue. They took my laptop yesterday , booted it from a hardware testing CD and ran it for a couple of hours sitting on top of a hot computer in the server room which is definitely hot. (It has a whole bunch of computers, I guess.) No issue. They then ran stress tests for a while in the same place. No problem. Highest recorded temp: 65C.
The head of IT then took my power adapter to a more general IT service to be tested and inspected. They looked at it, they opened the plug to check the fuse, they tested it. No problem. Of course, the guy also explained why he was asking and the other IT person said, "Oh, is that on level 1?" "Yes..." So apparently there was another machine (a Mac), I think, doing just the same thing in an office in my part of the building. Testing showed that the power spikes and when the power spikes, the laptop shut down as a safety measure. Solution: they installed a UPS for that one laptop. They didn't tell anybody else, including the local IT people.
What the local IT people were going to do was to install equipment to monitor the power in my office and see if anything weird was causing my laptop to react. However, that was when this was an extremely-unlikely-but-we-are-getting-desperate-for-theories scenario. Clearly, that theory no longer seems wildly implausible at all. So the current hypothesis is that it is most likely that my machine is also reacting to the spikes in power by shutting itself off. (I'm not sure why it should have just started doing this but who knows what the state of the electricals is and how that might vary?)
I have been told that a surge protector will do no good. (They've given me one anyway but apparently it will not deal with spikes in phase 3 power or something - I didn't understand this bit but the head IT person said he didn't understand it either but the electricals IT person showed him with graphs on the whiteboard. So it must be true.)
The current plan is to try to get the UPS from central IT which was provided for the other laptop since that person's discipline has since moved to another floor of the building so the UPS probably went back to central IT. They are going to ask during a meeting tomorrow about this possibility. Otherwise, they are planning to order a UPS for me on Monday.
I'm somewhat surprised that the abrupt shutdowns haven't screwed my data. I've lost work but not seen fs corruption. I didn't take my laptop today. I'll need it next week but I do not plan to plug it in in my office until I have a UPS.
I'm pretty annoyed, to be honest. I've wasted hours on this and got incredibly stressed about it. The IT people have also wasted a (smaller) amount of time. I hoped to have a new draft of an article I'm working on written by the end of reading week but that didn't happen due to all of this. And they *knew*. It would be different if this was an unknown problem just discovered - of course, one could understand that. But there's a known problem which can cause this type of problem and presumably could well damage equipment without these sorts of safety shutdown features and they don't tell anybody.
And, no, I doubt very much indeed that a damaged personal machine would be considered the institution's liability. (Maybe if it was a student's machine and the student was required to use it or something but even then...)
I can't believe it does much good to their equipment either.
The local IT people did know there was an issue with some burnt out devices but that was about eight years ago and only got mentioned as a outside possibility when other diagnostics turned up no result.
What gets me is that the proposed solution will only solve the issue for me - not for anybody else in my part of the building on level 1. -
Laptop mode tools problem with kernel 3.0
today I just updated the system and my laptop runs dramatically hotter after that. I read the archwiki, it does talk about the laptop mode tools problem with kernel 3.0 but when I opened the file /usr/sbin/laptop_mode, the lines which the wiki mentions are not there. Does anyone here have the same problem and can you offer the solution?
Here is my /usr/sbin/laptop_mode
#! /bin/sh
# Script to start or stop laptop_mode, and to control various settings of the
# kernel, hardware etc. that influence power consumption.
# This script is a part of Laptop Mode Tools. If you are running a supported
# power management daemon, this script will be automatically called on power
# state change.
# Configure laptop mode tools in /etc/laptop-mode/laptop-mode.conf, and in
# the broken-out config files in /etc/laptop-mode/conf.d.
# Please consult the manual pages laptop-mode.conf(8) and laptop_mode(8) for
# additional information.
# Maintainer: Ritesh Raj Sarraf ([email protected])
# Original Author: Bart Samwel ([email protected])
# Project home page: http://samwel.tk/laptop_mode
# Contributors to this script: Bart Samwel
# Kiko Piris
# Micha Feigin
# Andrew Morton
# Herve Eychenne
# Dax Kelson
# Jan Polacek
# ... and many others that I've stopped
# keeping track of.
# Based on a script for Linux 2.4 written by Jens Axboe.
set -a
# The laptop mode tools version number. Extracted by the installer makefile
# as well, so don't change the format!
LMTVERSION=1.59
# This script is loaded from multiple scripts to set the config defaults
# and to read the configuration on top of those. Only when the command is
# recognized does this script do anything else.
VERBOSE_OUTPUT=0
ENABLE_LAPTOP_MODE_ON_BATTERY=1
ENABLE_LAPTOP_MODE_ON_AC=0
ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0
PARTITIONS="auto /dev/mapper/*"
LM_BATT_MAX_LOST_WORK_SECONDS=600
LM_AC_MAX_LOST_WORK_SECONDS=360
DEF_MAX_AGE=30
LM_READAHEAD=3072
NOLM_READAHEAD=128
CONTROL_READAHEAD=1
CONTROL_NOATIME=0
USE_RELATIME=1
CONTROL_HD_IDLE_TIMEOUT=1
LM_AC_HD_IDLE_TIMEOUT=4 # 20 seconds
LM_BATT_HD_IDLE_TIMEOUT=4 # 20 seconds
NOLM_HD_IDLE_TIMEOUT=244 # 2 hours
DEF_UPDATE=5
DEF_XFS_AGE_BUFFER=15
DEF_XFS_SYNC_INTERVAL=30
DEF_XFS_BUFD_INTERVAL=1
XFS_HZ=100
CONTROL_MOUNT_OPTIONS=1
BATT_HD_POWERMGMT=1
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=254
CONTROL_HD_POWERMGMT=0
CONTROL_HD_WRITECACHE=0
NOLM_AC_HD_WRITECACHE=1
NOLM_BATT_HD_WRITECACHE=0
LM_HD_WRITECACHE=0
LM_DIRTY_RATIO=60
LM_DIRTY_BACKGROUND_RATIO=1
NOLM_DIRTY_BACKGROUND_RATIO=10
NOLM_DIRTY_RATIO=40
LM_SECONDS_BEFORE_SYNC=2
BATT_CPU_MAXFREQ=medium
BATT_CPU_MINFREQ=slowest
BATT_CPU_GOVERNOR=ondemand
BATT_CPU_IGNORE_NICE_LOAD=1
LM_AC_CPU_MAXFREQ=fastest
LM_AC_CPU_MINFREQ=slowest
LM_AC_CPU_GOVERNOR=ondemand
LM_AC_CPU_IGNORE_NICE_LOAD=1
NOLM_AC_CPU_MAXFREQ=fastest
NOLM_AC_CPU_MINFREQ=slowest
NOLM_AC_CPU_GOVERNOR=ondemand
NOLM_AC_CPU_IGNORE_NICE_LOAD=0
CONTROL_CPU_FREQUENCY=0
HD="/dev/[hs]d[abcdefgh]"
CONTROL_SYSLOG_CONF=0
LM_AC_SYSLOG_CONF=/etc/syslog-on-ac-with-lm.conf
NOLM_AC_SYSLOG_CONF=/etc/syslog-on-ac-without-lm.conf
BATT_SYSLOG_CONF=/etc/syslog-on-battery.conf
SYSLOG_CONF_SIGNAL_PROGRAM=syslogd
SYSLOG_CONF=/etc/syslog.conf
CONTROL_DPMS_STANDBY=0
BATT_DPMS_STANDBY=300
LM_AC_DPMS_STANDBY=1200
NOLM_AC_DPMS_STANDBY=1200
CONTROL_CPU_THROTTLING=0
BATT_CPU_THROTTLING=medium
LM_AC_CPU_THROTTLING=minimum
NOLM_AC_CPU_THROTTLING=minimum
CONTROL_START_STOP=1
CONTROL_TERMINAL=0
TERMINALS="/dev/vc/1 /dev/vcs1"
BATT_TERMINAL_BLANK_MINUTES=1
BATT_TERMINAL_POWERDOWN_MINUTES=2
LM_AC_TERMINAL_BLANK_MINUTES=10
LM_AC_TERMINAL_POWERDOWN_MINUTES=10
NOLM_AC_TERMINAL_BLANK_MINUTES=10
NOLM_AC_TERMINAL_POWERDOWN_MINUTES=50
ENABLE_AUTO_HIBERNATION=0
HIBERNATE_COMMAND=/usr/sbin/hibernate
AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL=1
DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL=1
AUTO_HIBERNATION_BATTERY_CHARGE_MAH=0
AUTO_HIBERNATION_BATTERY_CHARGE_MWH=0
MINIMUM_BATTERY_CHARGE_MAH=0
MINIMUM_BATTERY_CHARGE_MWH=0
ASSUME_SCSI_IS_SATA=1
CONTROL_BRIGHTNESS=0
BATT_BRIGHTNESS_COMMAND=false
LM_AC_BRIGHTNESS_COMMAND=false
NOLM_AC_BRIGHTNESS_COMMAND=false
LOG_TO_SYSLOG=1
DEBUG=0
ENABLE_LAPTOP_MODE_TOOLS=1
# Initialize the PATH Variable
export PATH="${PATH}":/bin:/sbin:/usr/bin:/usr/sbin
# This is a 2 phase locking approach. LMT_REQ_LOCK is the outer lock and LMT_INVOC_LOCK is the inner lock
# We take this approach to ensure the scenario that, "At any point when an event occurs (AC/BATT), the
# kernel can generate multiple events spanning over a couple of events. The first event is honored and
# lmt executes. If the last event triggered at the 9th second, there is a fair chance that a good amount
# of state change would have occured in the OS, to honor that state, we keep an outer lock (LMT_REQ_LOCK)
# handy, so that those changes can also be applied and not forgotten.
# Workflow:
# Event-1 is generated and lmt executes (lmt runtime could span 5-10 seconds)
# At seventh second, 4 events generate. But Event-1 is still running.
# We don't want to discard all the remaining 4 events, but at least honor 1 so that we can act to the changes
# that occured in the last 7 seconds.
# So, Event-2 acquire LMT_REQ_LOCK and waits to acquire LMT_INVOC_LOCK (which is acquire by Event-1)
LMT_REQ_LOCK="/var/lock/lmt-req.lock"
LMT_INVOC_LOCK="/var/lock/lmt-invoc.lock"
FLOCK=`which flock`
checkint ()
# $1 arg should be the string/integer
# that you want to check for as an integer.
echo $1 | grep "[^0-9]" > /dev/null 2>&1
return $?;
# Returns 1 if it is an integer
# Function to handle logging
LOGGER=`which logger`;
log ()
# $1 should be msg type
# $2 should be the real msg
if [ x$LOG_TO_SYSLOG = x1 ]; then
# NOTE: Add the check on $2 being empty, once you are confident
# that there aren't any bugs in logging. And no bugs in executing
# modules and logging
if [ -x $LOGGER -a "$1" != "STATUS" ]; then
#if [ -z $2 ]; then
# continue
#elif [ "$1" = "MSG" ]; then
if [ "$1" = "MSG" ]; then
logger -p daemon.info -t laptop-mode "$2";
elif [ "$1" = "ERR" ]; then
logger -p daemon.err -t laptop-mode "$2";
elif [ "$1" = "VERBOSE" ]; then
if [ x$VERBOSE_OUTPUT = x1 ]; then
logger -p daemon.debug -t laptop-mode "$2";
fi
else
logger -p daemon.notice -t laptop-mode "$2";
fi
fi
fi
if [ "$1" = "VERBOSE" ]; then
$LM_VERBOSE && echo "$2" >/dev/fd/2;
elif [ "$1" = "ERR" ]; then
echo "$2" >/dev/fd/2;
else
# Message of type MSG and STATUS can go to stdout.
echo "$2" >/dev/fd/1;
fi
enableDebug ()
# Check if debug is enabled
if [ x$(($(basename $1 | cut -d . -f1 | tr "[:lower:]" "[:upper:]" | sed 's/-/_/g')_DEBUG)) = x1 ]; then
set -vx
fi
disableDebug ()
# Check if debug is enabled
if [ x$(($(basename $1 | cut -d . -f1 | tr "[:lower:]" "[:upper:]" | sed 's/-/_/g')_DEBUG)) = x1 ]; then
set +vx
fi
# No default on these ones -- we need to detect if they have been set, for
# backward compatibility with MINIMUM_BATTERY_MINUTES etc.
AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=
MINIMUM_BATTERY_CHARGE_PERCENT=
# Backward compatibility variable that is sometimes
# set externally (Debian init system)
unset VERBOSE
lmt_load_config ()
# Source config. Some config settings have been moved from the main config file
# to modular configuration files, and to support existing laptop-mode.conf
# files from earlier versions, we source the modular configuration files FIRST.
if [ -d /etc/laptop-mode/conf.d ] ; then
for CONF in /etc/laptop-mode/conf.d/*.conf ; do
if [ -r "$CONF" ] ; then
. "$CONF"
#Handle individual module debug settings
if [ "$DEBUG" -eq 1 ]; then
export $(basename $CONF | cut -d . -f1 | tr "[:lower:]" "[:upper:]" | sed 's/-/_/g')_DEBUG=1
log "VERBOSE" "Enabling debug mode for module $CONF"
fi
DEBUG=0
else
log "MSG" "Warning: Configuration file $CONF is not readable, skipping."
fi
done
fi
if [ -r /etc/laptop-mode/laptop-mode.conf ] ; then
. /etc/laptop-mode/laptop-mode.conf
else
log "ERR" "$0: Configuration file /etc/laptop-mode/laptop-mode.conf not present or not readable."
exit 1
fi
if [ x$ENABLE_LAPTOP_MODE_TOOLS = x0 ]; then
log "MSG" "laptop-mode-tools is disabled in config file. Exiting"
exit 0;
fi
# Add a simple bash debug mode switch
if [ "$DEBUG" -eq 1 ]; then
set -vx;
fi
# Support for old config settings
if [ "$AC_HD" != "" ] ; then
AC_HD_WITHOUT_LM="$AC_HD"
AC_HD_WITH_LM="$AC_HD"
fi
if [ "$VERBOSE" != "" ] ; then
VERBOSE_OUTPUT="$VERBOSE"
fi
if [ "$CPU_MAXFREQ" != "" ] ; then
BATT_CPU_MAXFREQ="$CPU_MAXFREQ"
fi
if [ "$MAX_AGE" != "" ] ; then
LM_BATT_MAX_LOST_WORK_SECONDS="$MAX_AGE"
LM_AC_MAX_LOST_WORK_SECONDS="$MAX_AGE"
fi
if [ "$DEF_AGE" != "" ] ; then
DEF_MAX_AGE="$DEF_AGE"
fi
if [ "$LAPTOP_MODE_ALWAYS_ON" != "" ] ; then
ENABLE_LAPTOP_MODE_ALWAYS="$LAPTOP_MODE_ALWAYS_ON"
fi
if [ "$LM_WHEN_LID_CLOSED" != "" ] ; then
ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED="$LM_WHEN_LID_CLOSED"
fi
if [ "$REMOUNT_PARTITIONS" != "" ] ; then
PARTITIONS="$REMOUNT_PARTITIONS"
fi
if [ "$READAHEAD" != "" ] ; then
LM_READAHEAD="$READAHEAD"
fi
if [ "$DO_REMOUNT_NOATIME" != "" ] ; then
CONTROL_NOATIME="$DO_REMOUNT_NOATIME"
fi
if [ "$DO_HD" != "" ] ; then
CONTROL_HD_IDLE_TIMEOUT="$DO_HD"
fi
if [ "$AC_HD_WITH_LM" != "" ] ; then
LM_AC_HD_IDLE_TIMEOUT="$AC_HD_WITH_LM"
fi
if [ "$AC_HD_WITHOUT_LM" != "" ] ; then
NOLM_HD_IDLE_TIMEOUT="$AC_HD_WITHOUT_LM"
fi
if [ "$BATT_HD" != "" ] ; then
LM_BATT_HD_IDLE_TIMEOUT="$BATT_HD"
fi
if [ "$DO_REMOUNTS" != "" ] ; then
CONTROL_MOUNT_OPTIONS="$DO_REMOUNTS"
fi
if [ "$DO_HD_POWERMGMT" != "" ] ; then
CONTROL_HD_POWERMGMT="$DO_HD_POWERMGMT"
fi
if [ "$AC_HDPARM_POWERMGMT_WITH_LM" != "" ] ; then
LM_AC_HD_POWERMGMT="$AC_HDPARM_POWERMGMT_WITH_LM"
fi
if [ "$AC_HDPARM_POWERMGMT_WITHOUT_LM" != "" ] ; then
NOLM_AC_HD_POWERMGMT="$AC_HDPARM_POWERMGMT_WITHOUT_LM"
fi
if [ "$BATT_HDPARM_POWERMGMT" != "" ] ; then
BATT_HD_POWERMGMT="$BATT_HDPARM_POWERMGMT"
fi
if [ "$DO_WRITECACHE" != "" ] ; then
CONTROL_HD_WRITECACHE="$DO_WRITECACHE"
fi
if [ "$AC_WRITECACHE_WITHOUT_LM" != "" ] ; then
NOLM_AC_HD_WRITECACHE="$AC_WRITECACHE_WITHOUT_LM"
fi
if [ "$BATT_WRITECACHE" != "" ] ; then
LM_HD_WRITECACHE="$BATT_WRITECACHE"
fi
if [ "$DIRTY_RATIO" != "" ]; then
LM_DIRTY_RATIO="$DIRTY_RATIO"
fi
if [ "$DIRTY_BACKGROUND_RATIO" != "" ] ; then
LM_DIRTY_BACKGROUND_RATIO="$DIRTY_BACKGROUND_RATIO"
fi
if [ "$DEF_DIRTY_RATIO" != "" ]; then
NOLM_DIRTY_RATIO="$DEF_DIRTY_RATIO"
fi
if [ "$DEF_DIRTY_BACKGROUND_RATIO" != "" ] ; then
NOLM_DIRTY_BACKGROUND_RATIO="$DEF_DIRTY_BACKGROUND_RATIO"
fi
if [ "$DO_CPU" != "" ] ; then
CONTROL_CPU_FREQUENCY="$DO_CPU"
fi
if [ "$CONTROL_CPU_MAXFREQ" != "" ] ; then
CONTROL_CPU_FREQUENCY="$CONTROL_CPU_MAXFREQ"
fi
if [ "$AC_CPU_MAXFREQ_WITH_LM" != "" ] ; then
LM_AC_CPU_MAXFREQ="$AC_CPU_MAXFREQ_WITH_LM"
fi
if [ "$AC_CPU_MAXFREQ_WITHOUT_LM" != "" ] ; then
NOLM_AC_CPU_MAXFREQ="$AC_CPU_MAXFREQ_WITHOUT_LM"
fi
if [ "$DO_SYSLOG" != "" ] ; then
CONTROL_SYSLOG_CONF="$DO_SYSLOG"
fi
if [ "$SYSLOG_SIGNAL_PROGRAM" != "" ] ;then
SYSLOG_CONF_SIGNAL_PROGRAM="$SYSLOG_SIGNAL_PROGRAM"
fi
if [ "$AC_SYSLOG_WITH_LM" != "" ] ; then
LM_AC_SYSLOG_CONF="$AC_SYSLOG_WITH_LM"
fi
if [ "$AC_SYSLOG_WITHOUT_LM" != "" ] ; then
NOLM_AC_SYSLOG_CONF="$AC_SYSLOG_WITHOUT_LM"
fi
if [ "$BATT_SYSLOG" != "" ] ; then
BATT_SYSLOG_CONF="$BATT_SYSLOG"
fi
if [ "$ENABLE_LAPTOP_MODE_ALWAYS" != "" ] ; then
ENABLE_LAPTOP_MODE_ON_AC="$ENABLE_LAPTOP_MODE_ALWAYS"
fi
if [ "$MINIMUM_BATTERY_MINUTES" != "" -a "$MINIMUM_BATTERY_CHARGE_PERCENT" = "" ] ; then
# Use a very conservative estimate (1% = 1 battery minute, 100 minutes in a battery)
# for backward compatibility.
MINIMUM_BATTERY_CHARGE_PERCENT="$MINIMUM_BATTERY_MINUTES"
fi
if [ -z "$MINIMUM_BATTERY_CHARGE_PERCENT" ] ; then
# Apply the default, now that we've determined that this is the minimum.
MINIMUM_BATTERY_CHARGE_PERCENT=3
fi
if [ "$AUTO_HIBERNATION_BATTERY_MINUTES" != "" -a "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" = "" ] ; then
# Use a very conservative estimate (1% = 1 battery minute, 100 minutes in a battery)
# for backward compatibility.
AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT="$AUTO_HIBERNATION_BATTERY_MINUTES"
fi
if [ -z "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" ] ; then
# Apply the default, now that we've determined that this is the minimum.
AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=2
fi
# Postprocessing
if [ "$VERBOSE_OUTPUT" -ne 0 ] ; then
OUTPUT="/dev/stdout"
LM_VERBOSE="[ 1 = 1 ]"
else
OUTPUT="/dev/null"
LM_VERBOSE="[ 1 = 0 ]"
fi
if [ "$PARTITIONS" = "" ] ; then
PARTITIONS="auto /dev/mapper/*"
fi
# Expand shell wild cards immediately.
PARTITIONS=$( echo $PARTITIONS )
TERMINALS=$( echo $TERMINALS )
# Convert seconds to hdparm -S format
# Everything over 20 minutes is interpreted as 2 hours.
seconds_to_hdparm_S() {
if [ "$1" -eq 0 ] ; then
# disable.
echo 0
elif [ "$1" -gt 0 -a "$1" -lt 5 ] ; then
# 5 seconds minimum
echo 1
elif [ "$1" -le $((240*5)) ] ; then
# Values between 1 and 240 signify increments of 5 seconds
echo $(($1 / 5))
elif [ "$1" -lt $((30*60)) ] ; then
# Values between 20 and 30 minutes are rounded up to 30 minutes.
echo 241
elif [ "$1" -lt $((12*30*60)) ] ; then
# Values between 30 minutes and 6 hours (exclusive) yield values between
# 241 and 251, in 30-minute increments.
echo $(( 240 + ($1 / (30*60)) ))
else
# Larger values effectively indicate no timeout at all.
echo 0
fi
# Convert configured idle timeouts to hdparm -S format.
if [ "$LM_AC_HD_IDLE_TIMEOUT_SECONDS" != "" ] ; then
LM_AC_HD_IDLE_TIMEOUT=$(seconds_to_hdparm_S $LM_AC_HD_IDLE_TIMEOUT_SECONDS)
fi
if [ "$LM_BATT_HD_IDLE_TIMEOUT_SECONDS" != "" ] ; then
LM_BATT_HD_IDLE_TIMEOUT=$(seconds_to_hdparm_S $LM_BATT_HD_IDLE_TIMEOUT_SECONDS)
fi
if [ "$NOLM_HD_IDLE_TIMEOUT_SECONDS" != "" ] ; then
NOLM_HD_IDLE_TIMEOUT=$(seconds_to_hdparm_S $NOLM_HD_IDLE_TIMEOUT_SECONDS)
fi
# The main workhorse.
lmt_main_function ()
if [ "$1" = "status" ] ; then
# Display a status report.
log "STATUS" "Mounts:"
mount | sed "s/^/ /"
log "STATUS" " "
log "STATUS" "Drive power status:"
for disk in $HD; do
if [ -r $disk ]; then
hdparm -C $disk 2>/dev/null | sed "s/^/ /"
else
log "STATUS" " Cannot read $disk, permission denied - $0 needs to be run as root"
fi
done
log "STATUS" " "
log "STATUS" "(NOTE: drive settings affected by Laptop Mode cannot be retrieved.)"
log "STATUS" " "
log "STATUS" "Readahead states:"
cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do
# skip funny stuff
case "$FST" in
rootfs|unionfs|tmpfs|squashfs|sysfs|usbfs|proc|devpts) continue
esac
if [ -b $DEV ] ; then
if [ -r $DEV ] ; then
log "STATUS" " $DEV: $((`blockdev --getra $DEV` / 2)) kB"
else
log "STATUS" " Cannot read $DEV, permission denied - $0 needs to be run as root"
fi
fi
done
log "STATUS" " "
if [ -e /var/run/laptop-mode-tools/enabled ] ; then
log "STATUS" "Laptop Mode Tools is allowed to run: /var/run/laptop-mode-tools/enabled exists."
else
log "STATUS" "Laptop Mode Tools is NOT allowed to run: /var/run/laptop-mode-tools/enabled does not exist."
fi
log "STATUS" " "
STATFILES="/proc/sys/vm/laptop_mode /proc/apm /proc/pmu/info /proc/sys/vm/bdflush /proc/sys/vm/dirty_ratio /proc/sys/fs/xfs/age_buffer /proc/sys/fs/xfs/sync_interval /proc/sys/fs/xfs/lm_age_buffer /proc/sys/fs/xfs/lm_sync_interval /proc/sys/vm/pagebuf/lm_flush_age /proc/sys/fs/xfs/xfsbufd_centisecs /proc/sys/fs/xfs/xfssyncd_centisecs /proc/sys/vm/dirty_background_ratio /proc/sys/vm/dirty_expire_centisecs /proc/sys/fs/xfs/age_buffer/centisecs /proc/sys/vm/dirty_writeback_centisecs /sys/devices/system/cpu/*/cpufreq/cpuinfo_*_freq /sys/devices/system/cpu/*/cpufreq/scaling_governor /proc/acpi/button/lid/*/state /proc/acpi/ac_adapter/*/state /proc/acpi/battery/*/state /sys/class/power_supply/*/online /sys/class/power_supply/*/state"
for THISFILE in $STATFILES ; do
if [ -e "$THISFILE" ] ; then
log "STATUS" "$THISFILE:"
if [ -r "$THISFILE" ] ; then
cat "$THISFILE" | sed "s/^/ /"
else
log "STATUS" " Not accessible, permission denied - $0 needs to be run as root."
fi
log "STATUS" " "
fi
done
elif [ "$1" != "readconfig" -a "$1" != "defaults" ] ; then
KLEVEL="$(uname -r |
IFS='.-' read a b c
echo $a.$b
KMINOR="$(uname -r |
IFS='.-' read a b c d
# Strip any stuff from the end -- only the initial digits are part of the KMINOR.
echo $c | sed -e 's/\([[:digit:]]*\).*/\1/'
# Stop exporting everything -- what we do from here is private.
set +a
if [ "$1" = "--version" ] ; then
log "MSG" "Laptop Mode Tools $LMTVERSION"
exit 0
fi
if [ ! -e /proc/sys/vm/laptop_mode ] ; then
log "ERR" "Kernel does not have support for laptop mode. Please apply the laptop mode"
log "ERR" "patch or install a newer kernel."
exit 1
fi
if [ ! -w /proc/sys/vm/laptop_mode ] ; then
log "ERR" "You do not have enough privileges to enable laptop_mode."
exit 1
fi
INIT=0 # Display info in init script format?
FORCE=0 # Force reapplying the current state?
while [ "$1" != "" ] ; do
case "$1" in
init) INIT=1 ;;
force) FORCE=1 ;;
# Old options. We always do "auto" for any option now, but
# we still have to accept the options.
start) ;;
stop) ;;
auto) ;;
modules=*)
MODULES=$1
MODULES=${MODULES#"modules="}
devices=*)
DEVICES=$1
DEVICES=${DEVICES#"devices="}
*) log "ERR" "Unrecognized option $1."
exit 1 ;;
esac
shift
done
mkdir -p /var/run/laptop-mode-tools
# Used to display laptop mode state later on. This is the enabled/disabled
# state for laptop mode processing, it tells us nothing about whether laptop
# mode is actually _active_.
STATE=enabled
if [ "$ENABLE_LAPTOP_MODE_ON_BATTERY" -eq 0 -a "$ENABLE_LAPTOP_MODE_ON_AC" -eq 0 -a "$ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED" -eq 0 ] ; then
STATE=disabled
fi
# Determine the power state.
# First try /sys/class/power_supply/*
FOUND_SYS_CLASS_POWER_SUPPLY_AC=0
ON_AC=0
for POWER_SUPPLY in /sys/class/power_supply/* ; do
if [ -f $POWER_SUPPLY/type ] ; then
if [ "$(cat $POWER_SUPPLY/type)" = "Mains" ] ;then
log "VERBOSE" "Determining power state from $POWER_SUPPLY/online."
FOUND_SYS_CLASS_POWER_SUPPLY_AC=1
if [ "$(cat $POWER_SUPPLY/online)" = 1 ] ; then
ON_AC=1
fi
fi
fi
done
if [ $FOUND_SYS_CLASS_POWER_SUPPLY_AC = 1 ] ; then
# Already found it!
log "VERBOSE" "Not trying other options, already found a power supply."
elif [ -d /proc/acpi/ac_adapter ] ; then
log "VERBOSE" "Determining power state from /proc/acpi/ac_adapter."
ADAPTERS_FOUND=0
ON_AC=0
for ADAPTER in /proc/acpi/ac_adapter/* ; do
if [ -f $ADAPTER/state ] ; then
ADAPTERS_FOUND=1
STATUS=`awk '/^state: / { print $2 }' $ADAPTER/state`
if [ "$STATUS" = "on-line" ] ; then
ON_AC=1
fi
fi
done
if [ "$ADAPTERS_FOUND" -eq 0 ] ; then
ON_AC=1
fi
elif [ -f /proc/pmu/info ] ; then
log "VERBOSE" "Determining power state from /proc/pmu/info."
if ( grep -q "^AC Power.*0$" /proc/pmu/info ) ; then
log "VERBOSE" "/proc/pmu/info indicates absence of AC power."
ON_AC=0
else
# It is possible that there is no AC Power = 1 in the file,
# but we always assume AC power when we're not sure.
ON_AC=1
log "VERBOSE" "/proc/pmu/info indicates presence of AC power."
fi
elif [ -f /proc/apm ] ; then
log "VERBOSE" "Determining power state from /proc/apm."
read D1 D2 D3 APM_AC_STATE D0 </proc/apm
if [ "$APM_AC_STATE" = "0x00" ] ; then
ON_AC=0
else
ON_AC=1
fi
else
log "VERBOSE" "No /sys/class/power_supply, ACPI, APM or PMU power management information found -- assuming AC power is present."
ON_AC=1
fi
# Determine whether to activate or deactivate laptop mode.
ACTIVATE=0
if [ "$ON_AC" -eq 1 ] ; then
if [ "$ENABLE_LAPTOP_MODE_ON_AC" -ne 0 ] ; then
log "VERBOSE" "On AC power: Activating, because ENABLE_LAPTOP_MODE_ON_AC is set."
ACTIVATE=1
else
log "VERBOSE" "On AC power: Deactivating, because ENABLE_LAPTOP_MODE_ON_AC is not set."
ACTIVATE=0
fi
else
if [ "$ENABLE_LAPTOP_MODE_ON_BATTERY" -ne 0 ] ; then
log "VERBOSE" "On battery power: Activating, because ENABLE_LAPTOP_MODE_ON_BATTERY is set."
ACTIVATE=1
else
log "VERBOSE" "On battery power: Deactivating, because ENABLE_LAPTOP_MODE_ON_BATTERY is not set."
ACTIVATE=0
fi
fi
if [ "$ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED" -ne 0 -a "$ACTIVATE" -eq 0 ] ; then
if [ -x "`which hal-find-by-property`" ] ; then
HAL_LID_BUTTON=$(hal-find-by-property --key "button.type" --string "lid")
fi
if [ "$HAL_LID_BUTTON" != "" ] ; then
HAL_LID_BUTTON_STATE=$(hal-get-property --udi $(hal-find-by-property --key "button.type" --string "lid") --key "button.state.value")
if [ "$HAL_LID_BUTTON_STATE" = "true" ] ; then
log "VERBOSE" "Setting action to \"start\" because the lid is closed (says HAL)."
ACTIVATE=1
fi
elif [ -f /proc/acpi/button/lid/*/state ] ; then
if ( grep -q "closed" /proc/acpi/button/lid/*/state ) ; then
log "VERBOSE" 'Setting action to "start" because the lid is closed (says /proc/acpi/button/lid/*/state).'
ACTIVATE=1
fi
else
log "MSG" "Warning: ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED is set, but there is no file"
log "MSG" "/proc/acpi/button/lid/.../state, and hal information is not available either!"
fi
fi
# If the init script has not been run or has been run with the "stop"
# argument, then we should never start laptop mode.
if [ ! -f /var/run/laptop-mode-tools/enabled ] ; then
log "VERBOSE" "Laptop mode disabled because /var/run/laptop-mode-tools/enabled is missing."
STATE=disabled
fi
if [ "$ACTIVATE" -eq 1 -a -f /etc/default/laptop-mode ] ; then
. /etc/default/laptop-mode
if ! ( echo "$ENABLE_LAPTOP_MODE" |grep y ) ; then
log "VERBOSE" "Not starting laptop mode because it is disabled in /etc/default/laptop-mode."
STATE=disabled
fi
fi
if [ "$STATE" = "disabled" ] ; then
ACTIVATE=0
fi
# Check whether we are allowed to activate the data-loss-sensitive stuff.
# If the battery charge is too low, we want to disable this, but not the
# other power-saving stuff.
if [ "$ACTIVATE" -eq 0 ] ; then
ACTIVATE_WITH_POSSIBLE_DATA_LOSS=0
elif [ "$ON_AC" = 1 ] ; then
log "VERBOSE" "On AC, not checking minimum battery charge."
ACTIVATE_WITH_POSSIBLE_DATA_LOSS=1
else
ACTIVATE_WITH_POSSIBLE_DATA_LOSS=1
ENOUGH_CHARGE=0
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=0
# Weird way of checking that /sys/class/power_supply is not empty -- but it works.
if [ "$(echo /sys/class/power_supply/*)" != '/sys/class/power_supply/*' ] ; then
log "VERBOSE" "Not on AC and we have battery information in /sys/class/power_supply/BAT* -- checking minimum battery charge."
for BATT in /sys/class/power_supply/* ; do
BATT_TYPE=$(cat $BATT/type)
log "VERBOSE" "$BATT is of type $BATT_TYPE."
if [ "$BATT_TYPE" != "Battery" ] ; then
log "VERBOSE" "Not of type \"Battery\", skipping."
else
PREV_ENOUGH_CHARGE=$ENOUGH_CHARGE
PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
log "VERBOSE" "Checking levels for $BATT."
PRESENT=$(cat $BATT/present)
log "VERBOSE" "Present: $PRESENT."
# Only do if the battery is present
if [ "$PRESENT" -eq 1 ] ; then
FOUND_AN_ENABLED_CHECK=0
FOUND_AN_ENABLED_HIBERNATION_CHECK=0
# Get the remaining capacity.
IN_UAH=0
IN_UWH=0
if [ -f $BATT/charge_now ] ; then
REMAINING=$(cat $BATT/charge_now)
IN_UAH=1 # charge_* is in microAmpere-hours
elif [ -f $BATT/energy_now ] ; then
REMAINING=$(cat $BATT/energy_now)
IN_UWH=1 # energy_* is in microWatt-hours
else
REMAINING=0
fi
if [ -z "$REMAINING" -o "$REMAINING" -eq 0 ] ; then
log "VERBOSE" "Battery does not report remaining charge. Perhaps it is not present?"
REMAINING=0
fi
log "VERBOSE" "Remaining charge: $REMAINING"
if [ -f $BATT/charge_full_design ] ; then
CAPACITY=$(cat $BATT/charge_full_design)
elif [ -f $BATT/energy_full_design ] ; then
CAPACITY=$(cat $BATT/energy_full_design)
else
CAPACITY=0
fi
if [ -z "$CAPACITY" -o "$CAPACITY" -eq 0 ] ; then
log "VERBOSE" "Battery does not report design full charge, using non-design full charge."
if [ -f $BATT/charge_full ] ; then
CAPACITY=$(cat $BATT/charge_full)
elif [ -f $BATT/energy_full_design ] ; then
CAPACITY=$(cat $BATT/energy_full)
else
CAPACITY=0
fi
if [ -z "$CAPACITY" -o "$CAPACITY" -eq 0 ] ; then
log "VERBOSE" "Battery does not report non-design full charge."
CAPACITY=0
fi
fi
log "VERBOSE" "Full capacity: $CAPACITY"
# Check the charge percentage
if [ "$MINIMUM_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
FOUND_AN_ENABLED_CHECK=1
if [ "$CAPACITY" -eq 0 ] ; then
log "MSG" "WARNING: Battery does not report a capacity. Minimum battery"
log "MSG" "charge checking does not work without a design capacity."
ENOUGH_CHARGE=1
elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$MINIMUM_BATTERY_CHARGE_PERCENT" ] ; then
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
FOUND_AN_ENABLED_HIBERNATION_CHECK=1
if [ "$CAPACITY" -eq 0 ] ; then
log "MSG" "WARNING: Battery does not report a design capacity. Auto hibernation"
log "MSG" "does not work without a design capacity."
ENOUGH_CHARGE=1
elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
# $BATT/alarm is the design_capacity_warning of a battery.
ALARM_LEVEL=$(cat $BATT/alarm)
if [ "$ALARM_LEVEL" -ne 0 ] ; then
if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then
# Restore the state we had before checking this battery, so that
# this battery does not count as having enough charge.
ENOUGH_CHARGE=$PREV_ENOUGH_CHARGE
elif [ "$FOUND_AN_ENABLED_CHECK" -eq 0 ] ; then
# This is the only check that is enabled. In that case a non-critical
# battery level counts as "enough". (If we would count non-critical
# battery levels as enough *always*, then the other settings would
# have no effect; this is only a final fallback.)
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then
if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
elif [ "$FOUND_AN_ENABLED_HIBERNATION_CHECK" -eq 0 ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
# Fallback: hard values
if [ "$IN_UAH" -ne 0 ] ; then
if [ "$MINIMUM_BATTERY_CHARGE_MAH" -ne 0 ] ; then
FOUND_AN_ENABLED_CHECK=1
if [ "$REMAINING" -ge $((1000*"$MINIMUM_BATTERY_CHARGE_MAH")) ] ; then
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MAH" -ne 0 ] ; then
FOUND_AN_ENABLED_HIBERNATION_CHECK=1
if [ "$REMAINING" -ge $((1000*"$AUTO_HIBERNATION_BATTERY_CHARGE_MAH")) ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
elif [ "$IN_UWH" -ne 0 ] ; then
if [ "$MINIMUM_BATTERY_CHARGE_MWH" -ne 0 ] ; then
FOUND_AN_ENABLED_CHECK=1
if [ "$REMAINING" -ge $((1000*"$MINIMUM_BATTERY_CHARGE_MWH")) ] ; then
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MWH" -ne 0 ] ; then
FOUND_AN_ENABLED_HIBERNATION_CHECK=1
if [ "$REMAINING" -ge $((1000*"$AUTO_HIBERNATION_BATTERY_CHARGE_MWH")) ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
else
log "ERR" "Failed to determine battery charge. Battery charge units are not in"
log "ERR" "mWh, uWh, mAh or uAh."
fi
else
log "VERBOSE" "Battery is not present."
fi
fi
done
elif [ "$(echo /proc/acpi/battery/*)" != '/proc/acpi/battery/*' ] ; then
log "VERBOSE" "Not on AC and we have batteries in /proc/acpi/battery -- checking minimum battery charge."
for BATT in /proc/acpi/battery/* ; do
PREV_ENOUGH_CHARGE=$ENOUGH_CHARGE
PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
BATT_STATE=$BATT/state
BATT_INFO=$BATT/info
log "VERBOSE" "Checking info and state for $BATT."
# Only do if the battery is present
if ( grep -q 'present:.*yes' $BATT_INFO ) ; then
FOUND_AN_ENABLED_CHECK=0
FOUND_AN_ENABLED_HIBERNATION_CHECK=0
# Get the remaining capacity.
REMAINING=`grep "remaining capacity:" $BATT_STATE | sed "s/.* \([0-9][0-9]* \).*/\1/" `
if [ -z "$REMAINING" ] ; then
log "VERBOSE" "Battery does not report remaining charte. Perhaps it is not present?"
REMAINING=0
fi
log "VERBOSE" "Remaining charge: $REMAINING"
CAPACITY=`grep "design capacity:" $BATT_INFO | sed "s/.* \([0-9][0-9]* \).*/\1/" `
if [ -z "$CAPACITY" ] ; then
log "VERBOSE" "Battery does not report capacity. Perhaps it is not present?"
CAPACITY=0
fi
log "VERBOSE" "Design capacity: $CAPACITY"
# Check the charge percentage
if [ "$MINIMUM_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
FOUND_AN_ENABLED_CHECK=1
if [ "$CAPACITY" -eq 0 ] ; then
log "MSG" "WARNING: Battery does not report a design capacity. Minimum battery"
log "MSG" "charge checking does not work without a design capacity."
ENOUGH_CHARGE=1
elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$MINIMUM_BATTERY_CHARGE_PERCENT" ] ; then
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
FOUND_AN_ENABLED_HIBERNATION_CHECK=1
if [ "$CAPACITY" -eq 0 ] ; then
log "MSG" "WARNING: Battery does not report a design capacity. Auto hibernation"
log "MSG" "does not work without a design capacity."
ENOUGH_CHARGE=1
elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
# Fallback: hard values.
# Determine the reporting unit.
IN_MAH=0
IN_MWH=0
if ( grep -q mWh $BATT_INFO ) ; then
IN_MWH=1
elif ( grep -q mAh $BATT_INFO ) ; then
IN_MAH=1
fi
if [ "$IN_MAH" -ne 0 ] ; then
if [ "$MINIMUM_BATTERY_CHARGE_MAH" -ne 0 ] ; then
FOUND_AN_ENABLED_CHECK=1
if [ "$REMAINING" -ge "$MINIMUM_BATTERY_CHARGE_MAH" ] ; then
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MAH" -ne 0 ] ; then
FOUND_AN_ENABLED_HIBERNATION_CHECK=1
if [ "$REMAINING" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_MAH" ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
elif [ "$IN_MWH" -ne 0 ] ; then
if [ "$MINIMUM_BATTERY_CHARGE_MWH" -ne 0 ] ; then
FOUND_AN_ENABLED_CHECK=1
if [ "$REMAINING" -ge "$MINIMUM_BATTERY_CHARGE_MWH" ] ; then
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MWH" -ne 0 ] ; then
FOUND_AN_ENABLED_HIBERNATION_CHECK=1
if [ "$REMAINING" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_MWH" ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
else
log "ERR" "Failed to determine battery charge. Battery charge units are not in"
log "ERR" "mWh or mAh."
fi
CAP_STATE=`sed -r 's/^capacity state:\s*(.*)\s*$/\1/;t;d' "$BATT_STATE"`
if [ "$DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then
if [ "$CAP_STATE" = "critical" ] ; then
# Restore the state we had before checking this battery, so that
# this battery does not count as having enough charge.
ENOUGH_CHARGE=$PREV_ENOUGH_CHARGE
elif [ "$FOUND_AN_ENABLED_CHECK" -eq 0 ] ; then
# This is the only check that is enabled. In that case a non-critical
# battery level counts as "enough". (If we would count non-critical
# battery levels as enough *always*, then the other settings would
# have no effect; this is only a final fallback.)
ENOUGH_CHARGE=1
fi
fi
if [ "$AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then
if [ "$CAP_STATE" = "critical" ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
elif [ "$FOUND_AN_ENABLED_HIBERNATION_CHECK" -eq 0 ] ; then
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
fi
fi
else
log "VERBOSE" "Battery is not present."
fi
done
else
ENOUGH_CHARGE=1
ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
log "VERBOSE" "Not on AC and could not check battery state -- data loss sensitive features stay enabled and auto-hibernation will not work."
fi
if [ "$ENABLE_AUTO_HIBERNATION" -ne 0 -a "$ENOUGH_CHARGE_TO_PREVENT_HIBERNATION" -eq 0 ] ; then
log "VERBOSE" "None of the batteries have a charge above the auto-hibernation level."
log "VERBOSE" "Starting hibernation."
if [ -x $HIBERNATE_COMMAND ]; then
$HIBERNATE_COMMAND
elif [ -f /sys/power/state ]; then
grep -q disk /sys/power/state && echo disk > /sys/power/state
fi
# Don't continue -- if things are configured correctly, then we
# will be called on resume.
exit 0
fi
if [ "$ENOUGH_CHARGE" -eq 0 ] ; then
log "VERBOSE" "None of the batteries have a charge above the minimum level."
log "VERBOSE" "Deactivating data loss sensitive features."
ACTIVATE_WITH_POSSIBLE_DATA_LOSS=0
fi
fi
if [ "$INIT" -eq 0 ] ; then
log "MSG" "Laptop mode "
fi
# WAS_ACTIVE is used later on. If there is no /var/run/laptop-mode-tools/state, then
# we know that laptop mode wasn't active before.
WAS_ACTIVE=0
log "VERBOSE" "Checking if desired state is different from current state."
if [ -f /var/run/laptop-mode-tools/state ] ; then
read WAS_ACTIVE WAS_ON_AC WAS_ACTIVATE_WITH_POSSIBLE_DATA_LOSS WAS_STATE < /var/run/laptop-mode-tools/state
if [ "$WAS_STATE" != "" ] ; then
if [ "$WAS_ACTIVE" -eq "$ACTIVATE" -a "$WAS_ON_AC" -eq "$ON_AC" -a "$WAS_ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -a "$WAS_STATE" = "$STATE" -a "$FORCE" -eq 0 ] ; then
log "MSG" "$STATE, "
if [ "$WAS_ACTIVE" -eq 1 ] ; then
log "MSG" "active [unchanged]"
if [ "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq 0 ] ; then
log "MSG" " (Data-loss sensitive features disabled.)"
fi
else
log "MSG" "not active [unchanged]"
fi
exit 0
fi
fi
else
log "VERBOSE" "/var/run/laptop-mode-tools/state does not exist, no previous state."
fi
echo "$ACTIVATE $ON_AC $ACTIVATE_WITH_POSSIBLE_DATA_LOSS $STATE" > /var/run/laptop-mode-tools/state
if [ "$ACTIVATE" -eq 1 ] ; then
log "MSG" "$STATE, active"
if [ "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq 0 ] ; then
log "MSG" " (Data-loss sensitive features disabled.)"
fi
else
log "MSG" "$STATE, not active"
fi
# Finally, call laptop-mode-tools modules. The modules can use the settings
# from the config files, but they may NOT assume the settings actually exist,
# as no defaults have been given for them.
# Note that the /usr/local/lib path is deprecated.
export FORCE STATE ON_AC ACTIVATE ACTIVATE_WITH_POSSIBLE_DATA_LOSS KLEVEL KMINOR WAS_ACTIVE LM_VERBOSE DEVICES
for SCRIPT in /usr/share/laptop-mode-tools/modules/* /usr/local/lib/laptop-mode-tools/modules/* /usr/local/share/laptop-mode-tools/modules/* /etc/laptop-mode/modules/* ; do
if [ -z "$MODULES" ] ; then
# If a module list has not been provided, execute all modules
EXECUTE_SCRIPT=1
else
# If a module list has been provided, execute only the listed
# modules.
EXECUTE_SCRIPT=0
for MODULE in $MODULES; do
# Attempt to remove the module name from the end of the
# full script path. If the module name matches the
# script, the name will be removed from the end of the
# full file path, leaving the path to the script. If
# there was not a match made, the module name would not
# be removed from the path, and $PATH_TO_SCRIPT would
# be the same as $SCRIPT.
PATH_TO_SCRIPT=${SCRIPT%%$MODULE}
# Execute the script if a match was found (module name
# was removed from the script path, making it shorter.
if [ $PATH_TO_SCRIPT != $SCRIPT ] ; then
EXECUTE_SCRIPT=1
fi
done
fi
if [ -x "$SCRIPT" -a $EXECUTE_SCRIPT -eq 1 ] ; then
log "VERBOSE" "Invoking module $SCRIPT."
SCRIPT_DEBUG=$SCRIPT; # We do this because in start-stop-programs module a $SCRIPT variable is used. That
# changes the whole meaning when passed to disableDebug ()
enableDebug $SCRIPT_DEBUG;
. $SCRIPT
disableDebug $SCRIPT_DEBUG;
else
log "VERBOSE" "Module $SCRIPT is not executable or is to be skipped."
fi
done
exit 0
# This fi closes the if for "readconfig". If I would have indented this one
# I would have indented the whole file. :)
fi
lmt_load_config
lock_retry ()
( $FLOCK -n -x -w 1 8 || exit 0;
i=10;
while [ $i -ge 1 ]
do
log "ERR" "Couldn't acquire lock. Retrying.... PID is $$\n"
$FLOCK -x -w 1 9 && lmt_main_function "$@" && break;
i=$(( $i - 1 ))
done
) 8>$LMT_REQ_LOCK
# Check and acquire locks and then exec.
( $FLOCK -n -x -w 1 8; ) 8>$LMT_REQ_LOCK
($FLOCK -n -x -w 1 9 && lmt_main_function "$@";) || lock_retry "$@"
) 9<>$LMT_INVOC_LOCK
# We do a special run of battery polling daemon here so that it does not get
# plagued by the lock. We need the polling daemon to be independent of any locks
if [ x$ENABLE_BATTERY_LEVEL_POLLING = x1 ] && [ x$BLACKLIST_IN_FLOCK = x1 ]; then
log "VERBOSE" "Battery level polling is enabled."
if [ x$ON_AC = x1 ] ; then
log "VERBOSE" "On AC, stopping the polling daemon."
# In AC mode we disable the polling daemon.
killall -q lm-polling-daemon
else
if ! pidof -x lm-polling-daemon ; then
log "VERBOSE" "On battery and there was no polling daemon yet, starting the polling daemon."
# If there is no polling daemon, we start one.
/usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon < /dev/null > /dev/null 2> /dev/null &
fi
fi
else
log "VERBOSE" "Battery level polling is disabled."
fi
exit 0;
and here is the lines which archwiki mentions
case "$KLEVEL" in
"2.4" ) ;;
"2.6" ) ;;
log "ERR" "Unhandled kernel version: $KLEVEL ('uname -r' = '$(uname -r)')" >&2
exit 1
esacI had the problem but edited the line in /usr/sbin/laptop_mode and it worked. But thoes lines are not there anymore. I guess they changed it at the recent update of laptop-mode-tools.
Regarding your heat problem; is there any other thing you use to cut down power usage (from AUR maybe)? I use acpi_call from AUR had to edit lines there aswell, but it should be updated by now. -
2011 MacBook Pro hard drive power consumption
Does anyone know the differences in power consumption between the Apple-supplied 750GB 5400rpm HDD, 500GB 7200rpm HDD, and 256GB SSD drives? I'm currently using a 2011 MacBook Pro with an Apple-supplied 256GB SSD and I'm getting between 5-8 hours of battery life, depending on what I'm doing. I wish it could get closer to a full 10-hour battery life for longer trips, but I realize there's a price for performance. What's the best hard drive option to minimize power consumption? Are there any other tips for increasing battery life? Does it make a difference if you turn off Bluetooth and WiFi when you know you're not going to be able to use them? Thank you in advance for your reply.
Yes, turn Wi-Fi and BT off when not needed. That and your screen are the biggest power consumers. Keep the brightness as low as you can to conserve power.
17" 2.2GHz i7 Quad-Core MacBook Pro 8G RAM 750G HD + OCZ Vertex 3 SSD Boot HD
Maybe you are looking for
-
How to shut down when in Tablet mode
Hi guys out there in Lenovo-land Just got an S10 3T and trying to get used to it. I mainly want to use it as an in-car GPS/communications system, and the best option is to make a framework to fit in the car in Tablet form. The only problem I have so
-
IPhoto book import/templates
I upgraded to Aperture 3 when it was released and upgraded to Snow Leopard at the same time. I now need to reprint a book I created in iPhoto 08 and have just realized this wasn't imported to Aperture. In reading the discussion groups it appears that
-
Multi-Operation problem in Routing (CA01)
Hi, I have a in-house production material, which may need to be manufactured as following 3 operations: operation 10 (opitonal operation) operation 20 (opitonal operation) operation 30 (<b>mandatory</b> operation) Current situation is, if th
-
Print dialog box comes up after 30 sec delay-why?
Hi, I am in Ai CS4. The first file I open, when I go to print it takes just over 30 secs for the print dialog box to come up. The next time I print, no problem, pops up right away. All subsequent file print dialog boxes come up immediately. Quit Illu
-
Change three frames with one hyperlink
Hello, I am new to Java and was wondering if it is possible to refresh more than one frame with one hyperlink. My webpage consists of three frames and I want to change all three frames (for switching from Spanish to English and vica versa). I need a