Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4822650rwl; Tue, 28 Mar 2023 11:46:14 -0700 (PDT) X-Google-Smtp-Source: AK7set+k9hF2NI6gdv9+QXxFrENG2+Pk3Q+pju3K+CfbIDyeH6ebLNrkt6GNjyPqxS9lhu40PmsF X-Received: by 2002:a05:6a20:b057:b0:da:f073:1f1c with SMTP id dx23-20020a056a20b05700b000daf0731f1cmr13272660pzb.9.1680029173931; Tue, 28 Mar 2023 11:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680029173; cv=none; d=google.com; s=arc-20160816; b=k1DBq7SUKOFE3CVIJRERlqdQAZIBxZZWDZLOExkfpOVL5uQkvt59/4wGLd0UWXddFM 8G29HWthQPmCWvklZSEc/5gi/Ig3PO18TN/osNFh352lTL0FZGMbuqP/FwJFxgxAQgD9 vAsSjJOdaTVc9guf8LIKgNx0RcfRiIRd8OIjVe3MTshbi7/vtMmnvwI6BVzZjBtJFKew JgPDGtJ521GxSEEMgXSKVt1iSY9lZ67PBQ6gHMljVWRhd3G8eymcQ46ffgaUDON8qW45 ylzmUcz3Au5rsWyQMGEUUSKyFwiM2xv/zeg/lsGa5sMjYxfqjDipYdS5OIFlCJDdvLOl uwzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=oUnis0I9DCkHTuAl/kjVGkuf8nMmUFvnmkkIa8OSLQo=; b=ytEU8HnMRpbzQhT89h0hMr+MBSm0AjFc4DJu/hkGV/D1+rLMm+k4XHM4lA9mpdxMlv BlvfliQotbXUzKEGTy1YlAShEywP5qE6ypNMQ65jbuHqZ0IYF17e39yQyulSSJFuplf0 wO5E5nj0jXMB+Oy8bg6K5/751FLNW4qN+4bOStu1qm13jtpUri6wjNFhZgn1FkZVs7X2 fGb8ft53qMyjmA+n/uHF0JHzH9k6znUHjK4zU/t1TIUdAGbqDIX0i9MV0bO5vhVjun55 7+SUJmBOUieE+4w8LFO74ifOuOa7uKLOHcTxh1CJNcM9Qipa4k3xpFNMC+Ep4UOdrJ7z icvg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fb19-20020a056a002d9300b00625637c1699si30968168pfb.34.2023.03.28.11.46.02; Tue, 28 Mar 2023 11:46:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbjC1Snz (ORCPT + 99 others); Tue, 28 Mar 2023 14:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjC1Sny (ORCPT ); Tue, 28 Mar 2023 14:43:54 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E402121; Tue, 28 Mar 2023 11:43:30 -0700 (PDT) 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 5.1.0) id 81b377ba140dd037; Tue, 28 Mar 2023 20:43:28 +0200 Received: from kreacher.localnet (unknown [213.134.169.43]) (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 v370.home.net.pl (Postfix) with ESMTPSA id 72F1578215F; Tue, 28 Mar 2023 20:43:27 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Zhang Rui , Daniel Lezcano , Imre Deak , Linux ACPI Subject: [PATCH v1] thermal: core: Drop excessive lockdep_assert_held() calls Date: Tue, 28 Mar 2023 20:43:26 +0200 Message-ID: <2681615.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.169.43 X-CLIENT-HOSTNAME: 213.134.169.43 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehgedguddvkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeegfffhudejlefhtdegffekteduhfethffhieettefhkeevgfdvgfefieekiefgheenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppedvudefrddufeegrdduieelrdegfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieelrdegfedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehl ihhnrghrohdrohhrghdprhgtphhtthhopehimhhrvgdruggvrghksehinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 From: Rafael J. Wysocki The lockdep_assert_held() calls added to cooling_device_stats_setup() and cooling_device_stats_destroy() by commit 790930f44289 ("thermal: core: Introduce thermal_cooling_device_update()") trigger false-positive lockdep reports in code paths that are not subject to race conditions (before cooling device registration and after cooling device removal). For this reason, remove the lockdep_assert_held() calls from both cooling_device_stats_setup() and cooling_device_stats_destroy() and add one to thermal_cooling_device_stats_reinit() that has to be called under the cdev lock. Fixes: 790930f44289 ("thermal: core: Introduce thermal_cooling_device_update()") Link: https://lore.kernel.org/linux-acpi/ZCIDTLFt27Ei7+V6@ideak-desk.fi.intel.com Reported-by: Imre Deak Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_sysfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) Index: linux-pm/drivers/thermal/thermal_sysfs.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_sysfs.c +++ linux-pm/drivers/thermal/thermal_sysfs.c @@ -876,8 +876,6 @@ static void cooling_device_stats_setup(s unsigned long states = cdev->max_state + 1; int var; - lockdep_assert_held(&cdev->lock); - var = sizeof(*stats); var += sizeof(*stats->time_in_state) * states; var += sizeof(*stats->trans_table) * states * states; @@ -903,8 +901,6 @@ out: static void cooling_device_stats_destroy(struct thermal_cooling_device *cdev) { - lockdep_assert_held(&cdev->lock); - kfree(cdev->stats); cdev->stats = NULL; } @@ -931,6 +927,8 @@ void thermal_cooling_device_destroy_sysf void thermal_cooling_device_stats_reinit(struct thermal_cooling_device *cdev) { + lockdep_assert_held(&cdev->lock); + cooling_device_stats_destroy(cdev); cooling_device_stats_setup(cdev); }