Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp834708rwi; Thu, 13 Oct 2022 06:01:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jptUQw+Vydto/of2aMiLfc19b7vktJxwecN7/OgCalzQhey+SXOTTjWZ2bS3bK7LAocEG X-Received: by 2002:a17:907:2712:b0:78d:a223:729b with SMTP id w18-20020a170907271200b0078da223729bmr18722761ejk.443.1665666070790; Thu, 13 Oct 2022 06:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665666070; cv=none; d=google.com; s=arc-20160816; b=Xd3vig31p/2xih5WSqMs2QAxE8CmC0Shlu+wm7SxWJTEaBkB5oILP9LV9Jan3gi5lp uEhUp9FEHBRer+weEVLqlUmK75peCDhJiHqVPxDqx4ebkG4Y7DPFi3MIGI2EEoUlZQ+K aZIIA9PlqSAbSUGqG7aZIqz0vJcGGYSe7QsQLZWNpHQvkS+dtIj9rOEFRpzslYoPNHg5 IcJavkCICcp+IA/8lhkFjfxXA3wqAkgLMlTnXhmvHft4UJxoj96fPj7qd9OvN2laSCZO teRmKY7hYIJuF2kNBi5SQbC+ws24U1GNQe3Cx7SQXkXtr/w3Whs38UKRWrA4CtZ7cQ0U xg2Q== 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=8NBFDV7vltSyFiDc+cim2NpYoaAsjQGohlf3BQLXnQE=; b=DIWI5hVdezOzLZGAtoL+D6OZc0D+I3+qkgrR/5oDwXUCtKrtFZv52nTGKxJue9QcGV tzIspcgFIr6zsdfO04jA9A0Bw1l0wEZ9qng4lZWW/cI8cSIjNBCiWhllJnxlqRVPug6I Rs+7I7s/lBA6n6Ig2IeI4AHbkaptSc5lOh1+wqmwqh1a8SBTYY9uKV93i56xbSwIyREx +FYGFWQV4oRAy4Vrc9mafCrXfylrimDBVDHGl2X/A91GnvmH+IPSB/bFhvfB2WohW0OL iW3U+uC0x9MwocRvlWzuQuq66wqz4HUdPY/bbWN0BFgVje1u9i/2jxyA9zEuXHQMi1Hf BNVw== 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 c24-20020a17090603d800b00779a3220c5asi14342527eja.343.2022.10.13.06.00.43; Thu, 13 Oct 2022 06:01:10 -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 S229567AbiJMMug (ORCPT + 99 others); Thu, 13 Oct 2022 08:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiJMMue (ORCPT ); Thu, 13 Oct 2022 08:50:34 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C6220181; Thu, 13 Oct 2022 05:50:32 -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.0.0) id 9bd3522237f0ea1e; Thu, 13 Oct 2022 14:50:30 +0200 Received: from kreacher.localnet (unknown [213.134.183.5]) (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 8BF6B6667B9; Thu, 13 Oct 2022 14:50:29 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: Bjorn Helgaas , Chen Yu , Srinivas Pandruvada , LKML , Jacob Pan , Pavel Machek Subject: [PATCH] thermal: intel_powerclamp: Use first online CPU as control_cpu Date: Thu, 13 Oct 2022 14:50:28 +0200 Message-ID: <5633735.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.183.5 X-CLIENT-HOSTNAME: 213.134.183.5 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgheelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepgeffhfdujeelhfdtgeffkeetudfhtefhhfeiteethfekvefgvdfgfeeikeeigfehnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepvddufedrudefgedrudekfedrheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukeefrdehpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhgvlhhgrggrsheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohephihurdgtrdgthhgvnhesihhnthgvlhdrtghomhdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhht vghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhgrtghosgdrjhhunhdrphgrnheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehprghvvghlsehutgifrdgtii X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 Commit 68b99e94a4a2 ("thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash") fixed an issue related to using smp_processor_id() in preemptible context by replacing it with a pair of get_cpu()/put_cpu(), but what is needed there really is any online CPU and not necessarily the one currently running the code. Arguably, getting the one that's running the code in there is confusing. For this reason, simply give the control CPU role to the first online one which automatically will be CPU0 if it is online, so one check can be dropped from the code for an added benefit. Link: https://lore.kernel.org/linux-pm/20221011113646.GA12080@duo.ucw.cz/ Fixes: 68b99e94a4a2 ("thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash") Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/intel_powerclamp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) Index: linux-pm/drivers/thermal/intel/intel_powerclamp.c =================================================================== --- linux-pm.orig/drivers/thermal/intel/intel_powerclamp.c +++ linux-pm/drivers/thermal/intel/intel_powerclamp.c @@ -516,11 +516,7 @@ static int start_power_clamp(void) cpus_read_lock(); /* prefer BSP */ - control_cpu = 0; - if (!cpu_online(control_cpu)) { - control_cpu = get_cpu(); - put_cpu(); - } + control_cpu = cpumask_first(cpu_online_mask); clamping = true; schedule_delayed_work(&poll_pkg_cstate_work, 0);