16 ms·
Hardware (peripherals) have state. Reading the hardware state is difficult and sometimes impossible so recreating that state correctly after powering down is ve
by gvb 6y ago
Hardware (peripherals) have state. Reading the hardware state is difficult and sometimes impossible so recreating that state correctly after powering down is very difficult. Then multiply that difficulty across all the different hardware that can be in a PC and it becomes extremely difficult to do on an arbitrary laptop/PC.
Add to that difficulty the fact that many hardware (peripheral) vendors provide incomplete documentation making it difficult or impossible to implement "off-nominal" situations like hardware state reading/writing-restoring.
VMs have an advantage that the peripherals are limited in types and numbers and the state is "virtual" so the state is directly accessible (r/w) in the virtualizing driver software, not buried in physical hardware. When you "hibernate" a VM, no physical device actually powers down and no (buried in hardware) state is lost.
- liquidify 6y agohow does winndows resolve these issues?
- tyingq 6y agoI had to disable "Fast Startup" in Windows because it would make WSL lose its mind. So whatever they are doing, it has issues as well.
- tffgg 6y agoWsl1 wsl2 - No issue with fast startup, sleep or hibernation
- tyingq 6y agoSure, though it's not just me. Plenty of issues in the WSL github repo and results from Google.
- dboreham 6y agoSimilar experience, except there is a time of day drift issue that afflicts docker. It's a single magic powershell command to fix, once you Google the error and find the right SO article.
- danieldk 6y agoHere, the trackpad is broken after fastboot 1/2 times (basically registers button presses all the time, making it unusable). Without fastboot no such issues, plus modern machines boot fast even without fastboot ;).
- jodoherty 6y agoMost hardware device vendors write Windows drivers and test them. Since they built the hardware, the vendor driver developers are privy to all the internals. Windows also has a stable ABI for drivers. Hardware device vendors don't always write or maintain Linux drivers there's no stable driver ABI for binary drivers to be built and distributed for Linux. Instead, vendors are encouraged to write drivers that follow the conventions of the Linux kernel with no hardware abstraction layers and submit them for inclusion in the upstream Linux kernel under the GPLv2. Not every vendor is willing to do that (NVIDIA for example), but some do (AMD, Intel).
- pharmakom 6y agoI’m wondering if a clever solution of presenting the Windows ABI to drivers but translating to Linux calls under the hood would be feasible?
- keanebean86 6y agoAMD tried something similar and the Kernel maintainers rejected the patch. At least that's how I understood it. I think this is a HN post about it: https://news.ycombinator.com/item?id=13142285 https://news.ycombinator.com/item?id=13142285
- voxadam 6y agoSounds a lot like NDISwrapper.[1] God, that was a pain in the ass. [1]https://en.wikipedia.org/wiki/NDISwrapper https://en.wikipedia.org/wiki/NDISwrapper
- Syonyk 6y agoI don't miss that. But it was better than the alternative at the time... "Ok, there are at least three versions of the Linksco WG8211, all with different wireless chipsets. The box is identical except for the UPC sub-label - you want the one ending in -02. Some of the -01 boxes might work, but no guarantees, and the -03 definitely doesn't have support yet. You can't tell by the PCI ID, but if you poke this particular register, you can get the sub-version, which should tell you which chipset they're using - if they haven't changed it again." Wireless cards on Linux, back in the early days of 802.11, were brutal to get working properly, mostly due to lack of drivers. The NDISwrapper was gross and sometimes hard to configure, but it also meant you had a snowball's chance in hell of getting a random wireless adapter working on Linux.
- gvb 6y agoDelegated and distributed responsibility. Windows makes the hardware vendors implement it in the their device drivers, and the "system integrator" (laptop manufacturer) is responsible to verify that it works. The laptop manufactures (a) have a limited and known set of hardware to verify works and (b) have "leverage" (i.e. promises to purchase large quantities of peripherals) to ensure the hardware vendors fix any problems found. Linux drivers don't get much hardware vendor love.
- noen 6y agoIt doesn't, really. Hibernation and even the levels of "sleep" mode have and still have issues in Windows. I have a brand new Dell Precision workstation that still can't properly come back from sleep mode every time.
- MattGaiser 6y agoYep. I have a Surface for work. It just reboots when you tell it to hibernate or even sleep.
- philliphaydon 6y agoI haven’t had any issues with hibernating or sleep on windows with any device I’ve owned. But damn the number of issues I have on linux in 2021 outweighs the amount I’ve had on Windows, ever. Still prefer linux over windows tho.
- vladvasiliu 6y agoHeh, as I've posted above, I've had the reverse. All kinds of weird broken behavior on Windows, everything works perfectly on Linux. And those are mostly highly-integrated, full-intel computers. I have a small HP with a thunderbolt / usb-c port. Thunderbolt kinda sorta works. Sometimes. But even if the display goes to sleep, it's game over. I also have a usb-c monitor. I've only ever seen it work one (1) time in windows. On linux it mostly works. Sometimes it doesn't detect the correct refresh rate for some reason. But in the BIOS it always works. I could actually even install Windows with it. And it sometimes gets to the login page. But once the session launches, it turns off.
- salawat 6y agoYou've never had games that would only start and run without crashing from a clean boot? That's part of where the whole "Have you tried turning it off and back on again?" piece of wisdom comes in. You never know what might have flipped out from under agter a hibernate. When you turn it Off off. You know. Unless...you dual boot linux. I have an Envy 47 something whose wireless still can't get it right. So I just ran an ethernet cable to it. Traced it down to being because Ubuntu wouldn't clean out the hardware registers between hot reboots. It would be fine after a cold shutdown, but once the card got stuck in a bad state, not even a switch to windows could save you. I'd have to pull the plug to get all the registers clear, and start anew. And that was how I learned it's never the hardware until it is.
- 6gvONxR4sf7o 6y agoMy windows think pad has had a super buggy hibernation for a few years. Better than Linux laptops I’ve tried, but still not at all solved. Only my mac seems to get hibernation right.
- aksss 6y agoClosed hardware platform, no coincidence there.
- ghshephard 5y agoI don't believe the latest version of macOS supports Hibernation anymore. At least I couldn't get it working with an hour or two of finagling/googling around.
- ajross 6y agoThey make it the OEM's responsibility. The board integrator tests hibernate, sees that it fails, checks the docs, eventually figures out that it's the driver for (just to invent a random example) their oddball audio codec forgetting to reset the RST_OR_BADSTUFF register on hardware reset, so it starts pushing bad data at the hardware DMA controller which confuses the media stack. The board vendor knows what they put on the board, they have support from the suppliers, etc... So it's a tractable problem for them even if the solutions are often ugly ad hoc hackery. The community has none of that. They need to figure out all this stuff by reverse engineering in most cases. But the point is it's not an "OS" problem. "Windows" doesn't do anything different from Linux. The difference is that if you ship hardware and people only pay for windows, then you only make windows work.
- bbulkow 6y agoAs others have said, essentially by being the single os for a multibillion dollar pc industry for decades. I forget exactly when the hibernate api came online... 90's?... and Microsoft has a porting layer test suite as a manufacturer that you have to pass to get that little windows stamp. All done by paid professionals and spread over the cost of the large number of pcs sold. The hal (hardware abstraction layer) is always a hard problem that takes years to get right. Write the code, write the tests, fix insane little bugs, get market momentum. Once it is solved it kinda runs itself and is a massive moat. (Apple tried this... 95? StarTrek project, os 8?) This collection of issues is why i run windows as a host os and above that run wsl (far better than mac's weird port of bsd + homebrew), local vms, and cloud servers. Unless you want to talk about the difficulty that is high dpi monitors? That has taken 5 years for 'the windows community' to shake out and i don't think linux ever will. Windows is the best solution right now for this very important problem, unless you like fuzzy text fonts. I am not a windows fanboi. Far from it. I have all the ecosystems in my house, and have professionally gone back and forth as the winds have shifted. It is amazing to me that windows has come back, credit vmware, docker, wsl, and microsoft's new openness to being a sensible first stop for developers.
- vladvasiliu 6y agoMeh. For what it's worth, Windows doesn't always do this right either. In my particular case, I have a HP Elitedesk 800 G4 mini (a small form-factor desktop) that sleeps, hibernates, etc perfectly on linux. Worked ever since it was brand new. On windows, for some reason, it randomly turns on at night. I've tried deactivating pretty much all I could, including the option to wake up to install updates (and I usually install the updates fairly quickly anyway). This also happens on an older custom-built PC. Random screen problems (AMD RX card) and / or previously unused USB ports don't work. Everything goes back to normal after a reboot. As this computer doesn't have a TPM, bonus points for the screen turning on bright blue in the middle of the night for bitlocker unlock. Linux sleeps and hibernates perfectly on all my PCs (all some form of HP elitedesk or probook - I haven't tried those on the custom-built PC).
- sigg3 6y agoIn my experience, it doesn't. Hibernation is a hit and miss on Windows too, just less so.
- tinus_hn 6y agoWith Windows 10 shutdown means hibernate so if it’s flakey you’ll crash every time. Also if you don’t implement it or you implement it poorly and you’re not the size of Nvidia your drivers will not pass the checks and will not be signed, so your customers won’t be able to load them.
- _trampeltier 6y agoEven windows has sometimes troubles with it. On work with my HP ZBook and the HP Docking Station I had many, many crashes and bluescreens allways, when I the external monitors felt asleep. Now, no monitors goes blank ever and since then everything works fine.
- m463 6y agoPay people to fix these i-hate-my-life bugs. I've seen companies run shelves full of sleep-wake machines. sleeping and waking. sleeping and... yawn... waking.
- cesarb 6y agoAnd besides all that, hibernate is fundamentally more complex than sleep. With sleep, when waking up the computer resumes directly to the already loaded operating system in RAM, and the operating system "only" has to restore all the hardware state. With hibernate, the computer does a clean boot of a fresh copy of the operating system, which has to initialize all hardware, read the hibernation image, de-initialize (quiesce and/or power off) all hardware, and finally jump to the copy of the operating system found in the hibernation image, which only then will restore all hardware state.
- salawat 6y agoOn top of that. All that state is written to disk, and if someone else goes romping through where you've written your hibernate state to, you get a corrupted state to restore to.
- Izkata 6y agoSpeaking of disk, on a laptop where hibernate did work, I once ended up with more disk space available than there was in total, because it was mounted through the hibernate and I was using it from another OS. Lucky a reboot fixed that bit of weirdness.
- rcxdude 6y agoAlso the amount of stuff the firmware does nowadays, especially on a laptop, is quite high. The OS-UEFI interface is quite complex and involves a fair amount of firmware code which keeps running after boot. This code is heavily involved in operations like suspend and hibernate, and is usually developed by the laptop OEM themselves, so quality is not very high and they have little incentive to test with anything other that windows. This results in a tendency towards fragility (even with windows), as well as worse battery life under linux.
- addicted 6y agoI think the non server Linux community needs a reference device. Basically, you develop against that device, and it's upto hardware manufacturers to try and match the reference device to make their laptops/desktops compatible. If you could get a couple of distro owners such as Red Hat, Ubuntu, Arch, etc. to agree upon such a device it would go a long way to resolving a lot of the issues that the desktop community faces. Disclaimer: I have no expertise in this on either the hardware or software end so this idea might be completely nonsensical for all I know.
- Kalium 6y agoThat's a good idea! What do you think would convince hardware vendors to match a reference device?
- dylan604 6y agoA large number of sales of said device. That's pretty much what drives any manufacturer.
- kortilla 6y agoIn consumer space it’s probably 1 sale for every 100 Windows. If you’re constrained on engineering resources guess which one you won’t care about ?
- zaat 6y ago1 to 100 in the consumer space seems to me extremely optimistic, not sure if I'm betting that it's a 2 or 3 orders of magnitude miss.
- yissp 6y agoI know it's not representative of the consumer space as a whole, but Linux users apparently make up about 1% of the Steam userbase fwiw https://www.phoronix.com/scan.php?page=news_item&px=Steam-Linux-May-2020 https://www.phoronix.com/scan.php?page=news_item&px=Steam-Li...
- test6554 6y agoWhy not create a low-level hardware state interface layer that linux uses to save/restore hardware state. The attitude could be "it's not linux's job to fix your hardware" At first nothing would use it and it would be basically useless, but eventually manufacturers would add support. In the meantime, Another layer on top of this low layer could be created to make older hardware compatible. For hardware that is worth the effort, people could write drivers or other things that could bridge the gap between hardware and the low-level interface.
- chousuke 6y agoThe problem with that is that it doesn't work. People will buy the cheap broken hardware and then complain that Linux doesn't work. That's basically how it is already. I'm pretty certain ACPI is supposed to be at least one part of such a "hardware state layer" already, but as far as I know broken implementations are more common than functional ones.
- njibhu 6y agoThis wouldn't be a silver bullet, many hardware have their own controllers, with their own firmware and their own state that the kernel cannot directly control. And for the same type of hardware some might have a full reset with a power cycle, and other might not. For some reference you can look at the GPU reset bug for navi 10 and below.
- ironmagma 6y agoWhen does restoring state become a necessity as opposed to just disconnecting the devices upon hibernate and reconnecting them afresh when the device wakes up?
- bboreham 6y agoIf there is a running process using that device before/after hibernate, it needs to know it should re-configure it. There is currently no way to pass this information to a Linux process, and quite a task to add the feature to all existing programs.
- ironmagma 6y agoRight, that seems more tractable than trying to restore the actual state of the device though which sounds like a different problem.
- whatever1 6y agoHave no clue from hardware, but why we cannot take a full memory snapshot to the hard disk and then just load it back bit to bit ?
- H8crilA 6y agoThe "memory", or more like "relevant state" is spread across lots of hardware pieces. It's not just RAM. Saving all RAM blocks is indeed easy. Consider the RAM of the graphics card as an example, it can have lots of complicated structures stored by the running programs.
- saltedonion 6y agoCan’t this also be said about windows. How do they solve this problem ?
- deleted 6y ago[deleted]
- m463 6y agoI remember things like getting initialized by at boot cleanly vs coming back from sleep and having to remember the no-boot-state setup. It's like savegames - I think it's hard and bug-ridden so some folks just add checkpoints and don't bother with complex restores in the middle of the bossfight with rockets in the air.