Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2355403pxb; Fri, 5 Feb 2021 16:12:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrgQF+XueB7InkdHcOMRkIBrdqU4B+cw9HlgjJ2kway21zZtCotQ/lE/F8kAmcWIRgEjeE X-Received: by 2002:a17:906:2ed7:: with SMTP id s23mr6221654eji.346.1612570354674; Fri, 05 Feb 2021 16:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612570354; cv=none; d=google.com; s=arc-20160816; b=P/OMr3EsdT9d6UjWZ1BUJiYg9PI9fmsvpuev2fGnbIsWftKfdzakVo+hOsvTtfd4wt VdXvGq2UkOuGYhli4m1BpflIVBnwl49ejHgcSLjRQU88GWz8TggpTGvl4HkG+oJOHhbD IZv7jo9bpdDbiTtRsui7DFrwQd7b5XsJq2UVFCA1/UvLlZsUmVEHvmiFrhRUrqN3fdUb sF3wipf0/pAezjN8YR6ARFvp5lv/KIpp7IBVjJ0AVXWQMbks2pcVgP466MD5n6Yb0S3y HdYltTywaWIpJpzGweGbgwHA86XzHFkSgzQurn7I2K/qAxE2zDYU4nz9vyJhwz9uVLJi 6RfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=zebLqAyquoHLSHUIiikHXZ2kyJyvLp0C6IWdVIP3/DY=; b=cX79/MXCFifPmMG9S8XkkHiTjkzLAPQheMDpXKa6Lbryirf5osQ/gWTBggG+u3hgYI vfVVU6sSFHjV3CDZsmmNBE+x79UDEMksNHu13VGrw4Y3rFO6hULnoL8W58VH+BBIuQls rIkSZ3PdrAswgpVh+wr7l7n4KfrkW0rSm+Yptd1RpPsfP6Ae9PUXdaGzoe2B7F5jCcar Lta8QQjJyyw9aSZb1+sJH/Fa6PK8FmnkU0h0nOSzgOiK/FpLHbQPGxTgF+9+Gf/OffB+ lgOTbj7gu6JP4ZFpoV60c0/TOOOZMa6uWS+wBP5PfDlRCE5/uIInqlpee3OupdXI3SER 57+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj25si6130756edb.580.2021.02.05.16.12.10; Fri, 05 Feb 2021 16:12:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229622AbhBFALU (ORCPT + 99 others); Fri, 5 Feb 2021 19:11:20 -0500 Received: from mail-oo1-f52.google.com ([209.85.161.52]:38802 "EHLO mail-oo1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbhBENGb (ORCPT ); Fri, 5 Feb 2021 08:06:31 -0500 Received: by mail-oo1-f52.google.com with SMTP id y72so1584753ooa.5; Fri, 05 Feb 2021 05:06:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zebLqAyquoHLSHUIiikHXZ2kyJyvLp0C6IWdVIP3/DY=; b=rVkfciYGCGvLy3tOUuFsj1ucLDAMY/ALk44YYn0knLS4ax88oJFXFLwIbvTPRY1wXo MIkBSGIbU/bl04Iu20yw2WRhtzlZYik5/tktu4wjVSkhh9M+oHQo2uC2YVbVYJQEVwnN vEpveuoTsK75UUtXvrQZswI2Lsl5jHShhzgaVtUttd1dVsMG5AVAArPBMaA8UzwkxQGa Uo5mCI1EtVtgw904uJRwunTRApozkbiUfHszDnH2uTAdx+zH/TtpU6Bj9r9aILC/xXj7 fYm84yfjMr6QWqMAK5fmFmgNuTp526wI3mDePMEyt3jigxA2zaVh2e1qZJApxKOto1WP DGPw== X-Gm-Message-State: AOAM5318mPfWt2vl4uXgVKzNAn+yeqCvzFIONGXkp5EmRKZC4qK0eUUM VpZhZqa8S1KyqYzYj/FumRLTtHNqJoTowqr9wu4= X-Received: by 2002:a4a:9873:: with SMTP id z48mr3360258ooi.44.1612530350081; Fri, 05 Feb 2021 05:05:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 5 Feb 2021 14:05:36 +0100 Message-ID: Subject: Re: How can a userspace program tell if the system supports the ACPI S4 state (Suspend-to-Disk)? To: Dexuan Cui Cc: "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , Michael Kelley Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 12, 2020 at 2:22 AM 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. > > 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! Sorry for the delay. If ACPI S4 is supported, /sys/power/disk will list "platform" as one of the options (and it will be the default one then). Otherwise, "platform" is not present in /sys/power/disk, because ACPI is the only user of hibernation_ops. HTH