Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2949122lqt; Tue, 23 Apr 2024 06:38:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDQKXJiAyXqKJRTxVw1ZJaqTLR4RdaDqqqj1kQe8dWGtQZ2SKKis7ylEC049+pVpga7vk8iLROupXTw0AZYnEOVfKbu+qHUmSn/sXIYg== X-Google-Smtp-Source: AGHT+IEDWjl7kkQ1j248HYftauuwznXENH41G7IdNbmZbd1K4wjlnO3vNcoGzUW8+eRqKImLXlfA X-Received: by 2002:a05:6512:3719:b0:515:d164:2583 with SMTP id z25-20020a056512371900b00515d1642583mr8782904lfr.11.1713879537048; Tue, 23 Apr 2024 06:38:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713879537; cv=pass; d=google.com; s=arc-20160816; b=hc5E2pIRuY48bqPBFDhOJlftIWyAm6rZ/t+UYQA4cEy8ZLXmINBnq/rjEIH5RO2ivW QhI8bjz4RgEfCUF3ZLTnk0N563z7/+PgZACqSOmwll86A3UV54qEmIC5Gw6IZmJ5UhFm xD7dWPpBmjzFIK2zKxzGYkhSFEy8Bfn7CR2TzIKDlzdUzixdhzN/Bbg8Jz5hRYOL2IfG ZRZaSYpVOtv4EKWkMIeuAOwAqHPleAAi9Rb/HiG8AlRyv9CuAu1TzlOuehRWaCVDcURw dW3sFeo40J4Vb3kHD4X11KoDyPVNB+ct2ufOCS2n99zRcqgIwC78wWRG5MqsJjOI7H1M /xAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=32udfte2i4hLEMMF254xWRCrbZl1retvPZG7p4WJ9T8=; fh=p5zKhCXr0n4EsN3E15ZJ8onhy4AxhOfCBqgwKhaP+30=; b=KnJrWZyUgdvXwIyMYSIVJYt0ZQ+dSgmpXowVDKrWHfTmZKY+wfVddLTq4O9Ovh6zhr tZTnQMZ0W9A1lyK6QMheqwP/E+vgG+Mg9xmNZXEk3/jIoVk1zEVqbgZjqpQCvrSeiGS9 ai1pte6Rwf+Axe/fpQPDpQKAoSyL8DKAGgwbdB7mCt8NuwbSJONaOXY90S0aDF7tOBoQ 7OkpxbB4x0sRDd9ZFcm6M4OXahM2k9He5Yr0p66TckEj38gldAGjdAgzoh02DxTApvXI 7CcykihGXJP0IX3Ruj1nW6z7TPN9JIaE9f9q/92yMJDHX2xAPBXbN3ZQjbzktmFStXJK Z0fA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-155295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155295-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g16-20020a17090613d000b00a5887f917b7si70820ejc.532.2024.04.23.06.38.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 06:38:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-155295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155295-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C14FB1F2259B for ; Tue, 23 Apr 2024 13:38:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06B6413698B; Tue, 23 Apr 2024 13:38:48 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 066FC13664A; Tue, 23 Apr 2024 13:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713879527; cv=none; b=RJhiGHClFKeLC6YtAZMK64LfHAHroIhan136mJ5omeS7mm1f0+iPW5cv2Z3ZOdLYhWA0Un5QwdAGk8WCeu3hX1+vG3VlP4e/z5E/G8ol9ikTTJVo8eWgRj0ZUC2UGIRabJ/INuLO1iiFGK2mf9uVzskz94/RQhyZ/2srFcj4thI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713879527; c=relaxed/simple; bh=PfhZ9BWya075TMeIKQE4oWCcQuH0pMJSpG0ApxJMxuA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PENRTkNMvshJ6518DG22qCSvuBx8Y92xGsBxbV34utusqV2m+jFym68Feakwufw2M/unI9K+LoNlaWDXrtOAXx5g9pDn6Qsj6bJry9CGclcaReYGmgjb1ZAMZ/ags6sl8QrQPaKZEtfXN6Zx5s5d6PmLJc6TPFsOZtUf6M4zzcA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 369F8339; Tue, 23 Apr 2024 06:39:10 -0700 (PDT) Received: from [10.57.76.137] (unknown [10.57.76.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F1193F64C; Tue, 23 Apr 2024 06:38:41 -0700 (PDT) Message-ID: <95c30582-4fba-4e2d-8cc1-776b3e5507b7@arm.com> Date: Tue, 23 Apr 2024 14:38:50 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 0/3] thermal/debugfs: Fix and clean up trip point statistics updates To: "Rafael J. Wysocki" , Daniel Lezcano Cc: "Rafael J. Wysocki" , LKML , Linux PM References: <4918025.31r3eYUQgx@kreacher> <3a8f1978-c5df-40d6-91ca-276431bb01e1@arm.com> <2acea3c3-5c8f-4f3c-a275-743c3fbfd2e6@linaro.org> Content-Language: en-US From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/23/24 13:26, Rafael J. Wysocki wrote: > On Mon, Apr 22, 2024 at 6:12 PM Daniel Lezcano > wrote: >> >> On 22/04/2024 17:48, Rafael J. Wysocki wrote: >>> On Mon, Apr 22, 2024 at 5:34 PM Daniel Lezcano >> >> [ ... ] >> >>>> or we should expect at least the residency to be showed even if the >>>> mitigation state is not closed ? >>> >>> Well, in fact the device has already been in that state for some time >>> and the mitigation can continue for a while. >> >> Yes, but when to update the residency time ? >> >> When we cross a trip point point ? >> >> or >> >> When we read the information ? >> >> The former is what we are currently doing AFAIR > > Not really. > > Records are added by thermal_debug_cdev_state_update() which only runs > when __thermal_cdev_update() is called, ie. from governors. > > Moreover, it assumes the initial state to be 0 and checks if the new > state is equal to the current one before doing anything else, so it > will not make a record for the 0 state until the first transition. Correct, AFAIKS. > >> and the latter must add the delta between the last update and the current time for the current >> state, right ? > > Yes, and it is doing this already AFAICS. > > The problem is that it only creates a record for the old state, so if > the new one is seen for the first time, there will be no record for it > until it changes to some other state. Exactly, it's not totally wrong what we have now, just some missing part that needs to be added in the code, while we are counting/updating these stats. > > The appended patch (modulo GMail-induced white space breakage) should > help with this, but the initial state handling needs to be addressed > separately. > > --- > drivers/thermal/thermal_debugfs.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > Index: linux-pm/drivers/thermal/thermal_debugfs.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_debugfs.c > +++ linux-pm/drivers/thermal/thermal_debugfs.c > @@ -433,6 +433,14 @@ void thermal_debug_cdev_state_update(con > } > > cdev_dbg->current_state = new_state; > + > + /* > + * Create a record for the new state if it is not there, so its > + * duration will be printed by cdev_dt_seq_show() as expected if it > + * runs before the next state transition. > + */ > + thermal_debugfs_cdev_record_get(thermal_dbg, cdev_dbg->durations, > new_state); > + > transition = (old_state << 16) | new_state; > > /* Yes, something like this should do the trick. We will get the record entry in the list, so we at least enter the list loop in the cdev_dt_seq_show().