From patchwork Mon Oct 24 11:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp392614wru; Mon, 24 Oct 2022 04:35:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sZXowRq54OGxbBO72Zr7f6912FQZWaRYkm/SeUD9o6Ia0y9E4tZ7qQNnpLCpqnoZU4xLa X-Received: by 2002:aa7:cd61:0:b0:461:de5e:ba3b with SMTP id ca1-20020aa7cd61000000b00461de5eba3bmr2270726edb.74.1666611342763; Mon, 24 Oct 2022 04:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666611342; cv=none; d=google.com; s=arc-20160816; b=ByTZq/DGzbsFbM6u8/X+yAKjW7lIfHO9eG2+rb4LsvqEwn82SO/HoW1r/FH/4XNHxp 7Qe92dUfPKL1XkOtFqUE++K/wDx7R+444UxM2VGcYl+V47MnqWxtq+BGfJJLq3X8pan2 7/MK+cafCy8QDjNwnxTfJkOWElolYJWlFGACwwozknNlTHlzM/UnIiU2wi3fmbMRigyz mJWIQoCsj5SYrFh8ENEAezv4f05OxVP25v+Ip9ZYDZbS04F2EWhWZqZuFqAosV2QqHJe EJvTRzrPZhgy/oVjDkjNVTZ3pgkX2mwT4eeMMvlW+30D9C4BgulNjUQ2/1M+8kM5HAS4 3lBA== 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=dq3XG/a/CLvH3FYJFfhp+ezWONPbYji/+vU5WI6WYyU=; b=SHKsrwSr5fWKCLsQAvJryEfOwqrbUEGr5V9WzIbI7XKWcuPx9pA7dkVYt1MeqYr4T7 /go3xdeeV994Ryf/TEGnmMoqItF/IElaGOZLTS9TQOuvNNc2OBxCWCVlAy0OA3RHB0ny afc9xDU6KjtDSuZtubk5WEb35tyhg2OhF2rcgt0aWLzIB1jTJTEANYbpFo/vX1vynO7K 7NQd9N9+Q0ZZ50MLGTQmu4JooZ78MpwGH+NBHNoTMIt8BteElMBOqMAJWRVgjq3KGtR3 ulQyYucOTzy1Qex67dB17YyXk0IDBZK1HUmHh3FnZlNS/5gUx9xU9VPbEh/DNXdqorXU /4uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MDWNg7ap; 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 k25-20020aa7c059000000b0044f1b7b8713si24146549edo.281.2022.10.24.04.35.18; Mon, 24 Oct 2022 04:35:42 -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=MDWNg7ap; 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 S230236AbiJXLdF (ORCPT + 99 others); Mon, 24 Oct 2022 07:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbiJXLcg (ORCPT ); Mon, 24 Oct 2022 07:32:36 -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 AFABD6068F; Mon, 24 Oct 2022 04:32:19 -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 B1AE161251; Mon, 24 Oct 2022 11:32:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8121C433D6; Mon, 24 Oct 2022 11:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611137; bh=nInlbStH9a5FQ1hxPfb1aIWblv3RMo5lp/f/c/5RMyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDWNg7apRfJPOnTX6yzSJszcqk5EkYrL+IQ4lrRsmrxO1HwPdT4eK/VFBt6/1BoBw QN6c1Y9oSaS62mpPmpO2rlWJAopO2GEVleE0o4qPcBXdxt916lZDOEUSTE20dS3ddC syXZRCV4nP7/EpUhvRT7wCBRPROogjsiscHkaR2g= 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 6.0 04/20] thermal: intel_powerclamp: Use first online CPU as control_cpu Date: Mon, 24 Oct 2022 13:31:06 +0200 Message-Id: <20221024112934.600700322@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112934.415391158@linuxfoundation.org> References: <20221024112934.415391158@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?1747568655279769275?= X-GMAIL-MSGID: =?utf-8?q?1747568655279769275?= 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) 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);