Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933221AbbGGUHO (ORCPT ); Tue, 7 Jul 2015 16:07:14 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38294 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932630AbbGGUHH (ORCPT ); Tue, 7 Jul 2015 16:07:07 -0400 Date: Tue, 7 Jul 2015 13:06:33 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: bp@suse.de, hpa@zytor.com, tglx@linutronix.de, jroedel@suse.de, peterz@infradead.org, jin.xiao@intel.com, linux-kernel@vger.kernel.org, yanmin_zhang@linux.intel.com, mingo@kernel.org Reply-To: jin.xiao@intel.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, yanmin_zhang@linux.intel.com, tglx@linutronix.de, hpa@zytor.com, bp@suse.de, jroedel@suse.de In-Reply-To: <20150705171102.063519515@linutronix.de> References: <20150705171102.063519515@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/urgent] hotplug: Prevent alloc/ free of irq descriptors during cpu up/down Git-Commit-ID: bdcbafe3402cb337752c4c8bce3445ee4c5559a5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2450 Lines: 67 Commit-ID: bdcbafe3402cb337752c4c8bce3445ee4c5559a5 Gitweb: http://git.kernel.org/tip/bdcbafe3402cb337752c4c8bce3445ee4c5559a5 Author: Thomas Gleixner AuthorDate: Sun, 5 Jul 2015 17:12:30 +0000 Committer: Thomas Gleixner CommitDate: Tue, 7 Jul 2015 22:03:22 +0200 hotplug: Prevent alloc/free of irq descriptors during cpu up/down When a cpu goes up some architectures (e.g. x86) have to walk the irq space to set up the vector space for the cpu. While this needs extra protection at the architecture level we can avoid a few race conditions by preventing the concurrent allocation/free of irq descriptors and the associated data. When a cpu goes down it moves the interrupts which are targeted to this cpu away by reassigning the affinities. While this happens interrupts can be allocated and freed, which opens a can of race conditions in the code which reassignes the affinities because interrupt descriptors might be freed underneath. Example: CPU1 CPU2 cpu_up/down irq_desc = irq_to_desc(irq); remove_from_radix_tree(desc); raw_spin_lock(&desc->lock); free(desc); We could protect the irq descriptors with RCU, but that would require a full tree change of all accesses to interrupt descriptors. But fortunately these kind of race conditions are rather limited to a few things like cpu hotplug. The normal setup/teardown is very well serialized. So the simpler and obvious solution is: Prevent allocation and freeing of interrupt descriptors accross cpu hotplug. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra Cc: xiao jin Cc: Joerg Roedel Cc: Borislav Petkov Cc: Yanmin Zhang Link: http://lkml.kernel.org/r/20150705171102.063519515@linutronix.de --- kernel/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index fa6dc67..6a37454 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "smpboot.h" -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/