linux-kernel-test/arch
Milton Miller 9b78825158 powerpc/irq: Protect irq_radix_revmap_lookup against irq_free_virt
The radix-tree code uses call_rcu when freeing internal elements.
We must protect against the elements being freed while we traverse
the tree, even if the returned pointer will still be valid.

While preparing a patch to expand the context in which
irq_radix_revmap_lookup will be called, I realized that the
radix tree was not locked.

When asked

    For a normal call_rcu usage, is it allowed to read the structure in
    irq_enter / irq_exit, without additional rcu_read_lock?  Could an
    element freed with call_rcu advance with the cpu still between
    irq_enter/irq_exit (and irq_disabled())?

Paul McKenney replied:

    Absolutely illegal to do so. OK for call_rcu_sched(), but a
    flaming bug for call_rcu().

    And thank you very much for finding this!!!

Further analysis:

In the current CONFIG_TREE_RCU implementation. CONFIG_TREE_PREEMPT_RCU
(and CONFIG_TINY_PREEMPT_RCU) uses explicit counters.

These counters are reflected from per-CPU to global in the
scheduling-clock-interrupt handler, so disabling irq does prevent the
grace period from completing. But there are real-time implementations
(such as the one use by the Concurrent guys) where disabling irq
does -not- prevent the grace period from completing.

While an alternative fix would be to switch radix-tree to rcu_sched, I
don't want to audit the other users of radix trees (nor put alternative
freeing in the library).  The normal overhead for rcu_read_lock and
unlock are a local counter increment and decrement.

This does not show up in the rcu lockdep because in 2.6.34 commit
2676a58c98 (radix-tree: Disable RCU lockdep checking in radix tree)
deemed it too hard to pass the condition of the protecting lock
to the library.

Signed-off-by: Milton Miller <miltonm@bga.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-05-26 13:38:59 +10:00
..
alpha Remove unused PROC_CHANGE_PENALTY constant 2011-05-25 08:39:43 -07:00
arm Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc 2011-05-25 16:55:55 -07:00
avr32 mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
blackfin Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/vapier/blackfin 2011-05-25 15:34:14 -07:00
cris cris: convert old cpumask API into new one 2011-05-25 08:39:39 -07:00
frv mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
h8300 genirq: Remove the now obsolete config options and select statements 2011-03-30 14:13:23 +02:00
ia64 mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
m32r lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
m68k mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
microblaze mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
mips lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
mn10300 mn10300: convert old cpumask API into new one 2011-05-25 08:39:39 -07:00
parisc Remove unused PROC_CHANGE_PENALTY constant 2011-05-25 08:39:43 -07:00
powerpc powerpc/irq: Protect irq_radix_revmap_lookup against irq_free_virt 2011-05-26 13:38:59 +10:00
s390 mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
score lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
sh lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
sparc lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
tile Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2011-05-25 15:35:32 -07:00
um lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
unicore32 lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
x86 Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging 2011-05-25 16:52:50 -07:00
xtensa mm: now that all old mmu_gather code is gone, remove the storage 2011-05-25 08:39:16 -07:00
.gitignore
Kconfig mm, powerpc: move the RCU page-table freeing into generic code 2011-05-25 08:39:16 -07:00