From patchwork Mon Oct 24 11:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp433303wru; Mon, 24 Oct 2022 05:49:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6e2XkiDZfxGA9plz3yo1CXltmEI4MZ/9XsjqCA3njBtZQnl9DtD2z075VLYcAOM4pg0oLB X-Received: by 2002:a17:90a:8504:b0:212:c1f4:ddf1 with SMTP id l4-20020a17090a850400b00212c1f4ddf1mr23798574pjn.224.1666615733877; Mon, 24 Oct 2022 05:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615733; cv=none; d=google.com; s=arc-20160816; b=Blohg5hOjSMkCV5xVo2kxGCCdGP5mgRbvZcPe4oz6iGoJXJQsOShP8JSWA0S+ybWf2 mPAJnmvCXZKSCDqfr9rigxA1iK/3owkEyWnpN0bE8WszLfRTeQi0AlqP1kOp2P3NlS77 0I5AexCLGK0pT/XkOVSOKDmKyTs0JfUhtbq42KqhY8D3py92HLyDI9u3d1qZZ9KVmhs2 IoxsWQNma14d7M8JU+6X1QXnRb9PImJjPcufWGoR+jmrtdKzCFJ6LLi6+Nht/UVJLjal czr4Pwp1cZnrtL/CLYW0SR4a3xjMqw5K7BSwptq8vgjoCkjM+2QBJqodS4/iJj/7nxFw 1Xnw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NGQPDhb7x7+wydTtcZFehZh80yJnk0tehq4AXLIshBE=; b=RzGUjW+gH5xGYLvZCZeBd0ZCIAJAM3t+oJNweY884hAmSbPruVnhqu1MJik7hjYcg/ pFVeToeXIiQ4/V+Jff537iBpCU2NpLjzriFobvzG3fZPqdV9trwjMWT/EulJPT2SHHo+ WN2o8nQI/FG/E2gKzUN6NAQpb4nfyezZelc6hH8hkacosHJ0HiNcaRS74fwGbW5eiiZe ZWHCnOP3btrIZZKuUNBoQ3/o2KuWO+BLa1wCtW5Zsj9ufsMBAVXgiUf49BwlvGkS1GCc 0c/NdP2Dm2BNQ6OOTzYXu9WsePFZ+WMQQbe18Bo+eaApSlUVI2h+l8N1LOMseAFFFbp0 +DjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xKjBEAbk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k62-20020a17090a4cc400b00212d5631badsi8223350pjh.55.2022.10.24.05.48.39; Mon, 24 Oct 2022 05:48:53 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xKjBEAbk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234201AbiJXMmT (ORCPT + 99 others); Mon, 24 Oct 2022 08:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234276AbiJXMjX (ORCPT ); Mon, 24 Oct 2022 08:39:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659958B2C0; Mon, 24 Oct 2022 05:07:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A5DB46128E; Mon, 24 Oct 2022 12:04:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8B3BC433C1; Mon, 24 Oct 2022 12:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613072; bh=jUlYH+CCO+C1GozJgPk99oAfl+QuIg9M6++iiseMq9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xKjBEAbkIafJ/5IzASvz7RZbb6Ri1ddILtXgv61ynTSUADUtElmhTPWDnnh7cg/gJ J/2GY9gblUw3EXXWnmGtlGCLA68wtyZReKSFogLQTW/Fx6w3w+n+T9JdMOGM0MKk1h oaYx2XPWAejI4A6S7Q2aSdeDTlm3faPTPAHFjA7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Chen Yu Subject: [PATCH 4.19 228/229] thermal: intel_powerclamp: Use first online CPU as control_cpu Date: Mon, 24 Oct 2022 13:32:27 +0200 Message-Id: <20221024113006.655375423@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1747573259651921793?= X-GMAIL-MSGID: =?utf-8?q?1747573259651921793?= From: Rafael J. Wysocki commit 4bb7f6c2781e46fc5bd00475a66df2ea30ef330d upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/intel_powerclamp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) --- a/drivers/thermal/intel_powerclamp.c +++ b/drivers/thermal/intel_powerclamp.c @@ -549,11 +549,7 @@ static int start_power_clamp(void) get_online_cpus(); /* 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);