From patchwork Mon Oct 24 11:32:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp439329wru; Mon, 24 Oct 2022 06:02:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5MyCCYt37oCBc9eJmzZxJDsXuQUX4SxiiINJwF9k6jCX1Ye1W542nSxk1+rwDfh/8Ac0q8 X-Received: by 2002:a63:3fce:0:b0:45a:2bab:6002 with SMTP id m197-20020a633fce000000b0045a2bab6002mr28608992pga.454.1666616550686; Mon, 24 Oct 2022 06:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616549; cv=none; d=google.com; s=arc-20160816; b=JcB+dcUYVPDaLRti8VfYScu/klkuZfhqSZho8GYDFQrMrndivDpDMtprw/9nhgQkJ2 1DWS833gTN7qnfpP4LipwIra6Awcztlm3Gq8v2EG2Q8dTKGhMvd0gJvlKxLCaOdsv1XM CduET8yFTQSHgOOiLf7HYAKeIchjGW6qy4UQn6lgXoic7jqtQgjBuQ7Bx74bV2fqCxdI RILtdU4DHMYo2hIGh7gkzBWy2mWebg8EqgK/E+8DQkbflEig3k4TotbXM+4BNgywqAsz y8HsEO0qigBL5QsOD5dySA43m5tRtSCV8bvU6qHRiYAG+vEO9tJh9joJVXxeTWQso1jf tbZA== 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=9QCAc8H4Hq68qOimb31vQi6yMxlzTI0DGahLnJFfsKE=; b=b2ogjO6rXZ+d5SCKtsRJiqYp/CBcGTY0YSxkwmJmd9/jOYx4AH0ckbyqp9u3XPL2o/ JPBeGEcPdo8Lxk3NCkZJntDKA5jId6Ttpy9f+GGpycPGwSbECfDw+nQmxDjd1zhwgqcT cjuS2FZgHjeDzufRkJ0WUWKRHxTVnAdSqXwGuhYCCVGwyk9zUe4geAfQmet1wyLfEbDz mbD6508w7t9pb4mvIuRqDgnwitIe6IvrQEEi650xIKgT7+P6nV5BTkd2z6jQgBcYjtK6 xp69S0MdDz4AsdIwkjnwVwFDUGpoXodYBIvmT3Qb9DhfJ1+yswZJ0K9hXjugFCIUF1ac SK/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YdhWwyET; 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 my15-20020a17090b4c8f00b0020d67a4e6fasi17878352pjb.174.2022.10.24.06.01.52; Mon, 24 Oct 2022 06:02:29 -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=YdhWwyET; 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 S235024AbiJXNBE (ORCPT + 99 others); Mon, 24 Oct 2022 09:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234930AbiJXM65 (ORCPT ); Mon, 24 Oct 2022 08:58:57 -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 A0B2C9A28C; Mon, 24 Oct 2022 05:18:02 -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 22BF761331; Mon, 24 Oct 2022 12:16:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38ED3C433C1; Mon, 24 Oct 2022 12:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613768; bh=iCYA+WieLEMO+7AeFrJuB0qA6FIj092/MecmdHKQVTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdhWwyETYg5Cy53QM7Bp/YWZFi8YkRym/pLlqiPhhMTC8XekVXi31GWMgSqZ03vg/ /6SpQWZ/dmNOAikTzKO75xa08kHGPf5Bymw00mCx/lxOztFz5YyrCy8YUnC2iiQC0P uSEYW7L7htVWG5g0PhN45r8BQRNmOVNCbLAaUjfc= 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.4 255/255] thermal: intel_powerclamp: Use first online CPU as control_cpu Date: Mon, 24 Oct 2022 13:32:45 +0200 Message-Id: <20221024113011.807775089@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747574114996389254?= X-GMAIL-MSGID: =?utf-8?q?1747574114996389254?= 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 @@ -534,11 +534,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);