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 02/12] thermal/x86_pkg_temp: Remove redundant package search
Date: Fri, 18 Nov 2016 00:03:24 -0000 [thread overview]
Message-ID: <20161117234810.028321676@linutronix.de> (raw)
In-Reply-To: 20161117231435.891545908@linutronix.de
[-- Attachment #1: thermal-x86_pkg_temp--Remove-redundant-package-search.patch --]
[-- Type: text/plain, Size: 2023 bytes --]
In pkg_temp_thermal_device_remove() the package device is searched at the
beginning of the function. When the device refcount becomes zero another
search for the same device is conducted. Remove the pointless loop and use
the device pointer which was retrieved at the beginning of the function.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/thermal/x86_pkg_temp_thermal.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
--- a/drivers/thermal/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/x86_pkg_temp_thermal.c
@@ -479,10 +479,8 @@ static int pkg_temp_thermal_device_add(u
static int pkg_temp_thermal_device_remove(unsigned int cpu)
{
- struct phy_dev_entry *n;
+ struct phy_dev_entry *phdev = pkg_temp_thermal_get_phy_entry(cpu);
u16 phys_proc_id = topology_physical_package_id(cpu);
- struct phy_dev_entry *phdev =
- pkg_temp_thermal_get_phy_entry(cpu);
if (!phdev)
return -ENODEV;
@@ -503,22 +501,19 @@ static int pkg_temp_thermal_device_remov
--phdev->ref_cnt;
pr_debug("thermal_device_remove: pkg: %d cpu %d ref_cnt %d\n",
phys_proc_id, cpu, phdev->ref_cnt);
- if (!phdev->ref_cnt)
- list_for_each_entry_safe(phdev, n, &phy_dev_list, list) {
- if (phdev->phys_proc_id == phys_proc_id) {
- thermal_zone_device_unregister(phdev->tzone);
- /*
- * Restore original MSR value for package
- * thermal interrupt.
- */
- wrmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,
- phdev->start_pkg_therm_low,
- phdev->start_pkg_therm_high);
- list_del(&phdev->list);
- kfree(phdev);
- break;
- }
- }
+
+ if (!phdev->ref_cnt) {
+ thermal_zone_device_unregister(phdev->tzone);
+ /*
+ * Restore original MSR value for package thermal
+ * interrupt.
+ */
+ wrmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,
+ phdev->start_pkg_therm_low,
+ phdev->start_pkg_therm_high);
+ list_del(&phdev->list);
+ kfree(phdev);
+ }
mutex_unlock(&phy_dev_list_mutex);
return 0;
next prev parent reply other threads:[~2016-11-18 0:03 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 ` Thomas Gleixner [this message]
2016-11-18 0:03 ` [patch 03/12] thermal/x86_pkg_temp: Replace open coded cpu search Thomas Gleixner
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.028321676@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).