public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Gong <gong.chen@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: lenb@kernel.org, Chen Gong <gong.chen@linux.intel.com>
Subject: [PATCH 2/2] update mutex usage in aggregator driver
Date: Mon, 14 Dec 2009 09:42:29 +0800	[thread overview]
Message-ID: <1260754949-11239-3-git-send-email-gong.chen@linux.intel.com> (raw)
In-Reply-To: <1260754949-11239-2-git-send-email-gong.chen@linux.intel.com>

I have 2 issues.
 1. I consider thread creation and RR thread execution don't share the
global data, so the serialization execution is not necessary. It is
enough to use another different mutex to lock thread exectuion itself
when these threads running concurrently.
 2. part of sysfs interfaces doesn't need to own mutex with thread createion.
Though some data maybe are not identical, it is not a big deal.

Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
---
 drivers/acpi/acpi_pad.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index a7bd49f..ceb8270 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -34,6 +34,7 @@
 #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
 #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
 static DEFINE_MUTEX(isolated_cpus_lock);
+static DEFINE_MUTEX(isolated_thread_lock);
 
 #define MWAIT_SUBSTATE_MASK	(0xf)
 #define MWAIT_CSTATE_MASK	(0xf)
@@ -105,7 +106,6 @@ static void round_robin_cpu(unsigned int tsk_index)
 	if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
 		return;
 
-	mutex_lock(&isolated_cpus_lock);
 	cpumask_clear(tmp);
 	for_each_cpu(cpu, pad_busy_cpus)
 		cpumask_or(tmp, tmp, topology_thread_cpumask(cpu));
@@ -113,10 +113,10 @@ static void round_robin_cpu(unsigned int tsk_index)
 	/* avoid HT sibilings if possible */
 	if (cpumask_empty(tmp))
 		cpumask_andnot(tmp, cpu_online_mask, pad_busy_cpus);
-	if (cpumask_empty(tmp)) {
-		mutex_unlock(&isolated_cpus_lock);
+	if (cpumask_empty(tmp))
 		return;
-	}
+
+	mutex_lock(&isolated_thread_lock);
 	for_each_cpu(cpu, tmp) {
 		if (cpu_weight[cpu] < min_weight) {
 			min_weight = cpu_weight[cpu];
@@ -129,7 +129,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 	tsk_in_cpu[tsk_index] = preferred_cpu;
 	cpumask_set_cpu(preferred_cpu, pad_busy_cpus);
 	cpu_weight[preferred_cpu]++;
-	mutex_unlock(&isolated_cpus_lock);
+	mutex_unlock(&isolated_thread_lock);
 
 	set_cpus_allowed_ptr(current, cpumask_of(preferred_cpu));
 }
@@ -280,9 +280,7 @@ static ssize_t acpi_pad_rrtime_store(struct device *dev,
 		return -EINVAL;
 	if (num < 1 || num >= 100)
 		return -EINVAL;
-	mutex_lock(&isolated_cpus_lock);
 	round_robin_time = num;
-	mutex_unlock(&isolated_cpus_lock);
 	return count;
 }
 
@@ -303,9 +301,7 @@ static ssize_t acpi_pad_idlepct_store(struct device *dev,
 		return -EINVAL;
 	if (num < 1 || num >= 100)
 		return -EINVAL;
-	mutex_lock(&isolated_cpus_lock);
 	idle_pct = num;
-	mutex_unlock(&isolated_cpus_lock);
 	return count;
 }
 
-- 
1.6.5.2.143.g8cc62


  reply	other threads:[~2009-12-14  1:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-14  1:42 [PATCH 0/2] aggregator device driver update Chen Gong
2009-12-14  1:42 ` [PATCH 1/2] fix some errors in aggregator device driver Chen Gong
2009-12-14  1:42   ` Chen Gong [this message]
2009-12-17  0:54     ` [PATCH 2/2] update mutex usage in aggregator driver Shaohua Li
2009-12-17  4:52       ` chen gong
2009-12-16  4:00 ` [PATCH 0/2] aggregator device driver update Len Brown

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=1260754949-11239-3-git-send-email-gong.chen@linux.intel.com \
    --to=gong.chen@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.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