Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp301476lqj; Wed, 10 Apr 2024 10:47:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUNZnhQQ8Og9ZZqTFd57ZjIAJ1L94+iW9Vf9V4L56I+74ltgOvCmuhtHpqApyNXoom6MUJMIV4ik6xnThB5tGfkP1L69gVesfKyDSOArw== X-Google-Smtp-Source: AGHT+IHh/f4ys9pn/p5upGnKj2QVO5la8naM6KP/xR/dWfifiU9bV8ICVR0HssiYwKygQTZ5CDVV X-Received: by 2002:a17:902:cec4:b0:1e0:e8b5:3225 with SMTP id d4-20020a170902cec400b001e0e8b53225mr505693plg.12.1712771256465; Wed, 10 Apr 2024 10:47:36 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f11-20020a170902684b00b001e236f58ea1si10505684pln.204.2024.04.10.10.47.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:47:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139128-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rjwysocki.net header.s=dkim header.b=nxJcMALb; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-139128-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139128-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7485328A98C for ; Wed, 10 Apr 2024 17:46:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFA281836C7; Wed, 10 Apr 2024 17:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="nxJcMALb" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B45BB17F373; Wed, 10 Apr 2024 17:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712771101; cv=none; b=p5Vhfxh6XmSspYfm2NXT90Jp2TSmuXU69o04Sq4suAC6aGSCUKTT8NGhQrDl4h4IKUtPhb8aSY/80Ok1rnqGRpN5s62RmK5ciw2mSsfrNHJ7jZpqdfz/z7eSzUHgTJOd21AAag6nizPSyovaC2j8vMp+MxaVqbzSymH+TNX2SnM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712771101; c=relaxed/simple; bh=KDEZGqVK+a+9HcbLaldc+1MzUP3IHmBDbVJNhkob+mI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iBb+c80+tJpkesX8VLzrAO7tv+/bqGP2gC+Bw6jrUFe0s8C5zydmogTPg/7oA0wVsUPd27lSkuP1pjy5ViqlE7aMpuhr0SIEG/IhXq6REVEH7DWTt46aNn3pLeAmt1EVse+TUpEsHW0DnjlWHC0L0ddx0JAk3VZSdsu7W3Vm/NE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=nxJcMALb reason="signature verification failed"; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id 4e1645a71e206586; Wed, 10 Apr 2024 19:44:49 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 2246966C66F; Wed, 10 Apr 2024 19:44:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1712771089; bh=KDEZGqVK+a+9HcbLaldc+1MzUP3IHmBDbVJNhkob+mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nxJcMALbf6WROrRz3bAx1vRfMFb75Kc4zMov3Kx+YT7G6kw9X4SKEdnjJb6bNZruf 5p3GKHXSsnPUayC8JF5YmAY3bIY3YEEktndEJMYLOyFa9pNXiPZby7UaKAFfR/l5Cn eSKFtOV6o4N0jN7oniTkl3+CjBtc2ADAEksyan1NLCI6Fux+F1Ui52DEaB3iOwOqlE le6mca+QIUBwRxNtg1D/5ZzsDvZ+A5mmCKpWMonLM2LYdWNx8fhfzfxc27N8CnDrNf B8fO8ZSzecmLWzCHn+ZmynZg3WFUtLlyJtJHr3EoYNPS0nEgOIcHot7QyyxYCCZNYb o5qEDxs9yhrxg== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Lukasz Luba , Srinivas Pandruvada Subject: [PATCH v1 14/16] thermal: gov_user_space: Use .trip_crossed() instead of .throttle() Date: Wed, 10 Apr 2024 19:03:10 +0200 Message-ID: <15186663.tv2OnDr8pf@kreacher> In-Reply-To: <13515747.uLZWGnKmhe@kreacher> References: <13515747.uLZWGnKmhe@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedguddugecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepshhr ihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki Notifying user space about trip points that have not been crossed is not particuarly useful, so modity the User Space governor to use the trip_crossed() callback, which is only invoked for trips that have been crossed, instead of .throttle() that is invoked for all trips in a thermal zone every time the zone is updated. Signed-off-by: Rafael J. Wysocki --- Note: I am not actually sure if there is user space depending on the current behavior that can be broken by this change. I can easily imagine trying to implement a complicated governor in user space that will look at all of the trips in the thermal zone regardless of whether or not they are crossed, which can be kind of helped by the current behavior of the user space governor. However, the total overhead caused by it is considerable and quite arguably it may not be acceptable at least in some cases. --- drivers/thermal/gov_user_space.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) Index: linux-pm/drivers/thermal/gov_user_space.c =================================================================== --- linux-pm.orig/drivers/thermal/gov_user_space.c +++ linux-pm/drivers/thermal/gov_user_space.c @@ -26,11 +26,13 @@ static int user_space_bind(struct therma * notify_user_space - Notifies user space about thermal events * @tz: thermal_zone_device * @trip: trip point + * @crossed_up: whether or not the trip has been crossed on the way up * * This function notifies the user space through UEvents. */ -static int notify_user_space(struct thermal_zone_device *tz, - const struct thermal_trip *trip) +static void notify_user_space(struct thermal_zone_device *tz, + const struct thermal_trip *trip, + bool crossed_up) { char *thermal_prop[5]; int i; @@ -46,13 +48,11 @@ static int notify_user_space(struct ther kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop); for (i = 0; i < 4; ++i) kfree(thermal_prop[i]); - - return 0; } static struct thermal_governor thermal_gov_user_space = { .name = "user_space", - .throttle = notify_user_space, + .trip_crossed = notify_user_space, .bind_to_tz = user_space_bind, }; THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);