]> www.infradead.org Git - users/jedix/linux-maple.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)
committerEthan Zhao <ethan.zhao@oracle.com>
Wed, 23 Aug 2017 03:57:00 +0000 (12:57 +0900)
commite9c7554a174f1fa23e4dd4ebc0cee2f8e3e31bf7
treefa1bdea4a6db7239dc2dcbe0f9fd755c667154d0
parent59e4a67215507762ea7d49ccd9c1efdfbb6aaeb1
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
(cherry picked from commit a899418167264c7bac574b1a0f1b2c26c5b0995a)

Orabug: 25671838

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
include/linux/irqdesc.h
kernel/cpu.c
kernel/irq/internals.h