From patchwork Mon Dec 14 01:42:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gong X-Patchwork-Id: 67174 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBE1eNKZ022930 for ; Mon, 14 Dec 2009 01:40:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751618AbZLNBkW (ORCPT ); Sun, 13 Dec 2009 20:40:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751520AbZLNBkV (ORCPT ); Sun, 13 Dec 2009 20:40:21 -0500 Received: from mga05.intel.com ([192.55.52.89]:60349 "EHLO fmsmga101.fm.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751081AbZLNBkU (ORCPT ); Sun, 13 Dec 2009 20:40:20 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 13 Dec 2009 17:33:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,391,1257148800"; d="scan'208";a="755753928" Received: from gchen-debian.bj.intel.com ([172.16.182.83]) by fmsmga001.fm.intel.com with ESMTP; 13 Dec 2009 17:40:15 -0800 Received: from gchen by gchen-debian.bj.intel.com with local (Exim 4.69) (envelope-from ) id 1NJzxH-0002vy-V5; Mon, 14 Dec 2009 09:42:31 +0800 From: Chen Gong To: linux-acpi@vger.kernel.org Cc: lenb@kernel.org, Chen Gong Subject: [PATCH 2/2] update mutex usage in aggregator driver Date: Mon, 14 Dec 2009 09:42:29 +0800 Message-Id: <1260754949-11239-3-git-send-email-gong.chen@linux.intel.com> X-Mailer: git-send-email 1.6.5.2.143.g8cc62 In-Reply-To: <1260754949-11239-2-git-send-email-gong.chen@linux.intel.com> References: <1260754949-11239-1-git-send-email-gong.chen@linux.intel.com> <1260754949-11239-2-git-send-email-gong.chen@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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; }