Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
PBM: Laptop battery drained, not suspending to RAM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5084
Location: Dark side of the mood

PostPosted: Wed Sep 23, 2020 10:11 am    Post subject: PBM: Laptop battery drained, not suspending to RAM Reply with quote

Hi all.

I've recently upgraded Gentoo on my laptop and I read the deprecation notice on pm-utils (along with consolekit), which are required by Xfce. So I removed that package and un-used the pm-utils USE flag wherever it was set. Exit hence xfce-power-manager, can do without, I have Conky — it never made sense to me anyway to require the desktop environment to be active for my laptop to be put into sleep mode when I close the lid.

So I removed consolekit and installed elogind. I did nothing particular, no configuration tweak, just installed the package. I then noticed some error messages from the system logs about missing DBUS UPower components (I can't get my hands on those messages). [I think] Until I installed UPower my laptop didn't go into sleep mode when I closed the lid.

Now I see no error messages in the logs; however the battery gets totally drained overnight in sleep mode while my laptop could stay a couple of days, even a whole week just before I made this upgrade. As a result, it doesn't do a proper shutdown and has to run a filesystem check when I power it on. My battery is only a few months old by the way, less than a year old.

cat /sys/power/state:
freeze mem disk

and
grep -i 'PM: suspend' /var/log/syslog:
Sep 23 10:31:07 <blah> kernel: [ 2040.802901] PM: suspend entry (deep)
Sep 23 10:31:08 <blah> kernel: [ 2044.626408] PM: suspend exit

However I ignore how/where I can check what really happens. As I have some recollection about S[N] states, shall I suspect my laptop goes into S2 state instead of S3? How can I control/verify/change that?

As a side note: I haven't touched the ACPI configuration in years and I've been doing with that since. I might need some refreshing in that matter so thanks for bearing with me.

[EDIT:] From the system logs I suspect my laptop does in fact *not* suspend... What is strange is that I've been checking the power LED and made sure it fades in and out as well as wait for the disk noise to stop, which indicates the beast is in suspend mode. Here is the system log right after I closed the lid yesterday night.
/var/log/syslog:
Sep 22 21:00:26 lappy root: LID: close ()
Sep 22 21:00:47 lappy root: ACPI event unhandled: ac_adapter ACPI0003:00 00000080 00000000
Sep 22 21:00:48 lappy root: ACPI event unhandled: battery PNP0C0A:00 00000080 00000001
Sep 22 21:00:48 lappy root: ACPI event unhandled: battery PNP0C0A:02 00000080 00000000
Sep 22 21:00:48 lappy root: ACPI event unhandled: processor LNXCPU:00 00000081 00000000
Sep 22 21:00:48 lappy root: ACPI event unhandled: processor LNXCPU:01 00000081 00000000
Sep 22 21:00:48 lappy root: ACPI event unhandled: processor LNXCPU:02 00000081 00000000
Sep 22 21:00:48 lappy root: ACPI event unhandled: processor LNXCPU:03 00000081 00000000
Sep 22 21:01:01 lappy CROND[22789]: (root) CMD (run-parts /etc/cron.hourly)
Sep 22 21:03:26 lappy dhcpcd[3491]: wlan0: carrier lost
Sep 22 21:03:26 lappy dhcpcd[3491]: wlan0: deleting address fe80::86a5:c5be:411f:71ce
Sep 22 21:03:26 lappy avahi-daemon[3323]: Withdrawing address record for fe80::86a5:c5be:411f:71ce on wlan0.
...

The text
Quote:
LID: close ()
comes from an ACPI action script I wrote that does nothing else but just that. See how a few minutes later the computer is still active:
/var/log/syslog:
...
Sep 22 21:10:44 lappy avahi-daemon[3323]: Leaving mDNS multicast group on interface wlan0.IPv6 with address fe80::86a5:c5be:411f:71ce.
Sep 22 21:10:44 lappy avahi-daemon[3323]: Interface wlan0.IPv6 no longer relevant for mDNS.
Sep 22 21:10:44 lappy avahi-daemon[3323]: Withdrawing address record for 10.222.8.181 on wlan0.
Sep 22 21:10:44 lappy avahi-daemon[3323]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 10.222.8.181.
Sep 22 21:10:44 lappy dhcpcd[3491]: wlan0: deleting route to 10.222.8.0/24
Sep 22 21:10:44 lappy avahi-daemon[3323]: Interface wlan0.IPv4 no longer relevant for mDNS.
...

Then suddenly it goes hibernating:
/var/log/syslog:
Sep 22 22:54:20 lappy kernel: [35914.109701] PM: hibernation entry
Sep 22 23:14:18 lappy kernel: [35914.806798] Filesystems sync: 0.464 seconds
Sep 22 23:14:18 lappy kernel: [35914.806802] Freezing user space processes ... (elapsed 0.004 seconds) done.
Sep 22 23:14:18 lappy kernel: [35914.811820] OOM killer disabled.
...

It was more than 2 hours after I closed the lid... *and made sure the power LED was dimming in and out!* And why does it take 20 minutes to enter hibernation? I can even see the system saving its state:
/var/log/syslog:
Sep 22 23:14:18 lappy kernel: [35925.683209] PM: Using 3 thread(s) for compression
Sep 22 23:14:18 lappy kernel: [35925.683212] PM: Compressing and saving image data (403159 pages)...
Sep 22 23:14:18 lappy kernel: [35925.683247] PM: Image saving progress:   0%
Sep 22 23:14:18 lappy kernel: [35926.251549] PM: Image saving progress:  10%
Sep 22 23:14:18 lappy kernel: [35926.695999] PM: Image saving progress:  20%
Sep 22 23:14:18 lappy kernel: [35927.612742] PM: Image saving progress:  30%
Sep 22 23:14:18 lappy kernel: [35928.442877] PM: Image saving progress:  40%
Sep 22 23:14:18 lappy kernel: [35929.170864] PM: Image saving progress:  50%
Sep 22 23:14:18 lappy kernel: [35930.024079] PM: Image saving progress:  60%
Sep 22 23:14:18 lappy kernel: [35930.950035] PM: Image saving progress:  70%
Sep 22 23:14:18 lappy kernel: [35931.786455] PM: Image saving progress:  80%
Sep 22 23:14:18 lappy kernel: [35932.524603] PM: Image saving progress:  90%
Sep 22 23:14:18 lappy kernel: [35932.995256] PM: Image saving progress: 100%
Sep 22 23:14:18 lappy kernel: [35933.479591] PM: Image saving done
Sep 22 23:14:18 lappy kernel: [35933.479612] PM: Wrote 1612636 kbytes in 7.79 seconds (207.01 MB/s)
Sep 22 23:14:18 lappy kernel: [35933.480449] PM: S|
Sep 22 23:14:18 lappy kernel: [35933.750281] printk: Suspending console(s) (use no_console_suspend to debug)
Sep 22 23:14:18 lappy kernel: [35933.767460] sd 0:0:0:0: [sda] Synchronizing SCSI cache
Sep 22 23:14:18 lappy kernel: [35933.769267] e1000e: EEE TX LPI TIMER: 00000011
Sep 22 23:14:18 lappy kernel: [35934.000652] sd 0:0:0:0: [sda] Stopping disk
Sep 22 23:14:18 lappy kernel: [35934.610187] ACPI: EC: interrupt blocked
Sep 22 23:14:18 lappy kernel: [35934.644513] ACPI: Preparing to enter system sleep state S3
Sep 22 23:14:18 lappy kernel: [35934.650611] ACPI: EC: event blocked
Sep 22 23:14:18 lappy kernel: [35934.650613] ACPI: EC: EC stopped
Sep 22 23:14:18 lappy kernel: [35934.650614] PM: Saving platform NVS memory
Sep 22 23:14:18 lappy kernel: [35934.650653] Disabling non-boot CPUs ...
Sep 22 23:14:18 lappy kernel: [35934.652430] smpboot: CPU 1 is now offline
Sep 22 23:14:18 lappy kernel: [35934.655003] smpboot: CPU 2 is now offline
Sep 22 23:14:18 lappy kernel: [35934.657739] smpboot: CPU 3 is now offline
...

But then this 8O :
/var/log/syslog:
Sep 22 23:14:18 lappy kernel: [35934.659298] ACPI: Low-level resume complete
Sep 22 23:14:18 lappy kernel: [35934.659375] ACPI: EC: EC started
Sep 22 23:14:18 lappy kernel: [35934.659376] PM: Restoring platform NVS memory
Sep 22 23:14:18 lappy kernel: [35934.661429] Enabling non-boot CPUs ...
Sep 22 23:14:18 lappy kernel: [35934.661508] x86: Booting SMP configuration:
Sep 22 23:14:18 lappy kernel: [35934.661510] smpboot: Booting Node 0 Processor 1 APIC 0x2
Sep 22 23:14:18 lappy kernel: [35934.665935] CPU1 is up
Sep 22 23:14:18 lappy kernel: [35934.665989] smpboot: Booting Node 0 Processor 2 APIC 0x1
Sep 22 23:14:18 lappy kernel: [35934.669219] CPU2 is up
Sep 22 23:14:18 lappy kernel: [35934.669268] smpboot: Booting Node 0 Processor 3 APIC 0x3
Sep 22 23:14:18 lappy kernel: [35934.672381] CPU3 is up
Sep 22 23:14:18 lappy kernel: [35934.673797] ACPI: Waking up from system sleep state S3
Sep 22 23:14:18 lappy kernel: [35934.693458] ACPI: EC: interrupt unblocked
Sep 22 23:14:18 lappy kernel: [35934.733711] ACPI: EC: event unblocked
Sep 22 23:14:18 lappy kernel: [35934.735059] sd 0:0:0:0: [sda] Starting disk
...

... until it dies out of energy:
Code:
Sep 22 23:14:40 lappy dhcpcd[3491]: wlan0: no IPv6 Routers available
Sep 22 23:14:49 lappy kernel: [35968.339628] PM: suspend entry (deep)

why it goes to sleep again is beyond me!

So basically:
  1. the laptop doesn't sleep but stays active
  2. the power LED cycles just as if it were sleeping
  3. it goes into hibernate mode...
  4. and wakes up immediately after...
  5. ... only to go sleeping again but the battery is empty!
What the...? 8O
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!


Last edited by VinzC on Tue Oct 13, 2020 9:48 am; edited 1 time in total
Back to top
View user's profile Send private message
halcon
Apprentice
Apprentice


Joined: 15 Dec 2019
Posts: 289

PostPosted: Fri Oct 02, 2020 8:02 pm    Post subject: Reply with quote

Hi VinzC,

Just a guess... If you're running kernel 5.8+, do you have CONFIG_HIBERNATION_SNAPSHOT_DEV=y?
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5084
Location: Dark side of the mood

PostPosted: Thu Oct 08, 2020 9:13 am    Post subject: Reply with quote

halcon wrote:
Hi VinzC,

Just a guess... If you're running kernel 5.8+, do you have CONFIG_HIBERNATION_SNAPSHOT_DEV=y?

No, I'm running kernel 5.4.60. I have this:

zgrep HIBERNATION /proc/config.gz:
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_HIBERNATION_HEADER=y
CONFIG_HIBERNATION=y

However I fail to see what hibernation has to do with this :? ; can you expand a little? BTW the computer *does* go to sleep most of the time when I close the lid (especially when I'm home). It's only on *one* particular site that it fails to, systematically. Weird.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
halcon
Apprentice
Apprentice


Joined: 15 Dec 2019
Posts: 289

PostPosted: Fri Oct 09, 2020 8:46 am    Post subject: Reply with quote

VinzC wrote:
No, I'm running kernel 5.4.60. I have this:

zgrep HIBERNATION /proc/config.gz:
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_HIBERNATION_HEADER=y
CONFIG_HIBERNATION=y

However I fail to see what hibernation has to do with this :? ; can you expand a little?

Well, I just saw that new symbol in 5.8 and tested that it is necessary for a correct work of pm-suspend-hybrid (despite of it's written that it is used by the uswsusp tools only). It's Y by default, though.
Which exact command do you use for putting the machine to sleep?

VinzC wrote:
BTW the computer *does* go to sleep most of the time when I close the lid (especially when I'm home).

You wrote in the first post: "From the system logs I suspect my laptop does in fact *not* suspend..."
If the problem is not in going to sleep, but in that something wakes the machine up: did you try to disable the network, usb?

VinzC wrote:
It's only on *one* particular site that it fails to, systematically.

Sorry, I don't understand. What do you mean by site?
(Maybe I misread something in your first post, I'm not a native English speaker)
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5084
Location: Dark side of the mood

PostPosted: Tue Oct 13, 2020 9:33 am    Post subject: Reply with quote

VinzC wrote:
BTW the computer *does* go to sleep most of the time when I close the lid (especially when I'm home).

halcon wrote:
You wrote in the first post: "From the system logs I suspect my laptop does in fact *not* suspend..."
If the problem is not in going to sleep, but in that something wakes the machine up: did you try to disable the network, usb?

Investigating a little further from the logs, I later understood (I have to speak in the past because I can no longer manage to be in the conditions this issue occurs) the machine did in fact *not* sleep. I thought it did, only to be immediately brought back to "life"; but I was wrong — false memories, maybe, as to whether I did check the power LED. And no, I didn't disable the network.

But you might have brought a hint to one question I had in mind: can the network prevent the system from suspending?
VinzC wrote:
It's only on *one* particular site that it fails to, systematically.

halcon wrote:
Sorry, I don't understand. What do you mean by site?

:oops: I'm sorry I didn't update this thread with new findings.

I initially believed the issue would occur systematically. It turned out to happen only when I was at a precise location, not my home. By the time wireless network issues also happened at that location, which have been fixed along the way so there are now two reasons I'm no longer able to reproduce this problem, one of which being that I no longer travel to that location.

halcon wrote:
I'm not a native English speaker

No wuckers, neither am I ;-).

halcon wrote:
Which exact command do you use for putting the machine to sleep?

Nothing. It just sleeps when I close the lid. I believe it automatically does thanks to sys-power/upower. I had to run a command before I installed that package but I don't remember which one.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
halcon
Apprentice
Apprentice


Joined: 15 Dec 2019
Posts: 289

PostPosted: Tue Oct 13, 2020 1:48 pm    Post subject: Reply with quote

VinzC wrote:
But you might have brought a hint to one question I had in mind: can the network prevent the system from suspending?

I can't answer this question for sure. I know that that there is Wake-on-LAN. Maybe more experienced people come here to answer.
(I disable the network and all the network services before suspending *anyway*, otherwise after resuming I have some issues with it...)

VinzC wrote:
It turned out to happen only when I was at a precise location

Magic! :)

VinzC wrote:
...I'm no longer able to reproduce this problem, one of which being that I no longer travel to that location.

Is it too far? If it happen to me, I would be interested to *debug* that magic :)

VinzC wrote:
halcon wrote:
Which exact command do you use for putting the machine to sleep?

Nothing. It just sleeps when I close the lid. I believe it automatically does thanks to sys-power/upower. I had to run a command before I installed that package but I don't remember which one.

You could try to run command like
`echo mem > /sys/power/state`
`s2ram`
`pm-suspend` (requires pm-utils?)

https://wiki.gentoo.org/wiki/Suspend_and_hibernate

That could be a first step for writing your own suspend script...
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5084
Location: Dark side of the mood

PostPosted: Tue Oct 13, 2020 2:26 pm    Post subject: Reply with quote

halcon wrote:
VinzC wrote:
But you might have brought a hint to one question I had in mind: can the network prevent the system from suspending?

I can't answer this question for sure. I know that that there is Wake-on-LAN. Maybe more experienced people come here to answer.

I know about wake-on-lan but I don't recall ever enabling it on my laptop — I'll need to double check though. I was instead thinking of some form of side effects as when the network interface keeps requesting an IP address and the DHCP server doesn't respond or thrashes the requests... I might ask Roy Marples after all :idea: .

halcon wrote:
I disable the network and all the network services before suspending *anyway*, otherwise after resuming I have some issues...

Never had to do that in all these years.

VinzC wrote:
...I'm no longer able to reproduce this problem, one of which being that I no longer travel to that location.

halcon wrote:
Is it too far? If it happen to me, I would be interested to *debug* that magic :)

No reason to get there anymore. For an extensive and complete explanation I'd have to expose personal details, which I prefer to keep... personal.

halcon wrote:
You could try to run command like
`echo mem > /sys/power/state`
`s2ram`
`pm-suspend` (requires pm-utils?)

https://wiki.gentoo.org/wiki/Suspend_and_hibernate

That could be a first step for writing your own suspend script...

Well, I didn't say I don't know how to get my computer to sleep however ;-) . Just that I don't remember the command I used back then. Thanks for the tip anyway. It'll come handy to travellers who seek assistance.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
halcon
Apprentice
Apprentice


Joined: 15 Dec 2019
Posts: 289

PostPosted: Tue Oct 13, 2020 3:06 pm    Post subject: Reply with quote

VinzC wrote:
halcon wrote:
I disable the network and all the network services before suspending *anyway*, otherwise after resuming I have some issues...

Never had to do that in all these years.

Even when you suspended performing a work on a network which became unavailable at resuming? Maybe I haven't digged into it properly, and it was easier for me to write a script-disabler...
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5084
Location: Dark side of the mood

PostPosted: Thu Oct 15, 2020 10:14 am    Post subject: Reply with quote

halcon wrote:
VinzC wrote:
halcon wrote:
I disable the network and all the network services before suspending *anyway*, otherwise after resuming I have some issues...

Never had to do that in all these years.

Even when you suspended performing a work on a network which became unavailable at resuming?

Yup. For a couple of years now, the complete net stack is stable and reliable with suspend. Neither wireless nor wired networks do cause issues anymore when moving across locations with different network topologies (at least on my old laptop). Winner-winner, chicken dinner...
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
halcon
Apprentice
Apprentice


Joined: 15 Dec 2019
Posts: 289

PostPosted: Thu Oct 15, 2020 11:44 am    Post subject: Reply with quote

VinzC wrote:
Yup. For a couple of years now, the complete net stack is stable and reliable with suspend. Neither wireless nor wired networks do cause issues anymore when moving across locations with different network topologies (at least on my old laptop).

Good to know! Maybe issues on my laptop are due to that I don't have neither a full DE, nor dbus service running, nor Network Manager... I have a minimalistic system, and have to *bridge gaps* with my own crunches.
(I'm not complaining, it's fun)

VinzC wrote:
Winner-winner, chicken dinner...

:D
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 16011

PostPosted: Thu Oct 15, 2020 3:55 pm    Post subject: Reply with quote

I have had almost fully reliable network with suspend/hibernate as well. I use a minimal system. wpa_supplicant talks to the access point. dhcpcd manages the lease, for both wired and wireless. My only quirk is that the rfkill state gets confused on suspend, so I need to toggle it twice to get wireless working on resume. You would think that I could toggle it zero times and get the same result, but that does not work. Other than that quirk, networking resumes automatically when I come up. Wired Ethernet never needs any help. Wireless just needs me to rfkill twice, and then wpa_supplicant links up to the access point without any specific action from me.
Back to top
View user's profile Send private message
halcon
Apprentice
Apprentice


Joined: 15 Dec 2019
Posts: 289

PostPosted: Thu Oct 15, 2020 9:04 pm    Post subject: Reply with quote

Hu, thank you for the hints about rfkill.

There are also situations, when I don't need to resume networking automatically because the old network is not available, and instead there is a new one with different characteristics. For example, I use dhcpcd for some networks only; I use different firewall settings for different networks; I need also to check files open on network drives for the case if I resume disconnected from them etc. Maybe it all can be achieved in a more consequent way? I am already used to my check-and-disable-everything solution... :?

BTW, I switched from wpa_supplicant to iwd and am happy with it :)
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5084
Location: Dark side of the mood

PostPosted: Sat Oct 24, 2020 9:21 am    Post subject: Reply with quote

halcon wrote:
I have a minimalistic system, and have to *bridge gaps* with my own crunches.
(I'm not complaining, it's fun)

It can be, most definitely :) .
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum