From patchwork Thu Oct 13 12:50:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 2043 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp262010wrs; Thu, 13 Oct 2022 05:58:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5f+xcJDgyYOfDcQbna48Ef3HGikGoiGnrJbP69kqD+jJ/Cd/m2kZuj9kqlLqJp62MUk6fE X-Received: by 2002:a63:34cd:0:b0:460:ea63:c20 with SMTP id b196-20020a6334cd000000b00460ea630c20mr21864280pga.530.1665665904747; Thu, 13 Oct 2022 05:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665665904; cv=none; d=google.com; s=arc-20160816; b=nYyruhDVorX/3woVLlQQVVK6d6DaCKPmaoshwo57Ktqnoch/EbCwza/taBa096XcNX giJAARh9bYJ1Iv4OofmfKLq4CyokV4bGArhtAfAg2fk3V0ppaBq86WJyNN6ZR0cG8oiv qj6UNGxyC4nfV1sLhDzRHxL2OeB2ufo+Qsryu3mZKUB2mIV79QhJnkONscnvkbh6ncDk +iKtZ50U8EG7yRD7NJywR/EZRLdVRaMbm0xJj4+55Wv3zLkf9MTC/JBxK/JqiFJGh9KF byvLscYrhVxYe5dfqyL0x5ee00T/BJ60I7quU1tm7sTrLKvV9u0IxtISPj4GUJgLj1P+ sCGA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j24-20020a62b618000000b00562b0b92756si19797426pff.297.2022.10.13.05.58.11; Thu, 13 Oct 2022 05:58:24 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746577291665798892?= X-GMAIL-MSGID: =?utf-8?q?1746577291665798892?= 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 Reviewed-by: Chen Yu --- 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);