From patchwork Tue Nov 22 17:57:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9441865 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93F6C605EE for ; Tue, 22 Nov 2016 18:03:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B31828448 for ; Tue, 22 Nov 2016 18:03:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8013A285C4; Tue, 22 Nov 2016 18:03:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EA3F285C3 for ; Tue, 22 Nov 2016 18:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933862AbcKVSC6 (ORCPT ); Tue, 22 Nov 2016 13:02:58 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60544 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933688AbcKVSAD (ORCPT ); Tue, 22 Nov 2016 13:00:03 -0500 Received: from localhost ([127.0.0.1] helo=[127.0.1.1]) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1c9FJa-0000Wz-6N; Tue, 22 Nov 2016 18:57:06 +0100 Message-Id: <20161122175357.109909226@linutronix.de> User-Agent: quilt/0.63-1 Date: Tue, 22 Nov 2016 17:57:06 -0000 From: Thomas Gleixner To: LKML Cc: Rui Zhang , edubezval@gmail.com, Peter Zijlstra , Borislav Petkov , linux-pm@vger.kernel.org, x86@kernel.org, rt@linutronix.de, Srinivas Pandruvada Subject: [patch V2 03/12] thermal/x86_pkg_temp: Replace open coded cpu search References: <20161122175256.922158782@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=thermalx86_pkg_temp_Replace_open_coded_cpu_search.patch Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP find_next_sibling() iterates over the online cpus and searches for a cpu with the same package id as the current cpu. This is a pointless exercise as topology_core_cpumask() allows a simple cpumask search for an online cpu on the same package. Signed-off-by: Thomas Gleixner --- drivers/thermal/x86_pkg_temp_thermal.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/thermal/x86_pkg_temp_thermal.c +++ b/drivers/thermal/x86_pkg_temp_thermal.c @@ -384,18 +384,6 @@ static int pkg_temp_thermal_platform_the return 0; } -static int find_siblings_cpu(int cpu) -{ - int i; - int id = topology_physical_package_id(cpu); - - for_each_online_cpu(i) - if (i != cpu && topology_physical_package_id(i) == id) - return i; - - return 0; -} - static int pkg_temp_thermal_device_add(unsigned int cpu) { int err; @@ -488,9 +476,10 @@ static int pkg_temp_thermal_device_remov mutex_lock(&phy_dev_list_mutex); /* If we are loosing the first cpu for this package, we need change */ if (phdev->first_cpu == cpu) { - phdev->first_cpu = find_siblings_cpu(cpu); - pr_debug("thermal_device_remove: first cpu switched %d\n", - phdev->first_cpu); + int target = cpumask_any_but(topology_core_cpumask(cpu), cpu); + + phdev->first_cpu = target; + pr_debug("CPU %d down. New first_cpu%d\n", cpu, target); } /* * It is possible that no siblings left as this was the last cpu