From patchwork Tue Mar 28 18:43:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 76227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2443240vqo; Tue, 28 Mar 2023 12:06:52 -0700 (PDT) X-Google-Smtp-Source: AKy350aRplLMVVLGu4Cbww+C+WvyT3FZcyf8Q00cCp++Ah/mwBwWetukbtwDeZP/OiI7Vz3Gn2co X-Received: by 2002:a17:90a:52:b0:23d:9a3:f571 with SMTP id 18-20020a17090a005200b0023d09a3f571mr17990371pjb.20.1680030411809; Tue, 28 Mar 2023 12:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680030411; cv=none; d=google.com; s=arc-20160816; b=utLDVgYr8sxvC9D2JqyVK6QddooFfYYOEDk6fX2bU3MSb3L8BnqGDPN1+q2mhmFpPn 5x8XP8xU777bh0GV3/xjM6Wj0VE2FT7S9PHLUarFcFr7/PzWy1k0tZ2RPMVg9nkGjXqh Jh8b5m9ulW9lMzo+Fiv6hsDMiyU4/G5SgZ3plKbXgP+ffpSXYSLrbY5x3k4pJMVDrR3X Uu0zEMDIBXWWmRw+EIEEZemm777Aw54aZvjkkQ58H+HsRU/a0FYkmBwIHkr1t8LS5n3F 6P0ZsBl0wGHgTh5zy5rt9YNRRLDa+MIuSeZFL2NcTohemcv31mLGMrYkHC0Je+vMQljM n1xg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t22-20020a17090aba9600b0023f58e27405si8905039pjr.32.2023.03.28.12.06.39; Tue, 28 Mar 2023 12:06:51 -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 S229844AbjC1Snz (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761639569111982908?= X-GMAIL-MSGID: =?utf-8?q?1761639569111982908?= 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); }