]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
hotplug: Prevent alloc/free of irq descriptors during cpu up/down
authorThomas Gleixner <tglx@linutronix.de>
Sun, 5 Jul 2015 17:12:30 +0000 (17:12 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 8 Jul 2015 09:32:25 +0000 (11:32 +0200)
commita899418167264c7bac574b1a0f1b2c26c5b0995a
tree92d1185f96f4ed72643cce403ab007a12bbbd7fc
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754
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 <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: xiao jin <jin.xiao@intel.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Link: http://lkml.kernel.org/r/20150705171102.063519515@linutronix.de
include/linux/irqdesc.h
kernel/cpu.c
kernel/irq/internals.h