by maverwa · 1y ago · 0 comments
IMHO that’s a giant issue. If you can’t hibernate (aka suspend to disk) you will never be able to get that power consumption low. And telling people to not run secure boot or lockdown is not really a good answer either. Especially since the default installer already sets those things up. I get that „Linux on laptops“ is not a priority big enough to get a proper fix for that. And that it’s not an easy issue to fix. But the current state is really really sad.
PC as a laptop platform is a complete joke.
For example, for my home lab, I bought a used Intel 12th gen industrial PC from a specialized Taiwanese embedded systems company, whose BIOS allows very granular control of all sleep states plus individual power control of most peripherals, probably because that's a must-have for customers in that space over stuff like benchmark scores and bang for the buck.
So technically, IT IS possible to do, just probably not very cost effective for consumer devices.
On Windows, network connectivity in S0 standby is optional: https://www.tenforums.com/tutorials/146593-enable-disable-ne...
>Which means it's impossible to turn off the CPU during suspend. it's always on.
Hibernation is still an option, if you don't mind a slower resume.
The real problem is that both AMD and Intel S0 implementations are mediocre at best and this is what they should fix. Also most vendors are dickheads and cannot even verify that their system even goes to S0ix states without any problem before releasing it. Because of their laziness you can buy brand new certified "Linux ready" machine which won't even achieve S0ix states out of the box.
I can't blame Framework, of course. Upstart laptop manufacturer that is open about repair vs tech giant who's spent years optimizing hardware and batteries.
All that said, I'm optimistic for better batteries, better suspend software/hardware support, and more efficient mobile processors outside of the Apple ecosystem in the coming years. The M-series Apple processors are definitely kicking others in the industry into gear.
We used to have better suspend before, when s3 was thing, on both Linux and windows. Maybe not as great as Macs, but way better than the current shitshow. Now I’m not saying pcs are great hardware, but I think this particular issue should be pinned on Microsoft, who tried to copy apple’s power nap, only doing it halfassedly as they usually do.
The MacBook is an existence proof that there is something they can do.
So, I guess Framework could start designing their own CPUs. I think having more competition in this area would be great!
Not sure how realistic this is, though.
It is as if the features are implemented by completely different people. But this is not obviously the case since systemd supports both and actively improving both.
Note for me hibernation is a security measure and not about saving battery. I am traveling sometimes with the laptop and risk of theft is non-trivial. If it is hibernated, then it is just a property loss. But with just suspend there is a chance that the data can be extracted. So I configured it to hibernate automatically after 15 minutes in suspension. Surprisingly it has been working reliably with Linux.
The solution I found involves making a custom initramfs to support hibernation and compiling the kernel into a signed EFI stub.
So its not a direct "linux prevents hibernate on secure boot", its "linux recommends kernel_lockdown when secure booting", "kernel_lockdown prevents hibernate with unencrypted swap" and "theres no well to make the kernel believe the hibernation disk is encrypted", but the result is the same.
You can "just" run secure boot without lockdown. Its a cmdline, you can just omit it. You can run custom patch sets that add cmdline options so the kernel allows hibernation in lockdown (if you pinky-promise the swap is encrypted).
But neither of these are easily accessible to the average user.
1: https://manpages.debian.org/bullseye/manpages/kernel_lockdow...
A UKI is a kernel+initramfs+boot-arguments bundle all as a single WinPE/UEFI executable using the "EFI Stub Loader".
You configure your system firmware to execute it, passing no arguments. It boots using the command line you set earlier. It's signed, and verified by the platform secure boot.
Hibernation works fine with this approach.
To dual-boot, I boot from a removable USB drive on my keychain. When it's not plugged in, it boots windows instead.
This is almost definitely true considering it’s an massive open source project
I expect many of the servers I have deployed, again consumer grade SSDs, would have more writes in a day than you in a year -- even with several suspends a day.
I cannot of course address the specific model you have, or the size of RAM you're suspending to swap space.
1: https://www.phoronix.com/news/AMD-ACPI-C4-Linux-Kernel-Code
I authored a patch (I still use it to this day, and I think others do too) that allows this, and sent it to the LKML as an RFC, and was rejected, for some background.
Proceeds to continue enforcing objectively worse solution (evidenced by the existence of this entire thread).
I’m torn between my instinct to classify anything from DHH as mostly hype, my faith in Linux kernel developers, and my cynicism toward Linux kernel developers.
Small enthusiast distributions with a bit of a hype can gain good features in by just pulling in knowledgable users missing things from their previous distro - and they can move a lot faster than the Debians or Fedoras of the world can, no committee decisions to be made first.
Setting that up is pure hell on Linux, with poor documentation and security people actively fighting against making this easy.
On Windows/macOS it just works, on Linux you'll probably break secure boot with it.
The way it works on my Windows laptop is it’ll stay in sleep overnight, then when I open the laptop in the morning it’ll wake up, then hibernate itself, then I have to wait for the computer to turn itself back on. Thankfully this feature can be turned off.
Luckily for me, I usually run Linux on this laptop which sleeps just fine.
The solution is to disable Wake Timers.
BIOS support for proper hibernation has been getting worse too because with MSFT demanding it, there is little reason to continue support.
I've had older laptops that do the sleep->hibernate setup without too much issue but now it is a crap-shoot on if it is even supported in the hardware.
You can disable that behavior. See: https://www.tenforums.com/tutorials/146593-enable-disable-ne...
All laptops support that though it's not always enabled as a feature by default.
For example, HP's enterprise lines have S3 stubs in their firmware. If you enable them, nothing happens, because someone deliberately removed the S3 blobs entirely.
AllowHybridSleep=true
Your Linux installer will also set everything up needed for it.
It's also a GUI option in KDE's System Settings.
In most cases your kernel will tell you it's "locked down" and refuse to hibernate. In my case - on a cutting edge kernel no less with Fedora - it refused to believe that the default disk encryption setup with Swap on encrypted LVM actually is encrypted and locked me out.
Linux security bros followed Apple and others here and refused to add any ability for us to configure or tell kernel that it's wrong about that and to fscking allow resume.
This stuff just works out of the box on both macOS and even the mess that is Windows.
It will do it eventually, though if you don't have enough free disk space it'll fail.
> Pretty much exactly 19 years ago I got on a train to Oxford and made Mark Shuttleworth's laptop successfully suspend and resume using ACPI and that was the turning point in my entire career [1]
[1] https://nondeterministic.computer/@mjg59/111249766634985812
10 years after that I bought a Macbook Air, and haven't gone back to Linux on a laptop since.
While I can understand random Joe and Jane are at the mercy of reverse engineering while installing a Linux distro over the weekend, I expect that anyone selling Linux laptops as OEM, to actually get the specifications and have everything working as any other hardware vendor.
It does not make any sense to write 32 or 64G data to secondary memory every time you close your laptop lid, that will accelerate the lifespan of most SSDs.
Does Mac hibernate? Because if it does, the wake up is literally under 100ms, it's just imperceptible. You open the lid and it's already awake.
Not by default. If you just shut the lid on your macbook and put it in your backpack for 2 days, it does not hibernate.
Which is why waking is instant.
Apple calls it "Safe Sleep" (https://support.apple.com/en-gb/guide/mac-help/mh10328/mac) and you get a progress bar when it wakes from it. Yes, even on magical Ms.
I'm not sure if that's possible on windows. I know my work laptop doesn't work that way, but then, it probably runs all sorts of enterprise settings.
This is cope. An Apple Silicon Macbook does not need to suspend to block devices to save energy (they only do this when the battery is empty). ChromeOS doesn't offer hibernate at all. The only reason that a Framework can't have good battery life in an operating state is that nobody is paying attention to the details.
And to be sure, I do not claim that there is nothing to gain in s2idle. I bet theres still a lot of headroom to safe energy. Its just that it would be easy to safe a lot of power if s2disk "just worked".
The issue is that Modern Standby goes ones step further and keeps the CPU and peripherals in low power states instead of just the memory. This will use more power than S3 sleep by default, and each SoC will need deep integration with the kernel for that to ever be power efficient. That means it will require heavy investment from AMD and Intel to enable efficient Modern Standby in Linux, along with heavy vendor investment to ensure each model they sell implements Modern Standby efficiently.
It isn't a matter of Framework dropping the ball, it's matter of hardware platforms being shitty and platform owners not investing as much resources into Linux as they do Windows.
If you're claiming it is just an oversight, then please back it up.
1%/h is just 0.5W (for a 50Wh battery) which isn't a lot, but fail to bring a component or two to shutdown or sufficiently low power state and you'll observe exactly this behaviour. Of course some drain is going to be almost inevitable just to keep memory contents sufficiently refreshed, but with proper power-saving states memory can go appreciably below 0.5W.
It's not a single oversight, it's a massive project that needs to be carried out throughout an operating system. Linux's usual advantage of decentralization and wide distro variety with massive customization potential is a disadvantage here. To have a power-efficient system you need all of the software to be working toward the same goal. One bad actor process can completely hose the system's power efficiency.
How so? You need each thing to do its part, but that decentralizes perfectly well because it isn't actually integration at all, it's just a hundred different pieces each doing it right.
And open source has the further advantage that you're not beholden to the maintainer. If Framework notices that piece #37 is wasting power, they have the code and can fix it themselves. If the upstream isn't completely asleep at the switch they'll accept the patch, and even if they are you can still ship it on your own device.
Where this can get messed up is in one of two ways. The first is if something is not open source and then the vendor fails to fix it but also fails to supply anyone else with the capacity to fix it. But this isn't a problem with integration, it's a problem with filthy knuckleheads not keeping their heads on straight and calls for some new competitors to show them how to do it.
The second is something like an actual trade off, e.g. if you want the machine to be able to wake via network packet or pressing a key on the keyboard then you'd need the network controller or USB controller to stay in a low power state instead of being dead off. And then that might cost you half a watt, but you're paying it in order to get something, and then somebody has to decide if Linux users would typically want a default where that feature works or one where the battery can last a month in standby, since it's one or the other.
These are important things, but they do not matter for power consumption in sleep, when the CPU is not executing instructions.
I don't daily drive an MBP anymore, only occasionally. But I had one for a week or so, and once or twice I've noticed that my backlit keyboard still had its lights on, which is unusual when the computer sleeps. The screen was dark, though, so it can be confusing.
You're already relying on the hardware platform for Secure Boot, it's not far fetched to apply the same view to hibernate if the platform protects memory and disk.
That said, S3 is still a viable option, and IMO, the best option. Some hardware vendors still implement S3 sleep for their Linux laptops.
Why do you need hibernation? Apple gets the ultra low power without suspending to disk?
I don't know what you're talking about, is this an apple Silcon marketing ploy? my linux laptops lose less battery in suspend than my macbooks do powered down
You might be okay with it, but I suspect most consumers today won’t be.
I go _months_ without rebooting/proper shut downs. And this is on a MacOS install that I've migrated from one Macbook to another for 5 macbooks now O.O
The issue is that firmware vendors disable S3 sleep in favor of s0ix/Modern Standby instead, which just puts hardware into low power states instead of stopping them entirely. This will inherently drain more power over time than just keeping memory powered in S3 sleep.
Modern Standby requires heavy integration with the OS to be power efficient. Turns out that takes a lot of reverse engineering because vendors will not release documentation or tune the kernel for their firmware.
And I often use my laptop for things where seconds matter. I've got things on the stove that could burn, I may not have 5 seconds to spare locating the next step in the recipe.
That said, I worked the same way many years ago, with browser tabs and desktop sessions that were precious and I didn't want to drop them. But what I ended up realizing was that the stress of losing that state due to random power failures or software bugs was too much. I found it far better for my sanity and actual productivity to instead make sure I had a sane note taking system, where I could track what was actually important to me.
It was a great relief to my mental state and general stress to allow myself to shut down all processes and start clean every day.
It's just a huge waste of time to get it all back. I see it no different than being in the middle of a heavy coding/mental task and being interrupted to the point that you have to 'start over' in the sense of getting all that context back in the right places.
Sure, I _could_ neatly close everything out and have a pristine perfect work/desktop environment. But, personally, when I see the work/desk environment of someone and it's absolutely pristine all I can think about is how they're spending energy to maintain that.
To give another example - in my workshop (woodworking), if I'm in the middle of something and need to take a break/leave the shop... I'm not putting _anything_ away. I turn off the lights and walk out. That way when I return I don't have to set everything back up. Now - when I finish something, then I go through and clean up and organize and get the state freshened up. Same thing with my laptop/computer.
Zero anxiety about it all - it's not about losing anything but time. And that's what's most important.