Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3576800rdb; Wed, 27 Dec 2023 11:53:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1Sq4JtO/dVrCYvUz+ozj9JkMnEbYkkT2+WpBoSy/eaTj3fQhK8VhHkzw3/ld9EnY0oU3D X-Received: by 2002:a05:6a21:81a8:b0:190:8e40:6f2a with SMTP id pd40-20020a056a2181a800b001908e406f2amr9926875pzb.44.1703706837349; Wed, 27 Dec 2023 11:53:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703706837; cv=none; d=google.com; s=arc-20160816; b=ARTikT1wGkdJbiGbbf7wXP1LRF0EKKVRK7t0Fp3Ky07U0VGMlKMHg4JnRA89YiYq4G w+RRtmLVuPVIYOWSHqoB+5fi6jM1aAj0CMEhaDvD+VbV7oOPCp82kwoy498UjtgtBwvo 7cfrbhzNqhvpHh6ZIyIf6tLsfVmngDTCl3vNPAdvo8Ti9F480QeWbz923Li30cy0jPYR atAweK6rA+OimGAK/5Xw7p7F7yC5AHcRKusUW13WODivjz83DLIXuphvDkZwOwFRK+Zk odJAEXaJg8FSEDHOeurL99rrNJIeiQAHiJue+BcutdJLROeH4CjBAyoe7Wi/eg1kU2Ac Jlww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=PzGvqkA+7vSK4S2dZ8/CmTeqqUn7cIuH50aZn1M+9vQ=; fh=lasocqyH+smjn/JDqQmsle5z/7Yg0jXhqkym87rl84w=; b=T8sUXJrt0XwJXDRBT0xIRG9uodXhc0aYpseU8cc46YUIfrLguY+dlI9C56qhwtExUD yXHwbax32wEyuAB6TZjOmR+7U+6U8MF+NCvhUct5YbueXqUuEnIyq4pvMPB87f0TLmjo 8kr52QlKp9nrAO5ihyGwnkI/55xM6hrU0pGO5Y2f59c+TbreFNAvaoaV3yGF3CDONP7I EG99REYvgAGYIDY6MVjcd/I87IF7L01UvDAHvsfDKtcxy4CLtniwZ9ndJI7UeCYyGv/b W1HMvwU4pcPm1QAh0tACTIg91xXP929UNy+dqE9Cb39eMMejrUN33e7jKBSpQ/QUldPv E0Cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b5-20020a63d805000000b005cdffe116d0si8002403pgh.532.2023.12.27.11.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 11:53:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 076D7B225E9 for ; Wed, 27 Dec 2023 19:53:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AD7947A63; Wed, 27 Dec 2023 19:53:40 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A7F047A51; Wed, 27 Dec 2023 19:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6dc003289c9so128173a34.0; Wed, 27 Dec 2023 11:53:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703706817; x=1704311617; 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=PzGvqkA+7vSK4S2dZ8/CmTeqqUn7cIuH50aZn1M+9vQ=; b=aA5QtZOpz8PS2QEnyTd+HBvKv7QToIxNN92ylzF/V2eU4y2Ly46TuXI4/bLP3oyskX stoMzM0ZYyoyZEGHxafk61Pz7gn7W9kgDgEJ3OxkbA1ah0VUfuI/hYXXPjK7pUFiKHAu cx99ZKNKBY1gg4nOpfMx9WxNaeRpVb8qMXE/Wtt6op9GjlL5b76mIl1JuLPxkK3VcqQu wzxEEXUAjrYF3KfobWpYVUEVeDvK0vGlnsvecFjR2SF6VMla9WZTYlVGUHgf8783LbKE nO2LJ3x22L9nlHHHCQ3v4dkypEl4de+SiugL8kCiIkupNO32ih/KXuFgonxL5FVL3ohq cA+A== X-Gm-Message-State: AOJu0Yx8k1RKyuEvhxAUR0k/flG4JBzaNLQCI4YlvfugoZCihlANIPte fUsdm7ClQglIp4KBot9RMogqXWr6OoR3WnEsChU= X-Received: by 2002:a4a:dc96:0:b0:594:ad62:bab9 with SMTP id g22-20020a4adc96000000b00594ad62bab9mr5536266oou.1.1703706817350; Wed, 27 Dec 2023 11:53:37 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231219092539.3655172-1-daniel.lezcano@linaro.org> <20231219092539.3655172-2-daniel.lezcano@linaro.org> <60ecab8e-7b96-469e-9bae-25c51514e6e8@linaro.org> In-Reply-To: <60ecab8e-7b96-469e-9bae-25c51514e6e8@linaro.org> From: "Rafael J. Wysocki" Date: Wed, 27 Dec 2023 20:53:25 +0100 Message-ID: Subject: Re: [PATCH v3 2/2] thermal/debugfs: Add thermal debugfs information for mitigation episodes To: Daniel Lezcano Cc: "Rafael J. Wysocki" , rjw@rjwysocki.net, lukasz.luba@arm.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Daniel, On Sat, Dec 23, 2023 at 12:41=E2=80=AFPM Daniel Lezcano wrote: > > > Hi Rafael, > > On 21/12/2023 20:26, Rafael J. Wysocki wrote: > > [ ... ] > > > >> +/** > >> + * struct tz_events - Store all events related to a mitigation episod= e > >> + * > >> + * The tz_events structure describes a mitigation episode. > > > > So why not call it tz_mitigation? > > A mitigation episode =3D N x tz_events > > eg. > trip A =3D passive cooling - cpufreq cluster0 > trip B =3D passive cooling - cpufreq cluster0 + cluster1 > trip C =3D active cooling + fan > > temperature trip A < trip B < trip C > > The mitigation episode, as defined, begins at trip A, and we can have > multiple events (eg. trip B crossed several times, trip C, then trip B > again etc ...). I understand this, but I thought that tz_events represented the entire epis= ode. > [ ... ] > > >> + if (dfs->tz.trip_index < 0) { > >> + tze =3D thermal_debugfs_tz_event_alloc(tz, now); > >> + if (!tze) > >> + return; > >> + > >> + list_add(&tze->node, &dfs->tz.tz_events); > >> + } > >> + > >> + dfs->tz.trip_index++; > >> + dfs->tz.trips_crossed[dfs->tz.trip_index] =3D trip_id; > > > > So trip_index is an index into trips_crossed[] and the value is the ID > > of the trip passed by thermal_debug_tz_trip_up() IIUC, so the trip IDs > > in trips_crossed[] are always sorted by the trip temperature, in the > > ascending order. > > > > It would be good to write this down somewhere in a comment. > > > > And what if trip temperatures change during a mitigation episode such > > that the order by the trip temperature changes? > > Changing a trip point temperature during a mitigation is a general > question about the thermal framework. > > How the governors will behave with such a change on the fly while they > are in action? > > IMO, we should prevent to change a trip point temperature when this one > is crossed and has a cooling device bound to it. Well, it's not that simple. There are legitimate cases in which this can happen on purpose. For example, the ACPI spec does not provide a way to get a trip hysteresis from the platform firmware and instead it recommends the firmware to update the trip temperature every time it is crossed on the way up in order to implement hysteresis. > >> + > >> + tze =3D list_first_entry(&dfs->tz.tz_events, struct tz_events,= node); > >> + tze->trip_stats[trip_id].timestamp =3D now; > >> + tze->trip_stats[trip_id].max =3D max(tze->trip_stats[trip_id].= max, temperature); > >> + tze->trip_stats[trip_id].min =3D min(tze->trip_stats[trip_id].= min, temperature); > >> + tze->trip_stats[trip_id].avg =3D tze->trip_stats[trip_id].avg = + > >> + (temperature - tze->trip_stats[trip_id].avg) / > >> + tze->trip_stats[trip_id].count; > >> + > >> + mutex_unlock(&dfs->lock); > >> +} > > > > --