From patchwork Fri Nov 18 00:03:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9435509 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 BE35B60469 for ; Fri, 18 Nov 2016 00:06:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF186296F5 for ; Fri, 18 Nov 2016 00:06:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3D7E2970B; Fri, 18 Nov 2016 00:06:10 +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 35A70296F5 for ; Fri, 18 Nov 2016 00:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751243AbcKRAGJ (ORCPT ); Thu, 17 Nov 2016 19:06:09 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:50316 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751359AbcKRAGF (ORCPT ); Thu, 17 Nov 2016 19:06:05 -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 1c7WeX-0000ed-JF; Fri, 18 Nov 2016 01:03:37 +0100 Message-Id: <20161117234810.113102580@linutronix.de> User-Agent: quilt/0.63-1 Date: Fri, 18 Nov 2016 00:03:25 -0000 From: Thomas Gleixner To: LKML Cc: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, Peter Zijlstra , x86@kernel.org, rt@linutronix.de, Borislav Petkov Subject: [patch 03/12] thermal/x86_pkg_temp: Replace open coded cpu search References: <20161117231435.891545908@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=thermal-x86_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