From patchwork Sun Nov 4 15:24:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1694561 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AA0A73FD2B for ; Sun, 4 Nov 2012 15:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755247Ab2KDPZI (ORCPT ); Sun, 4 Nov 2012 10:25:08 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:52244 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754918Ab2KDPZD (ORCPT ); Sun, 4 Nov 2012 10:25:03 -0500 Received: by mail-pa0-f46.google.com with SMTP id hz1so3385889pad.19 for ; Sun, 04 Nov 2012 07:25:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=qXBdp7y/CzdYQB44cp5cKDdy9vX8FaDbURuB/6L3x3U=; b=vqNPFrYdpwB6ibNj960YYrfLsvrWi0xr3Ok1UmZkSjqUc7v51T0V3VJGdk+1DOTDFH /DA9yl414HUXpOqKFI7HVgIliSlUlEuOCFx25gT4R21piC7MwRi0QHQbdnk9N2tLZREE MqLz9humYSwq1X448BqObt+hwK4R8wqAmHep9qs1snd+D82Pd2ETJJXqD3LrUXUA2wSB OZ+K28U5ZW2wQsNOB1mSR3x+9GqkLetusPEqtWroV0KjvetC/l64DbOd6FANh2aSnLFM Z9fFvtUib0OdRM5g/Qi9BWh3qh4iqR4j7DU8KA2p+T1hMB7J7nOK4LPxoeb2fUzywBc+ ZGqw== Received: by 10.68.189.8 with SMTP id ge8mr23394897pbc.24.1352042702833; Sun, 04 Nov 2012 07:25:02 -0800 (PST) Received: from localhost.localdomain ([120.196.98.117]) by mx.google.com with ESMTPS id nd6sm9020763pbc.68.2012.11.04.07.24.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Nov 2012 07:25:02 -0800 (PST) From: Jiang Liu To: "Rafael J . Wysocki" , Yinghai Lu , Tony Luck , Yasuaki Ishimatsu , Wen Congyang , Tang Chen , Taku Izumi , Bjorn Helgaas Cc: Jiang Liu , Kenji Kaneshige , Huang Ying , Bob Moore , Len Brown , "Srivatsa S . Bhat" , Yijing Wang , Hanjun Guo , Jiang Liu , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Subject: [ACPIHP PATCH part4 8/9] ACPI/processor: serialize call to acpi_map/unmap_lsapic Date: Sun, 4 Nov 2012 23:24:01 +0800 Message-Id: <1352042642-7306-9-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> References: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Function acpi_map_lsapic() is used to allocate CPU id for hot-added CPUs and acpi_unmap_lsapic() is used to free CPU id for hot-removed CPUs. But currently there's no mechanism to serialze the CPU id allocation/free process, which may cause wrong CPU id assignment when handling concurrent CPU online/offline operations. So introuce a mutex to serialize CPU id allocation/free. Signed-off-by: Jiang Liu --- drivers/acpi/processor_driver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 9a02210..6dbce2f 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -108,6 +108,7 @@ static struct acpi_driver acpi_processor_driver = { .drv.pm = &acpi_processor_pm, }; +static DEFINE_MUTEX(acpi_processor_mutex); static DEFINE_PER_CPU(void *, processor_device_array); DEFINE_PER_CPU(struct acpi_processor *, processors); @@ -668,7 +669,9 @@ static void acpi_processor_reset(struct acpi_device *device, struct acpi_process acpi_processor_unlink(device, pr); put_online_cpus(); arch_unregister_cpu(pr->id); + mutex_lock(&acpi_processor_mutex); acpi_unmap_lsapic(pr->id); + mutex_unlock(&acpi_processor_mutex); pr->id = -1; } @@ -703,14 +706,18 @@ static int acpi_processor_pre_configure(struct acpi_device *device, if (pr->apic_id == -1) return result; + mutex_lock(&acpi_processor_mutex); result = acpi_map_lsapic(device->handle, pr->apic_id, &pr->id); + mutex_unlock(&acpi_processor_mutex); if (result) return result; BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); result = arch_register_cpu(pr->id, 1); if (result) { + mutex_lock(&acpi_processor_mutex); acpi_unmap_lsapic(pr->id); + mutex_unlock(&acpi_processor_mutex); pr->id = -1; return result; }