Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19713497rwd; Wed, 28 Jun 2023 13:10:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64pKh+hUZszS3bnDkg4XKMJmuQCPbA6PtQPcWw5z0fI9uHDguJAoeSbFvhjIn4T9Yku1N9 X-Received: by 2002:a17:902:f806:b0:1b8:2132:a7fd with SMTP id ix6-20020a170902f80600b001b82132a7fdmr4457287plb.13.1687983034103; Wed, 28 Jun 2023 13:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687983034; cv=none; d=google.com; s=arc-20160816; b=iG5AJZ9BQk2+V6DY5WwwqaF8mKnLBJdCbvAj6r/vuFeGWXnuwaV6Csh9BZG4Dtfte1 rpEhj2pSvS1o7RK4VuT5VMve2+5h+WyucJ9X6ZUaQTDWwAc+237OqrdVtkhcBeJwolEr jpfF/DYR/qgGBlsV299kFSTwKAu2iisaSx5aNhZy7ImAFFhlcRL1dG8ZFPYe4ZtwZvuV dmIMoDvoHnw/2ox04F7nth4jxnwozjgaL8ej51nik3bUSSWDS1U81AOr3prAdKiy9DQS LDC0XbHVAM92NGGJqz9dAjwRvz1ROieFWiH6fX50BbR8J3rD8hWxZ8aEnX+7Oi8S18gs FENg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cRFOV5Ls4SEa3fwf1hjcJYjzDAHXzu2G6NG1ewG32Wc=; fh=QVCiou5EjAWi2M+yxZXRZkwAppYA8RPTPz+4WJKSyds=; b=mAKeh/7ClZDxd6DyNOXYhRnOCylhJS2twFZF57KWWBRrAbJOa03eGgfwIJxaAnz8x8 RYNex9ji0az4bG2+96BLAVzpw4sFMlrmtiV7HUeI0zlt+onGxAu9Wdbu5U5rDKrmVNNZ pYryisz9IIfCDFgVp4vGuhr26svTpRi+o0adFgzWS5KuorB3tPkwCl1ENzdHVwRv8IPV kkCS7EzcNYSkAI5E1zHc7uFJT7RngE44ey/cmFDIe7xPod2e49Nk71VYD8ZzAjfctMOI YXqgRR6n9BurIXaLRATrXisv+P8iSjtYKttbyYRw+OZeyuySKOjCvkRbxG3rjNIu+6cb iKUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z3DAS+Dh; 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 u16-20020a170903125000b001b3415a07dcsi10090081plh.91.2023.06.28.13.10.19; Wed, 28 Jun 2023 13:10:34 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z3DAS+Dh; 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 S231778AbjF1UAM (ORCPT + 99 others); Wed, 28 Jun 2023 16:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjF1UAG (ORCPT ); Wed, 28 Jun 2023 16:00:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 613B31FE7; Wed, 28 Jun 2023 13:00:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CD54D61464; Wed, 28 Jun 2023 20:00:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF7D6C433C8; Wed, 28 Jun 2023 20:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687982404; bh=B+RSyNVteRzKXRsWojAaoBAvx3nzmKOepDBCgrWk75Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z3DAS+DhjSBSF9kLBE56DRoAnHxqMycCSGE90TM5K/zrbttcJ0PGjGYru+7zttFug SiEsAu/eGbGk87tJa6MbuC+4T6HZPPX6H9LsZ3O+JhVTD8jEYeNYdS1/fsm3a1Kc/7 m4Ov1P0PCeIr7Ml2rVcX1J8bHYjjXYZ6KnwGejaruvL4cghEvDC0/W2KgSdq25y0mU VwXE5W2suIGkTVwtlP9WYGagF9KxO/mqmfLMx8OpDoZAJY1X1wjz46lqpXWBKGWubM 2TWNJSmvbpFWbG4HoimhGCvT6CxwGWTRSqdLIT5NWqnnDlQDWGvmibpuh2Aw2nEpJF gAqCqtEDvDT2A== Date: Wed, 28 Jun 2023 13:00:02 -0700 From: Eduardo Valentin To: "Rafael J. Wysocki" Cc: Eduardo Valentin , eduval@amazon.com, linux-pm@vger.kernel.org, Daniel Lezcano , Amit Kucheria , Zhang Rui , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] thermal: stats: introduce tz time in trip Message-ID: References: <20230519032719.2581689-1-evalenti@kernel.org> <20230519032719.2581689-6-evalenti@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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, Jun 23, 2023 at 06:40:20PM +0200, Rafael J. Wysocki wrote: > > > > On Wed, Jun 21, 2023 at 6:45 AM Eduardo Valentin wrote: > > > > On Tue, Jun 20, 2023 at 07:27:57PM +0200, Rafael J. Wysocki wrote: > > > > > > > > > > > > On Fri, May 19, 2023 at 5:27 AM Eduardo Valentin wrote: > > > > > > > > From: Eduardo Valentin > > > > > > > > This patch adds a statistic to report how long > > > > the thermal zone spent on temperature intervals > > > > created by each trip point. The first interval > > > > is the range below the first trip point. All > > > > subsequent intervals are accounted when temperature > > > > is above the trip point temperature value. > > > > > > > > Samples: > > > > $ cat /sys//class/thermal/thermal_zone0/stats/time_in_trip_ms > > > > trip-1 0 0 > > > > > > The above line is confusing. > > > > > > > trip0 -10000 35188 > > > > trip1 25000 0 > > > > > > And the format violates the "one value per attribute" sysfs rule. > > > > > > > $ cat /sys//class/thermal/thermal_zone0/stats/time_in_trip_ms > > > > trip-1 0 0 > > > > trip0 -10000 36901 > > > > trip1 25000 0 > > > > $ echo 25001 > /sys//class/thermal/thermal_zone0/emul_temp > > > > $ cat /sys//class/thermal/thermal_zone0/stats/time_in_trip_ms > > > > trip-1 0 0 > > > > trip0 -10000 47810 > > > > trip1 25000 2259 > > > > $ cat /sys//class/thermal/thermal_zone0/stats/time_in_trip_ms > > > > trip-1 0 0 > > > > trip0 -10000 47810 > > > > trip1 25000 3224 > > > > $ echo 24001 > /sys//class/thermal/thermal_zone0/emul_temp > > > > $ cat /sys//class/thermal/thermal_zone0/stats/time_in_trip_ms > > > > trip-1 0 0 > > > > trip0 -10000 48960 > > > > trip1 25000 10080 > > > > $ cat /sys//class/thermal/thermal_zone0/stats/time_in_trip_ms > > > > trip-1 0 0 > > > > trip0 -10000 49844 > > > > trip1 25000 10080 > > > > > > > > Cc: "Rafael J. Wysocki" (supporter:THERMAL) > > > > Cc: Daniel Lezcano (supporter:THERMAL) > > > > Cc: Amit Kucheria (reviewer:THERMAL) > > > > Cc: Zhang Rui (reviewer:THERMAL) > > > > Cc: Jonathan Corbet (maintainer:DOCUMENTATION) > > > > Cc: linux-pm@vger.kernel.org (open list:THERMAL) > > > > Cc: linux-doc@vger.kernel.org (open list:DOCUMENTATION) > > > > Cc: linux-kernel@vger.kernel.org (open list) > > > > > > > > Signed-off-by: Eduardo Valentin > > > > --- > > > > .../driver-api/thermal/sysfs-api.rst | 2 + > > > > drivers/thermal/thermal_sysfs.c | 86 +++++++++++++++++++ > > > > 2 files changed, 88 insertions(+) > > > > > > > > diff --git a/Documentation/driver-api/thermal/sysfs-api.rst b/Documentation/driver-api/thermal/sysfs-api.rst > > > > index ed5e6ba4e0d7..4a2b92a7488c 100644 > > > > --- a/Documentation/driver-api/thermal/sysfs-api.rst > > > > +++ b/Documentation/driver-api/thermal/sysfs-api.rst > > > > @@ -359,6 +359,8 @@ Thermal zone device sys I/F, created once it's registered:: > > > > |---stats/reset_tz_stats: Writes to this file resets the statistics. > > > > |---stats/max_gradient: The maximum recorded dT/dt in uC/ms. > > > > |---stats/min_gradient: The minimum recorded dT/dt in uC/ms. > > > > + |---stats/time_in_trip_ms: Time spent on each temperature interval of > > > > + trip points. > > > > > > I would write "in each temperature interval between consecutive trip points". > > > > Ok > > > > > > > > Doesn't this assume a specific temperature ordering of trip points? > > > And so what if they are not ordered? > > > > It does. I believe other things will break if they are not ordered. > > But there's no guarantee that they will be ordered, so it looks like > those other things are already broken. Correct. (1) there is no guarantee, it works by construction, and (2) current code does assume ascending order, so yes, if they come unsorted, the core code will not properly work. Ensuring the order is likely beyond the original intention of this patch, but we do need to improve there, for sure. -- All the best, Eduardo Valentin