Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1464178rwl; Fri, 31 Mar 2023 11:30:17 -0700 (PDT) X-Google-Smtp-Source: AKy350bh7k+yAN7AHU91VjUCjNtPhv2TdaqsFpfc7MVu9EAWXiD6x3sfWIxruosdCu9HvgNJpnrg X-Received: by 2002:a17:90a:bc83:b0:23f:6872:e37c with SMTP id x3-20020a17090abc8300b0023f6872e37cmr6635294pjr.0.1680287416865; Fri, 31 Mar 2023 11:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680287416; cv=none; d=google.com; s=arc-20160816; b=pPHfemlT8zcSnIZ33xdxyNCH8sLtFUdjahkZR12kRf6whxEcSAjwllfKbOl6MDJuB5 nbwkIvFZ0k3gKmazHY+eeWjIG1HWJ5Ik224C5ZdLOdTB39fTzp8DmQbQ5LmtgQh9FA+2 fQ3PtbhEU6x3uByFPezu9kbtzKfBmG8QcsvqHAqAa64ZVYdbjD2+d7J3X3Rum8K7APNE WqCfswb3hrf2IbD2dZOu2ZGZCB3OBrPNM9n+mkEeEZb1GY5JLD3WpHgwLC9vK1bAMNSJ VRWIfopBRbwO5GEmO0Isgoi9JsLrjYhq96kxN8ni9Mg/L+rVIsnjxuqjW0D91EbLYKYK 1OUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=Lt+n0aNkjO6BohP8w5QtfMZuwpMAlxxlfSSdj512VAc=; b=eUP5BbIywkGsJ4dbdptY7Kawic4RGEFhXZaaUifiEi+O/lb6D6bUK5ElxCudCDKGpZ NeHhy9Nj7gkdYusoljO9Fd2IvyarZSPxR+N6tTzLYbOTbZbsiG/R8q36zSQGHZ8dc9Tc ujjPpZx/aLquhnrUtzUzOHVcflthDnqtkibcm56CcmTad3t7cO8grTyprp9XWuk2X4E8 m+CV6dSmqL7aB3WN2gB+upzoq1E02l8P47sunxEigrKEkokm7uO5dvvsSFNSgjWjFzak t+em0/KhySf2zLtA3qmoNdA8aqGfFfOzy/G/oCqEplL2otDZx1J49BBapChoGXc+KBrP rmTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r62-20020a632b41000000b0050fa589bc9esi2795059pgr.592.2023.03.31.11.30.04; Fri, 31 Mar 2023 11:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232984AbjCaS0F convert rfc822-to-8bit (ORCPT + 99 others); Fri, 31 Mar 2023 14:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbjCaS0E (ORCPT ); Fri, 31 Mar 2023 14:26:04 -0400 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CCB01BF4C; Fri, 31 Mar 2023 11:26:03 -0700 (PDT) Received: by mail-ed1-f50.google.com with SMTP id er13so52176144edb.9; Fri, 31 Mar 2023 11:26:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680287161; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RaB5p8dANCz2nc2jG5lwXWHNdu974YJYtJWNgZD8A8M=; b=CCZN5FF3/Ox0z+h8BWZVY6/HoRSeD1i1u16vmqKTicuMWY++c3ywrBgQiWz0tsdTtJ AUx/um1OdzrqWczZomQsFxFvWtQ8YgGtays5Z92yeEMSAi8Ab+IgnMm1ZhcUBz+QuqNc t7EXkeqqkWIidhoz8y7PIklVMPemnXVQhueMyVY4BNDpl+ANtqiYQ0/P5D7Gkd3m6RJm d8Zlvnd4wIGt0XDu1oSyVd11op324SMA98I4MTZ8U1j/cBOmAtY6Ue0cwWusn8lZSjjS IlE+L2Lm6PDRPDOygCs7NnNEStmPeCVd0nEvFi10TmJdMancdDvcDrgSPXLQzo4cCy20 JgSQ== X-Gm-Message-State: AAQBX9cyv+bilD0bZXUrPpvDpA/rN84+8gI/pykm6ru+kAZZ1bvUnDdW 5ng1PJ4DUDcm/W0DTUbsne1hBczrtOfCb3bmA0s= X-Received: by 2002:a50:d49e:0:b0:4fc:ebe2:2fc9 with SMTP id s30-20020a50d49e000000b004fcebe22fc9mr13651347edi.3.1680287161357; Fri, 31 Mar 2023 11:26:01 -0700 (PDT) MIME-Version: 1.0 References: <20230330194439.14361-1-mario.limonciello@amd.com> <20230330194439.14361-2-mario.limonciello@amd.com> <2676888c-e93f-53aa-a4f7-e85b66f351c8@amd.com> <8a04da89-1c98-8b29-bf96-1e8d0ed47e58@amd.com> In-Reply-To: <8a04da89-1c98-8b29-bf96-1e8d0ed47e58@amd.com> From: "Rafael J. Wysocki" Date: Fri, 31 Mar 2023 20:25:50 +0200 Message-ID: Subject: Re: [PATCH v5 1/4] PM: Add a sysfs file to represent time spent in hardware sleep state To: "Limonciello, Mario" Cc: "Rafael J. Wysocki" , Sven van Ashbrook , John Stultz , Len Brown , Pavel Machek , Raul Rangel , David E Box , Rajat Jain , S-k Shyam-sundar , Hans de Goede , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 31, 2023 at 8:13 PM Limonciello, Mario wrote: > > On 3/31/2023 13:07, Rafael J. Wysocki wrote: > > On Fri, Mar 31, 2023 at 8:05 PM Limonciello, Mario > > wrote: > >> > >> On 3/31/2023 13:01, Rafael J. Wysocki wrote: > >>> On Thu, Mar 30, 2023 at 9:45 PM Mario Limonciello > >>> wrote: > >>>> > >>>> Userspace can't easily discover how much of a sleep cycle was spent in a > >>>> hardware sleep state without using kernel tracing and vendor specific sysfs > >>>> or debugfs files. > >>>> > >>>> To make this information more discoverable, introduce a new sysfs file > >>>> to represent the time spent in a sleep state. > >>> > >>> This is only in the most recent suspend-resume cycle, isn't it? > >> > >> Yes; that's correct. > >> > >>> > >>> Wouldn't it be useful to have another attribute printing the > >>> accumulated total HW sleep time? > >>> > >> > >> I had considered this; but I didn't think it was actually very useful > >> because userspace will get control at the end of every cycle and can > >> accumulate those numbers if desirable. > > > > Unless "user space" in question is actually a human, that is. > > This is what I envisioned: > > * In traditional Linux some software like systemd could capture this and > log it. > It could subtract at the time the suspend started from the time it ended > and use that to calculate a percentage of time in hardware sleep state > and then put that percentage in the system journal. > > * In ChromeOS something like powerd would be the only thing reading this > number and it could be adding it up during dark resume until the system > gets to a full resume. > > * If a human is manually capturing these values they'll be most > interested in whether an individual cycle reached hardware sleep. Or whether or not it has been reached in any cycle so far? Or in the most recent 10 cycles? Or similar? Or how much time the system spent in HW sleep in general? > If it didn't they'll want to look at debug data from that cycle. > The aggregate will be noise. Not necessarily and the point is that you can relatively easily provide both values, the one from the most recent cycle and the grand total. > Do you think of another use case? Well, if the kernel can easily compute and expose the grand total value, why is it better to offload that to user space, possibly in different ways in different system configurations? What if somebody runs a minimum user space?