From: Milton Miller <miltonm@bga.com>
To: linuxppc-dev@ozlabs.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>, Anton Blanchard <anton@samba.org>
Subject: Re: [PATCH] powerpc: Improve IRQ radix tree locking
Date: Fri, 25 Aug 2006 09:42:03 -0500 [thread overview]
Message-ID: <e991208eced0af7536e9f71bf6cb7016@bga.com> (raw)
On Fri Aug 25 16:04:52 EST 2006, Benjamin Herrenschmidt wrote:
> When reworking the powerpc irq code, I figured out that we were using
> the radix tree in a racy way. As a temporary fix, I put a spinlock in
> there. However, this can have a significant impact on performances.
> This
> patch reworks that to use a smarter technique based on the fact that
> what we need is in fact a rwlock with extremely rare writers (thus
> optimized for the read path).
> +static void irq_radix_wrlock(unsigned long *flags)
> +{
> + unsigned int cpu, ok;
> +
> + spin_lock_irqsave(&irq_big_lock, *flags);
> + irq_radix_writer = 1;
I think the smp_mb() is needed after here
> + do {
> + ok = 1;
> + smp_mb();
but not every time we poll the cpus. We are only
updating our local variable ok which we have not
given anyone else. It could even be a register.
> + for_each_possible_cpu(cpu) {
> + if (per_cpu(irq_radix_reader, cpu)) {
> + ok = 0;
> + break;
> + }
> + }
> + if (!ok)
> + cpu_relax();
Hmmm. the gcc barrier is conditional. How about putting
barrier() before the ok=1 at the top, to avoid any optimization
blockage but still telling gcc you must read every time?
> + } while(!ok);
> +}
> +
Oh, and how about some (un)likely in irq_radix_rdlock ? It
could happen by default by why not show our expected path?
And, while I'm thinking of changes, when set ok=0 above add:
#ifdef CONFIG_SPINLOCK_DEBUG
BUG_ON(cpu == smp_processor_id());
#endif
Hmm... just thought of something .... we are spinning under
irq lock. We are waiting on some other thread, but not
telling the hypervisor. Should we confer our execution
over to the cpu we are waiting on? I know, it sounds ugly
to call that code. I guess we would want a
cpu_waiting_on(cpu) that calls cpu_relax and/or hypervisor.
milton
next reply other threads:[~2006-08-25 14:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-25 14:42 Milton Miller [this message]
2006-08-25 22:54 ` [PATCH] powerpc: Improve IRQ radix tree locking Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2006-08-25 6:04 Benjamin Herrenschmidt
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=e991208eced0af7536e9f71bf6cb7016@bga.com \
--to=miltonm@bga.com \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/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).