From patchwork Mon Oct 24 11:33:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp640848wru; Mon, 24 Oct 2022 13:33:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Rm/jJjBgkXKso2OqmZAR8lC3MITltxYNH+wX+Ns13iHEZO0jjAv6D14NoqeFSaFtxxPCC X-Received: by 2002:a05:6a00:168e:b0:53b:3f2c:3213 with SMTP id k14-20020a056a00168e00b0053b3f2c3213mr35218321pfc.56.1666643623755; Mon, 24 Oct 2022 13:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643623; cv=none; d=google.com; s=arc-20160816; b=L2BCNIy826sk6XoEWKhqofLj3fdohXPmJ2gKwKYiW+8SBSEtbgS0LN1Qh8d6rAMLmN 7WNE1cT8HeIWAfxOBGGBe72EJQ2LehSlErsGhXA7693P+zeGhzdpYdlIbvS87Cu3f7IT c3V2sOo9BK73ADHU7vmu/oZLsEBqyXnzpGl7MtcANoV1eZSA+ObTAcVNA5JSf9+xbBlU n2nLNu5Z4yI43ZoGBhVOS0wwDsBp4G8LsDkvAVXJRMnZ7joDNoh1wlS4jqdZqqtbLrBc N7s6vckHd3WF7qA2aR23/sm2VoelxA0r4YmoIvMTvtxHJ+ObPHT83zHUBJoavevTcvhT NScg== 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=vs6CA6HZUEE4hdopd+3UrlFv4oKFlsugaK5trybsL7Q=; b=NK3cA1EUFrTyyRQi5AOpeKRg8WnAxG9wMyX7qQy92EXM0/MRjerCsfnhwH29qoh3Kk JI3M9Z6IcSp59dgrEa+A15QSpySM4UXdu9WP1J0iPBamoDTryoK7EdMUkgqThBszcrTK fVzsFO12htw2beM2PAN7+fuLFxb99uuO7aAXlS9h2HiyefzF9SSpW/Vx11ScYcbbPvuR aGRB6bp6W+MhnCe4TC9Jp+b8WkS1bLlVuGEaaibJ09oBi6H/es47/EEdXjmn/xr3XU+X 14DK7pawz6SZVRi2KwmvV5whPqR8cHHSB66ZS5dtVoRYrZjPfXMPh1wFU+NmtFa1Dc5O GGqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=esIBHyrf; 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 j191-20020a6380c8000000b0046afcba3088si457591pgd.735.2022.10.24.13.33.30; Mon, 24 Oct 2022 13:33:43 -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=esIBHyrf; 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 S234216AbiJXUV0 (ORCPT + 99 others); Mon, 24 Oct 2022 16:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234193AbiJXUUx (ORCPT ); Mon, 24 Oct 2022 16:20:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 890C5127BC9; Mon, 24 Oct 2022 11:37:21 -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 ams.source.kernel.org (Postfix) with ESMTPS id 51ABDB81714; Mon, 24 Oct 2022 12:33:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8BCFC433D6; Mon, 24 Oct 2022 12:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614791; bh=AW2HmN9TqaQ00WLNTP/efmBXWbdmYViKnrGlcIbwwjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esIBHyrfZld3/bmDjWGOPPjJel04SBoJ1mA5ByF31/LTD1AyYe/6AMrC2MQkCpBUT MPErjeOjNr8qxF2wBLFTBGirFcHqqD3dXsNcbc9J9BnASou68aB9arPrsQfxQHD0vm 7ZFW7HhL/6wN3gDne55bSGecWp+AzAEzTp35W2Ec= 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 5.10 388/390] thermal: intel_powerclamp: Use first online CPU as control_cpu Date: Mon, 24 Oct 2022 13:33:05 +0200 Message-Id: <20221024113039.490974083@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747602504113490692?= X-GMAIL-MSGID: =?utf-8?q?1747602504113490692?= 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/intel_powerclamp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) --- a/drivers/thermal/intel/intel_powerclamp.c +++ b/drivers/thermal/intel/intel_powerclamp.c @@ -531,11 +531,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);