From patchwork Mon Oct 24 11:31:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp405642wru; Mon, 24 Oct 2022 04:57:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70lcYC20Ca5UndJev/YULtoO/ZgqATX3hZPDZ+WSwsGP3DgpMISgDN7JVKnFWiDC59AYDn X-Received: by 2002:a17:90a:8c8e:b0:202:883b:2644 with SMTP id b14-20020a17090a8c8e00b00202883b2644mr73105728pjo.89.1666612644325; Mon, 24 Oct 2022 04:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612644; cv=none; d=google.com; s=arc-20160816; b=kly3/nRrSFsvn8SHQ1QLGCCED3WzOQ5/PMIOp7HITzTo84cLSMeBvPdGULavJG2+LC am0RmME7T9JWz2A3NNLHRzOZYRGCFzc1/MzvFQGSSshnFnUvz3VNu4tuGm17s5iw/4HT 5D67m/IDS6xcnovlJuybVoVZS/JQK8gX5FP9jLZikm1op6r2HKWcwRaU3gpwd/49dFFt fsjDHMU0uZaeGBEgRUfwEcBRrpqOpC4TcvBhEKKe10hrMipCoq7oj03ee8SH/g7epReq yQmRrB1IzfKOtPBfkNmYeNJbaV2weyiWEN//d51AmkLfWJcZpwLfd4vqIbDQ/xN3Rhqq QkXA== 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=JpkkXNZ7midOyzE1bcQKPW5GsKxAuyADv/2FoRofPYE=; b=PaH3A+mHzSPz3Or/Wvx4QrgasLK1IGe54v5UJ13KoAcuqAcn23v0QCk/uJ4Qwml+As Whh0Uw8ZJqh4TaQEjtP3STckHT2A+9axrDuIGIMe/stwqpOfiGFc/x3heqD0UAHKrWTq uyY8PSetHxh0TtA6tHj5AjFutLImhfJv6RsFPU9OKXj+SPhnQF3cCvw8+MlLyGuQjmaE Vyj38OEaUNRcd4LgSvSeLeS8D0z46rYgTMTNDkgwzY8d7HWIoNQRVa4kk5UHT2o+GXoH ruG5Nu9dc0v9/3xDcE32wUEwPmAmFJgt+yNAZT/Ac1l89YohzciFQA/hiCMsrCUwwD/M RUXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="X1b/xuyX"; 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 v20-20020a17090a459400b0020b127afe7dsi7925603pjg.70.2022.10.24.04.57.11; Mon, 24 Oct 2022 04:57: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="X1b/xuyX"; 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 S232306AbiJXL4r (ORCPT + 99 others); Mon, 24 Oct 2022 07:56:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbiJXLzF (ORCPT ); Mon, 24 Oct 2022 07:55:05 -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 1299279693; Mon, 24 Oct 2022 04:46:20 -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 4C04061257; Mon, 24 Oct 2022 11:45:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60D9EC433D7; Mon, 24 Oct 2022 11:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611909; bh=UfvIfSLODXePD49Dd2Op7D60wEFjswYaD9hDwYKdrLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X1b/xuyX2qeIdyN8SFUUU8a4kHPJl7WkkOMMJRtXUCvqnLhX/98Z3FfZNn2LxWi7K m9T1xPJ7J5fR5CnhnPQng59zxkU9BwhngR/zFKNvOuqzo/R7Ys6S8tp/IFpHXgC176 qI2Q0KI57AcSD3g1/xauABrrtXbSQ0gv5+zGsHRA= 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.9 158/159] thermal: intel_powerclamp: Use first online CPU as control_cpu Date: Mon, 24 Oct 2022 13:31:52 +0200 Message-Id: <20221024112955.194790075@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747570020066342687?= X-GMAIL-MSGID: =?utf-8?q?1747570020066342687?= 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 @@ -518,11 +518,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);