Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp199937rdb; Wed, 20 Dec 2023 09:45:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3njQUv4hkejH6xn14WKoNkpHwVscCSjmJD43rLwXNwKeAOCvf2lTW7dfnLz/2qHKH7sSP X-Received: by 2002:a05:6a21:3284:b0:190:665b:f773 with SMTP id yt4-20020a056a21328400b00190665bf773mr25507pzb.58.1703094310042; Wed, 20 Dec 2023 09:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703094310; cv=none; d=google.com; s=arc-20160816; b=NnMJjPkIpwjSXgL0Kj0TApBI0ljIcUvQGzKY+NzB1DZm63D9j3PjqaTAk0qdRn1UAK zBb+BlQZ6//kExy3i/Clj5HnpHciHSm6NLeGdlYNdhmsNsbCUpLyAiRN+Ofe7U69TIbb 0OZOWRmM0vjyWMSagGWiZlPEPhMy/WTOq+S7nZSHRal3IWoRXMTpMJcrB7NIst0QnX8r zRlq6IjbbqtERTvCOUlMMrUm/s/nzkgfQVC2fkGhLNrIBHzAU0Af1vrRq8npZkR+2tpQ nVi34+Nrp0+6SASYJTRnfqbYHye0FgWJlUeHk5niGJgrQNw+LQkBQxeL0ez2C9t0KAH8 /yKw== 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=Spg9sI5q8sRQEzGkG7hq+MtRjhUPkBO3KmZ8kEcf9EI=; fh=fLk6+zTI9TI7kvGwV4p+BkicOiDGI72hJ735oPZCzIk=; b=Z/mCb+BgxKstioT/60M7etjA5uoW/FGMK0tHVRQEkBB6RbAu06x4ZOUAvK/Y9OikTO JgnMtzlqEcZqiB+l7DOvwwUrs68Danq0maIyXRU9foWuvJ7y4iK7HxNpB09WAvctfUc1 JG1yDr7Qch2O4Q5tLLMrp6PWTbeeH1fVVCHkoVv3C/clyMu1ORhfjsPvg9W6LaGJU0+E PaR67w3U0X576yw7x5/yGKxu8n4c6jp7+CUCYJn0PFHUSdhMXk7vmNMlEGcOxm8DQz3R WZZ0StBP+HpPLXk8aPCHp6DsCAx8K2Z3iKszb0FeNRUIdZ+x8TC/ng6xWvlmqV1UG2KF lxyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7362-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. [147.75.48.161]) by mx.google.com with ESMTPS id q18-20020a637512000000b005cd7818afb9si79857pgc.698.2023.12.20.09.45.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 09:45:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7362-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 D7056B2491D for ; Wed, 20 Dec 2023 17:44:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE656482C5; Wed, 20 Dec 2023 17:44:44 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 15C2247F4A; Wed, 20 Dec 2023 17:44:42 +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-oo1-f46.google.com with SMTP id 006d021491bc7-58dd5193db4so1162332eaf.1; Wed, 20 Dec 2023 09:44:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703094282; x=1703699082; 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=Spg9sI5q8sRQEzGkG7hq+MtRjhUPkBO3KmZ8kEcf9EI=; b=uQifR7h15vnOfKGNdIsg0e7SFTJcQ4auIgzJ4CpNTnnYBCDFim5BY1NUU3t7NYnH06 tEcUvmrr6kxxQC775XgedKqnLMfDj6ixcjjArAdtFLsxXyY8Nyyty0wlhjU9DnnwED4C bPvKYmdA0Z7gLUuE6nxEthghxXDNo+fE8IW06jrfrax99PTeM+gk0g42prk1/Vaiub/X mSH8FGrz2dXbuk/wXU+IkLETMn1q2J2DEaR0eijTXUMuK/nOfpaVasMMQyjlWhTxyYZ7 NWDy2Po18nuBBWl98glBYYz7IskIPntZer2kOnbqldGTpEPzv8wj0NSsg14uLNR2jNvo CSyw== X-Gm-Message-State: AOJu0Yy/biUwSae1AAju+wShummSSbWCpuUa4onMPXg0IAMdctoyT0BU R/9BsvxnvO+NChzwrfhNW3L7r7Ew0IeXdAfZ2XNWYM6H X-Received: by 2002:a05:6820:104f:b0:594:33c:f126 with SMTP id x15-20020a056820104f00b00594033cf126mr2281624oot.0.1703094282175; Wed, 20 Dec 2023 09:44:42 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231212134844.1213381-1-lukasz.luba@arm.com> <20231212134844.1213381-2-lukasz.luba@arm.com> <4e5f7d1b-1534-432b-92c1-880c863d79a2@arm.com> In-Reply-To: <4e5f7d1b-1534-432b-92c1-880c863d79a2@arm.com> From: "Rafael J. Wysocki" Date: Wed, 20 Dec 2023 18:44:31 +0100 Message-ID: Subject: Re: [PATCH v2 1/8] thermal: core: Add governor callback for thermal zone change To: Lukasz Luba Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org, rui.zhang@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 20, 2023 at 5:16=E2=80=AFPM Lukasz Luba w= rote: > > > > On 12/20/23 13:51, Rafael J. Wysocki wrote: > > On Tue, Dec 12, 2023 at 2:48=E2=80=AFPM Lukasz Luba wrote: > >> > >> Add a new callback which can update governors when there is a change i= n > >> the thermal zone internals, e.g. thermal cooling instance list changed= . > > > > I would say what struct type the callback is going to be added to. > > OK, I'll add that. > > > > >> That makes possible to move some heavy operations like memory allocati= ons > >> related to the number of cooling instances out of the throttle() callb= ack. > >> > >> Reuse the 'enum thermal_notify_event' and extend it with a new event: > >> THERMAL_INSTANCE_LIST_UPDATE. > > > > I think that this is a bit too low-level (see below). > > Yes, I agree (based on below). > > > > >> Both callback code paths (throttle() and update_tz()) are protected wi= th > >> the same thermal zone lock, which guaranties the consistency. > >> > >> Signed-off-by: Lukasz Luba > >> --- > >> drivers/thermal/thermal_core.c | 13 +++++++++++++ > >> include/linux/thermal.h | 5 +++++ > >> 2 files changed, 18 insertions(+) > >> > >> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_= core.c > >> index 625ba07cbe2f..592c956f6fd5 100644 > >> --- a/drivers/thermal/thermal_core.c > >> +++ b/drivers/thermal/thermal_core.c > >> @@ -314,6 +314,14 @@ static void handle_non_critical_trips(struct ther= mal_zone_device *tz, > >> def_governor->throttle(tz, trip); > >> } > >> > > > > I needed a bit more time to think about this. > > OK. > > > > >> +static void handle_instances_list_update(struct thermal_zone_device *= tz) > >> +{ > >> + if (!tz->governor || !tz->governor->update_tz) > >> + return; > >> + > >> + tz->governor->update_tz(tz, THERMAL_INSTANCE_LIST_UPDATE); > >> +} > > > > So I would call the above something more generic, like > > thermal_governor_update_tz() and I would pass the "reason" argument to > > it. > > That sounds better, I agree. > > > > >> + > >> void thermal_zone_device_critical(struct thermal_zone_device *tz) > >> { > >> /* > >> @@ -723,6 +731,8 @@ int thermal_bind_cdev_to_trip(struct thermal_zone_= device *tz, > >> list_add_tail(&dev->tz_node, &tz->thermal_instances); > >> list_add_tail(&dev->cdev_node, &cdev->thermal_instanc= es); > >> atomic_set(&tz->need_update, 1); > >> + > >> + handle_instances_list_update(tz); > > > > In particular for this, I would use a special "reason" value, like > > THERMAL_TZ_BIND_CDEV. > > > > Yes, the list of instances will change as a result of the binding, but > > that is an internal detail specific to the current implementation. > > I see. With that new more generic thermal_governor_update_tz() would > be better then, right? I think so, IIUC.