linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	linux-pm@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org, rt@linutronix.de, Borislav Petkov <bp@alien8.de>
Subject: [patch 03/12] thermal/x86_pkg_temp: Replace open coded cpu search
Date: Fri, 18 Nov 2016 00:03:25 -0000	[thread overview]
Message-ID: <20161117234810.113102580@linutronix.de> (raw)
In-Reply-To: 20161117231435.891545908@linutronix.de

[-- Attachment #1: thermal-x86_pkg_temp--Replace-open-coded-cpu-search.patch --]
[-- Type: text/plain, Size: 1446 bytes --]

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 <tglx@linutronix.de>
---
 drivers/thermal/x86_pkg_temp_thermal.c |   19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

--- 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



  parent reply	other threads:[~2016-11-18  0:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18  0:03 [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another hotplug and locking trainwreck Thomas Gleixner
2016-11-18  0:03 ` [patch 01/12] thermal/x86_pkg_temp: Cleanup thermal interrupt handling Thomas Gleixner
2016-11-18  0:03 ` [patch 02/12] thermal/x86_pkg_temp: Remove redundant package search Thomas Gleixner
2016-11-18  0:03 ` Thomas Gleixner [this message]
2016-11-18  0:03 ` [patch 04/12] thermal/x86_pkg_temp: Sanitize callback (de)initialization Thomas Gleixner
2016-11-18  0:03 ` [patch 05/12] thermal/x86_pkg_temp: Get rid of ref counting Thomas Gleixner
2016-11-18  0:03 ` [patch 06/12] thermal/x86_pkg_temp: Cleanup namespace Thomas Gleixner
2016-11-18  0:03 ` [patch 07/12] thermal/x86_pkg_temp: Cleanup code some more Thomas Gleixner
2016-11-18  0:03 ` [patch 08/12] thermal/x86_pkg_temp: Sanitize locking Thomas Gleixner
2016-11-18  0:03 ` [patch 09/12] thermal/x86_pkg_temp: Move work scheduled flag into package struct Thomas Gleixner
2016-11-18  0:03 ` [patch 10/12] thermal/x86_pkg_temp: Move work " Thomas Gleixner
2016-11-18  0:03 ` [patch 11/12] thermal/x86_pkg_temp: Sanitize package management Thomas Gleixner
2016-11-18  0:03 ` [patch 12/12] thermal/x86 pkg temp: Convert to hotplug state machine Thomas Gleixner
2016-11-21 20:02 ` [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another hotplug and locking trainwreck Pandruvada, Srinivas
2016-11-21 21:34   ` Thomas Gleixner
2016-11-21 23:16     ` Pandruvada, Srinivas
2016-11-22  9:05       ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161117234810.113102580@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=bp@alien8.de \
    --cc=edubezval@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rt@linutronix.de \
    --cc=rui.zhang@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).