linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Sebastien Dugue <sebastien.dugue@bull.net>
To: linuxppc-dev@ozlabs.org
Cc: dwalker@mvista.com, tinytim@us.ibm.com,
	linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	rostedt@goodmis.org, jean-pierre.dion@bull.net,
	sebastien.dugue@bull.net, paulus@samba.org,
	gilles.carry@ext.bull.net, tglx@linutronix.de
Subject: [PATCH 0/2 V3] powerpc - Make the irq reverse mapping tree lockless
Date: Wed,  6 Aug 2008 15:30:27 +0200	[thread overview]
Message-ID: <1218029429-21114-1-git-send-email-sebastien.dugue@bull.net> (raw)


  Hi ,

  here is V3 for the powerpc IRQ radix tree reverse mapping rework.

  V2 -> V3: from comments by Benjamin Herrenschmidt and Daniel Walker

  - Move the initialization of the radix tree back into irq_late_init() and
    insert pre-existing irqs into the tree at that time.

  - One whitespace cleanup.

  V1 -> V2: from comments by Michael Ellerman

  - Initialize the XICS radix tree in xics code and only for that irq_host
    rather than doing it for all the hosts in the powerpc irq generic code
    (although the hosts list only contain one entry at the moment).

  - Add a comment in irq_radix_revmap_lookup() stating why it is safe to
    perform a lookup even if the radix tree has not been initialized yet.


  The goal of this patchset is to simplify the locking constraints on the radix
tree used for IRQ reverse mapping on the pSeries machines and provide lockless
access to this tree.

  This also solves the following BUG under preempt-rt:

BUG: sleeping function called from invalid context swapper(1) at kernel/rtmutex.c:739
in_atomic():1 [00000002], irqs_disabled():1
Call Trace:
[c0000001e20f3340] [c000000000010370] .show_stack+0x70/0x1bc (unreliable)
[c0000001e20f33f0] [c000000000049380] .__might_sleep+0x11c/0x138
[c0000001e20f3470] [c0000000002a2f64] .__rt_spin_lock+0x3c/0x98
[c0000001e20f34f0] [c0000000000c3f20] .kmem_cache_alloc+0x68/0x184
[c0000001e20f3590] [c000000000193f3c] .radix_tree_node_alloc+0xf0/0x144
[c0000001e20f3630] [c000000000195190] .radix_tree_insert+0x18c/0x2fc
[c0000001e20f36f0] [c00000000000c710] .irq_radix_revmap+0x1a4/0x1e4
[c0000001e20f37b0] [c00000000003b3f0] .xics_startup+0x30/0x54
[c0000001e20f3840] [c00000000008b864] .setup_irq+0x26c/0x370
[c0000001e20f38f0] [c00000000008ba68] .request_irq+0x100/0x158
[c0000001e20f39a0] [c0000000001ee9c0] .hvc_open+0xb4/0x148
[c0000001e20f3a40] [c0000000001d72ec] .tty_open+0x200/0x368
[c0000001e20f3af0] [c0000000000ce928] .chrdev_open+0x1f4/0x25c
[c0000001e20f3ba0] [c0000000000c8bf0] .__dentry_open+0x188/0x2c8
[c0000001e20f3c50] [c0000000000c8dec] .do_filp_open+0x50/0x70
[c0000001e20f3d70] [c0000000000c8e8c] .do_sys_open+0x80/0x148
[c0000001e20f3e20] [c00000000000928c] .init_post+0x4c/0x100
[c0000001e20f3ea0] [c0000000003c0e0c] .kernel_init+0x428/0x478
[c0000001e20f3f90] [c000000000027448] .kernel_thread+0x4c/0x68

  The root cause of this bug lies in the fact that the XICS interrupt
controller uses a radix tree for its reverse irq mapping and that we cannot
allocate the tree nodes (even GFP_ATOMIC) with preemption disabled.

  In fact, we have 2 nested preemption disabling when we want to allocate
a new node:

  - setup_irq() does a spin_lock_irqsave() before calling xics_startup() which
    then calls irq_radix_revmap() to insert a new node in the tree

  - irq_radix_revmap() also does a spin_lock_irqsave() (in irq_radix_wrlock())
    before the radix_tree_insert()

  Also, if an IRQ gets registered before the tree is initialized (namely the
IPI), it will be inserted into the tree in interrupt context once the tree
have been initialized, hence the need for a spin_lock_irqsave() in the
insertion path.

  This serie is split into 2 patches:

  - The first patch splits irq_radix_revmap() into its 2 components: one
    for lookup and one for insertion into the radix tree and moves the
    insertion of pre-existing irq into the tree at irq_late_init() time.

  - The second patch makes the radix tree fully lockless on the 
    lookup side.


  Here is the diffstat for the whole patchset:

 arch/powerpc/include/asm/irq.h        |   19 ++++-
 arch/powerpc/kernel/irq.c             |  148 ++++++++++++++------------------
 arch/powerpc/platforms/pseries/xics.c |   11 +--
 3 files changed, 85 insertions(+), 93 deletions(-)

  Thanks,

  Sebastien.

             reply	other threads:[~2008-08-06 13:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 13:30 Sebastien Dugue [this message]
2008-08-06 13:30 ` [PATCH 1/2] powerpc - Separate the irq radix tree insertion and lookup Sebastien Dugue
2008-08-20  5:21   ` Benjamin Herrenschmidt
2008-09-03 13:34     ` Sebastien Dugue
2008-08-06 13:30 ` [PATCH 2/2] powerpc - Make the irq reverse mapping radix tree lockless Sebastien Dugue
2008-08-20  5:22   ` Benjamin Herrenschmidt
2008-09-03 13:34     ` Sebastien Dugue
2008-08-20  5:23   ` Benjamin Herrenschmidt
2008-09-03 13:41     ` Sebastien Dugue
2008-09-04  2:52       ` Benjamin Herrenschmidt
2008-09-04  7:22         ` Sebastien Dugue
2008-09-04  7:34           ` Benjamin Herrenschmidt
2008-09-04  7:55             ` Sebastien Dugue
2008-09-04  7:58               ` Benjamin Herrenschmidt
2008-09-04  8:04                 ` Sebastien Dugue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218029429-21114-1-git-send-email-sebastien.dugue@bull.net \
    --to=sebastien.dugue@bull.net \
    --cc=dwalker@mvista.com \
    --cc=gilles.carry@ext.bull.net \
    --cc=jean-pierre.dion@bull.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=tinytim@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).