Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2167224rwb; Thu, 17 Nov 2022 07:22:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Z7SRB+eNyWa7u/EbJuUfPfyP831MLPbrCxNCkE+9sFWAgYAUSzA2yj+OgA9X2TGcALIXL X-Received: by 2002:a17:903:22cf:b0:188:bc8f:5fb2 with SMTP id y15-20020a17090322cf00b00188bc8f5fb2mr3254557plg.48.1668698526081; Thu, 17 Nov 2022 07:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668698526; cv=none; d=google.com; s=arc-20160816; b=bQ46j+jDGzfo8f3baqpsq8xy2iDKHRIq5PVsF60M7ECt7ShCpESq8RoOPg1Qo+CmZX vcAF3RrRQo3m+ZA83ZoCOq0GhR3m6PZs5l98e9bsPtuS/SmOj20o9Ob4gGPZRaovJI6V 7MJgRVj9Dw4m44/qP2bcCAyNmYUH3M6ttGJPWwNdl6z8rVX2s/O/O+s3rTWDb44lxWKe 0kBXL4K2izvK0QxGQVlwo9Au2JF1pVgRl7Ktb/+5erNrRBKg7mUZe61+ln5zyRwiMMCL 5j+a5GNqUa13eOoVpQM24e5+ibXOiHmxi0uZ8nAyCl03NGNfX5r8Vsg/0b8ODksYvD3t 1W6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ZOfT5eurCDMRxlkmRM+KtqZ95XT89veQx2mLMpeWx5s=; b=y3+U/Tih83TjYe88WY34FYgqgIzIRkQUW8idG7NqW9yqPhUjoqpxP/OQqm4A4uHCy7 kSvZ3xJ9xFDs5rDmtt8vhnKRlDCDlYsjz/ol9cf9KuUj93Y0bKupTsXHKVHG3NfTz5hM nv6i6Q66utzNz/NM0hanw+Ixp14HgN2dp/DCgYpIdOH75wGt32ZDo/zxDEBE+MNb8lqK CaB01IYNHSrusXP++AqsWViuqtUBWHncxB9kSNMZF9hsxzREEsOu8c+qqDm8c/wnazl4 EYwf1DPuhPD8A7FckWgF+AweLrhscJwXe72kPMI/dg11oGdoCf3lK0sgVvqop2u1nq+2 QG5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CLSV3SpJ; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c68-20020a633547000000b0046b03475683si1222476pga.831.2022.11.17.07.21.41; Thu, 17 Nov 2022 07:22:06 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CLSV3SpJ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234762AbiKQOLe (ORCPT + 92 others); Thu, 17 Nov 2022 09:11:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240046AbiKQOL0 (ORCPT ); Thu, 17 Nov 2022 09:11:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B25062054 for ; Thu, 17 Nov 2022 06:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668694229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZOfT5eurCDMRxlkmRM+KtqZ95XT89veQx2mLMpeWx5s=; b=CLSV3SpJGhwvtmUhPoWN6QciGKUlPdgWCFeM/Coxpp7UAtyMjhw4CQLJpO909I6zLqB86e W8BtOZ3BBn6ab/gJ3VZtSKk8HHR0BQcCXi1u7449mbldS4aCJLsY+P3q16M/Uss6PrL4c1 UsTP9hpa0uhdZkb4s4lWjH+nkMiu1NA= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-594-Ddu0Z2hKPXK9Bye0mYJsKw-1; Thu, 17 Nov 2022 09:10:28 -0500 X-MC-Unique: Ddu0Z2hKPXK9Bye0mYJsKw-1 Received: by mail-ed1-f70.google.com with SMTP id c9-20020a05640227c900b00463de74bc15so1304426ede.13 for ; Thu, 17 Nov 2022 06:10:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZOfT5eurCDMRxlkmRM+KtqZ95XT89veQx2mLMpeWx5s=; b=0xJWBl/v384ojCljClamt7reSkI+WwJZfPgX+LDHKm7/St3RjTnxL4EoNFh/bAkn6m 0NQMN3HmhiZdZ/WJ3xMTxt2A+gOtii6KXSGddzxztbAu5Yce4UfiQmZoRcaUD8ACrCNw LKgf8ArL4Bz2tJsUCZmCqsQWc51tpLjogUbxQ5C0TY/fnNuu5xTi1dgorrJ5IX0Mj6z0 obww9UWfjn/NO3yANG9gOP5UA0Tl9N4GyI+4AjQ8qVljXguPlOLZOQfWo5LIe7OR/YIt RlfeRdsWQ5272huS88bvuQUL7QCgQXJ9uEZiIU3vedWaVT4aKDoecdFCWP6eAIMZhk6l /+UA== X-Gm-Message-State: ANoB5pn1jQcjQfDRPHt287+xCu5oj4SEXt/kt7MH61zaco2lGAzqlRJQ eKfm/Zbj73p5wAiJ+2jGBJrkcWkORKSq187EWS2FNV38fSuQTVqr1eMLJnrhSSCn/2dbOIoouSw wOgGwnhUGN/CPVgmofVFz5IcH X-Received: by 2002:a17:906:a0d7:b0:7b2:7af0:c231 with SMTP id bh23-20020a170906a0d700b007b27af0c231mr2246812ejb.240.1668694227325; Thu, 17 Nov 2022 06:10:27 -0800 (PST) X-Received: by 2002:a17:906:a0d7:b0:7b2:7af0:c231 with SMTP id bh23-20020a170906a0d700b007b27af0c231mr2246782ejb.240.1668694227137; Thu, 17 Nov 2022 06:10:27 -0800 (PST) Received: from ?IPV6:2001:1c00:c1e:bf00:d69d:5353:dba5:ee81? (2001-1c00-0c1e-bf00-d69d-5353-dba5-ee81.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:d69d:5353:dba5:ee81]) by smtp.gmail.com with ESMTPSA id b2-20020a1709063ca200b007acd04fcedcsm413829ejh.46.2022.11.17.06.10.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Nov 2022 06:10:26 -0800 (PST) Message-ID: Date: Thu, 17 Nov 2022 15:10:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [RFC v3 0/4] Make it easier to measure % in HW sleep state Content-Language: en-US, nl To: Mario Limonciello , "Rafael J . Wysocki" , Stephen Boyd , platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sven van Ashbrook , Raul Rangel , Pavel Machek , Len Brown , John Stultz , Thomas Gleixner , Rajneesh Bhardwaj , S-k Shyam-sundar , Rajat Jain , David E Box References: <20221115200156.12218-1-mario.limonciello@amd.com> From: Hans de Goede In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Hi, On 11/15/22 21:01, Mario Limonciello wrote: > Sven van Ashbrook brought a patch to the kernel mailing list that > attempted to change the reporting level of a s0ix entry issue to a > different debugging level so that infastructure used by Google could > better scan logs to catch problems. > > This approach was rejected, but during the conversation another > suggestion was made by David E. Box to introduce some infrastructure > into the kernel to report this information. > > As it's information that is reported by both AMD and Intel platforms > over s2idle, this seems to make sense. > > RFC v1 and v2 introduced two new sysfs files to report the information, but > Rafael pointed out that there was already a file that could be used on > Intel platforms: `low_power_idle_system_residency_us`. > > RFC v3 creates this file for AMD platforms and also introduces another file > that can be used to determine total sleep time: > `/sys/power/suspend_stats/last_total`. > > With these two files a simple shell script can be run after suspend to > calculate the percentage. > > ``` > #!/bin/sh > total=$(cat /sys/power/suspend_stats/last_total) > hw=$(cat /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us) > percent=$(awk -v hw=$hw -v total=$total 'BEGIN { printf "%.2f%%", (hw/total*100) }') > echo "Last ${total}us suspend cycle spent $percent of the time in a hardware sleep state." > ``` > > A sample run on an AMD platform that was just sleeping with this series on > top of 6.1-rc5 shows the following: > # ./compare.sh > Last 15699838us suspend cycle spent 98.63% of the time in a hardware sleep state. > > Further discussion to be expected on this series: > > * What last_total will represent from the suspend cycle > > * Whether the semantics of all platforms will be the same for > `low_power_idle_system_residency_us` > - AMD platforms reset this counter before s2idle entry. Do Intel? Others? > > * Maybe the *kernel* should be responsible to do the calculation and export > a `last_hw_sleep_percent` file instead. Platform differences can be > abstracted then within individual drivers. That (`last_hw_sleep_percent` file) is an interesting proposal, I can see that being a better interface because as you say this allows the kernel / platform-drivers to take care of any platform quirks / weirdness, avoiding any userspace monitoring of this to possibly give false positive warnings. Regards, Hans > > Mario Limonciello (4): > PM: Add a sysfs file to represent the total sleep duration > platform/x86/intel/pmc: core: Drop check_counters > platform/x86/amd: pmc: Report duration of time in deepest hw state > platform/x86/amd: pmc: Populate cpuidle sysfs file with hw sleep data > > Documentation/ABI/testing/sysfs-amd-pmc | 6 ++++++ > Documentation/ABI/testing/sysfs-power | 8 ++++++++ > drivers/platform/x86/amd/pmc.c | 27 ++++++++++++++++++++++--- > drivers/platform/x86/intel/pmc/core.c | 7 ++----- > drivers/platform/x86/intel/pmc/core.h | 1 - > include/linux/suspend.h | 2 ++ > kernel/power/main.c | 15 ++++++++++++++ > kernel/power/suspend.c | 2 ++ > kernel/time/timekeeping.c | 2 ++ > 9 files changed, 61 insertions(+), 9 deletions(-) >