linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Dexuan Cui <decui@microsoft.com>
Cc: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	Michael Kelley <mikelley@microsoft.com>
Subject: Re: How can a userspace program tell if the system supports the ACPI S4 state (Suspend-to-Disk)?
Date: Mon, 21 Dec 2020 20:07:32 +0100	[thread overview]
Message-ID: <20201221190731.GA19905@amd> (raw)
In-Reply-To: <MWHPR21MB0863BA3D689DDEC3CA6BC262BFC91@MWHPR21MB0863.namprd21.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2172 bytes --]

On Sat 2020-12-12 01:20:30, Dexuan Cui wrote:
> Hi all,
> It looks like Linux can hibernate even if the system does not support the ACPI
> S4 state, as long as the system can shut down, so "cat /sys/power/state"
> always contains "disk", unless we specify the kernel parameter "nohibernate"
> or we use LOCKDOWN_HIBERNATION.
> 
> In some scenarios IMO it can still be useful if the userspace is able to detect
> if the ACPI S4 state is supported or not, e.g. when a Linux guest runs on 
> Hyper-V, Hyper-V uses the virtual ACPI S4 state as an indicator of the proper
> support of the tool stack on the host, i.e. the guest is discouraged from 
> trying hibernation if the state is not supported.

Umm. Does not sound like exactly strong reason to me.

If ACPI S4 is special to the hypervisor, perhaps that should be
reported to userspace...?

> I know we can check the S4 state by 'dmesg':
> 
> # dmesg |grep ACPI: | grep support
> [    3.034134] ACPI: (supports S0 S4 S5)
> 
> But this method is unreliable because the kernel msg buffer can be filled
> and overwritten. Is there any better method? If not, do you think if the
> below patch is appropriate? Thanks!


> @@ -600,8 +601,12 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
>                         s += sprintf(s,"%s ", pm_states[i]);
> 
>  #endif
> -       if (hibernation_available())
> -               s += sprintf(s, "disk ");
> +       if (hibernation_available()) {
> +               if (acpi_sleep_state_supported(ACPI_STATE_S4))
> +                       s += sprintf(s, "disk+ ");
> +               else
> +                       s += sprintf(s, "disk ");
> +       }
>         if (s != buf)

Will this compile on all the systems?

Certainly needs documentation.

Plus if ACPI S4 is supported, kernel can support both normal
hibernation and ACPI S4... so perhaps it should list two entries? And
"disk+" sounds wrong, "acpidisk"?

...and that would bring next question. Usespace writes "disk" there
and uses different file to select between S4 and S5...

								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2020-12-21 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12  1:20 How can a userspace program tell if the system supports the ACPI S4 state (Suspend-to-Disk)? Dexuan Cui
2020-12-21 19:07 ` Pavel Machek [this message]
2020-12-23 21:04   ` Dexuan Cui
2021-02-05 13:05 ` Rafael J. Wysocki
2021-02-05 19:36   ` Dexuan Cui
2021-02-09 18:15     ` James Morse
2021-02-10  7:00       ` Dexuan Cui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201221190731.GA19905@amd \
    --to=pavel@ucw.cz \
    --cc=decui@microsoft.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).