From: James Hogan <james.hogan@imgtec.com>
To: Joshua Kinard <kumba@gentoo.org>
Cc: Linux/MIPS <linux-mips@linux-mips.org>
Subject: Re: RFC: Proper locking tips for IRQ handlers?
Date: Mon, 6 Mar 2017 11:40:38 +0000 [thread overview]
Message-ID: <20170306114038.GE2878@jhogan-linux.le.imgtec.org> (raw)
In-Reply-To: <2c6f8c8d-6380-2f0b-69be-72115e2012c7@gentoo.org>
[-- Attachment #1: Type: text/plain, Size: 3259 bytes --]
Hi Joshua,
On Sat, Mar 04, 2017 at 10:17:41AM -0500, Joshua Kinard wrote:
> I am looking for some feedback on how to improve IRQ handlers on IP30 (SGI
> Octane). Since switching to the use of per_cpu data structures, I've
> apparently not needed to do any locking when handling IRQs. However, it looks
> like around ~Linux-4.8.x, there's some noticeable contention going on with
> heavy disk I/O, and it's worse in 4.9 and 4.10. Under 4.8, untar'ing a basic
> Linux kernel source tarball completed fine, but as of 4.9/4.10, there's a
> chance to trigger either an oops or oom killer. While the untar operation
> happens, I can watch the graphics console and the blinking cursor will
> sometimes pause momentarily, which suggests contention somewhere.
>
> So my question is in struct irq_chip accessors like irq_ack, irq_mask,
> irq_mask_ack, etc, should spinlocks be used prior to accessing the HEART ASIC?
> And if so, normal spinlocks, raw spinlocks, or the irq save/restore variants?
On RT kernels spinlock_t becomes a mutex and won't work correctly with
IRQs actually disabled for the IRQ callbacks, so raw spinlocks would be
needed instead.
To decide which variant, a good reference is:
https://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/index.html
in particular the cheat sheet for locking:
https://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/c214.html
(I don't know OTOH which contexts these callbacks are called from,
definitely hard IRQ, but possibly others when registering IRQs etc).
If its only protecting access to per-CPU structures though you shouldn't
need the spinlock part of the locks (but does it not access hardware
registers too, or are those accesses atomic in hardware rather than
software doing read-modify-write?). In that case you could choose to use
the following instead of locks depending on the contexts its used in:
- spin_lock_irqsave/restore -> local_irq_save/restore +
preempt_disable/enable
- spin_lock_irq -> local_irq_disable/enable +
preempt_disable/enable
- spin_lock_bh -> local_bh_disable/enable
- spin_lock -> preempt_disable/enable
Hope that helps a bit
Cheers
James
> I've looked at the IRQ implementations for a few other MIPS boards, but because
> each system is so unique, there's no clear consensus on the right way to do it.
> Octeon, uses irq_bus_lock and irq_bus_sync_unlock, along with a mutex, for
> locking, while netlogic uses locking only during irq_enable or irq_disable, and
> loongsoon-3 doesn't appear to employ any locking at all. Other archs appear to
> be a mix as well, and I'm even seeing newer constructs like the use of
> irq_data_get_irq_chip_data() to fetch a common data structure where the
> spinlock variable is defined. Other systems use a global spinlock.
>
> Any advice would be greatly appreciated. Thanks!
>
> --
> Joshua Kinard
> Gentoo/MIPS
> kumba@gentoo.org
> 6144R/F5C6C943 2015-04-27
> 177C 1972 1FB8 F254 BAD0 3E72 5C63 F4E3 F5C6 C943
>
> "The past tempts us, the present confuses us, the future frightens us. And our
> lives slip away, moment by moment, lost in that vast, terrible in-between."
>
> --Emperor Turhan, Centauri Republic
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2017-03-06 11:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-04 15:17 RFC: Proper locking tips for IRQ handlers? Joshua Kinard
2017-03-06 11:40 ` James Hogan [this message]
2017-03-07 16:56 ` Joshua Kinard
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=20170306114038.GE2878@jhogan-linux.le.imgtec.org \
--to=james.hogan@imgtec.com \
--cc=kumba@gentoo.org \
--cc=linux-mips@linux-mips.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