From: Daniel Thompson <daniel.thompson@linaro.org> To: Russell King - ARM Linux <linux@arm.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de>, Jason Cooper <jason@lakedaemon.net>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz <john.stultz@linaro.org>, Sumit Semwal <sumit.semwal@linaro.org>, Dirk Behme <dirk.behme@de.bosch.com>, Daniel Drake <drake@endlessm.com>, Dmitry Pervushin <dpervushin@gmail.com>, Tim Sander <tim@krieglstein.org>, Stephen Boyd <sboyd@codeaurora.org> Subject: Re: [RFC PATCH 5/5] arm: perf: Use FIQ to handle PMU events. Date: Tue, 20 Jan 2015 10:04:50 +0000 [thread overview] Message-ID: <54BE2842.5000205@linaro.org> (raw) In-Reply-To: <20150119174818.GD26493@n2100.arm.linux.org.uk> On 19/01/15 17:48, Russell King - ARM Linux wrote: > On Tue, Jan 13, 2015 at 04:35:31PM +0000, Daniel Thompson wrote: >> +/* >> + * This handler is called *unconditionally* from the default NMI/FIQ >> + * handler. The irq may not be anything to do with us so the main >> + * job of this function is to figure out if the irq passed in is ours >> + * or not. >> + */ >> +void cpu_pmu_handle_fiq(int irq) >> +{ >> + int cpu = smp_processor_id(); > > This can be either debug_smp_processor_id() or raw_smp_processor_id(). > raw_smp_processor_id() is fine from FIQ contexts, as seems to be > debug_smp_processor_id(), but only because we guarantee that > irqs_disabled() in there will be true. Curiously I was looking at exactly this yesterday (because I was intrigued why the NMI-safe bits of kgdb use raw_smp_processor_id() but the x86 arch_trigger_all_cpu_backtrace() implementation uses smp_processor_id()). Given the comments make clear smp_processor_id() is the preferred variant except for false positives I concluded I would continue with smp_processor_id() for any code I write hanging off the default FIQ handler. No objections? >> + >> + if (irq != get_cpu_var(cpu_pmu_irqs)) >> + return; > > get_cpu_var() needs put_cpu_var() to undo its effects. get_cpu_var() > calls preempt_disable(), which calls into lockdep... I think we > determined that was fine last time we went digging? Yes. We reviewed lockdep from the point-of-view of RCU and found that lockdep disabled most of itself when in_nmi() is true. > put_cpu_var() > would call preempt_enable() which I'd hope would be safe in FIQ/NMI > contexts? Yes. preempt_count_add/sub form part of the work done by nmi_enter() and nmi_exit(). However this code gets no benefit from calling get_cpu_var(). I think it would be better to switch it to this_cpu_ptr. >> + >> + (void)armpmu_dispatch_irq(irq, >> + get_cpu_ptr(&cpu_pmu->hw_events->percpu_pmu)); > > Again, get_cpu_xxx() needs to be balanced with a put_cpu_xxx(). > >
WARNING: multiple messages have this Message-ID (diff)
From: daniel.thompson@linaro.org (Daniel Thompson) To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 5/5] arm: perf: Use FIQ to handle PMU events. Date: Tue, 20 Jan 2015 10:04:50 +0000 [thread overview] Message-ID: <54BE2842.5000205@linaro.org> (raw) In-Reply-To: <20150119174818.GD26493@n2100.arm.linux.org.uk> On 19/01/15 17:48, Russell King - ARM Linux wrote: > On Tue, Jan 13, 2015 at 04:35:31PM +0000, Daniel Thompson wrote: >> +/* >> + * This handler is called *unconditionally* from the default NMI/FIQ >> + * handler. The irq may not be anything to do with us so the main >> + * job of this function is to figure out if the irq passed in is ours >> + * or not. >> + */ >> +void cpu_pmu_handle_fiq(int irq) >> +{ >> + int cpu = smp_processor_id(); > > This can be either debug_smp_processor_id() or raw_smp_processor_id(). > raw_smp_processor_id() is fine from FIQ contexts, as seems to be > debug_smp_processor_id(), but only because we guarantee that > irqs_disabled() in there will be true. Curiously I was looking at exactly this yesterday (because I was intrigued why the NMI-safe bits of kgdb use raw_smp_processor_id() but the x86 arch_trigger_all_cpu_backtrace() implementation uses smp_processor_id()). Given the comments make clear smp_processor_id() is the preferred variant except for false positives I concluded I would continue with smp_processor_id() for any code I write hanging off the default FIQ handler. No objections? >> + >> + if (irq != get_cpu_var(cpu_pmu_irqs)) >> + return; > > get_cpu_var() needs put_cpu_var() to undo its effects. get_cpu_var() > calls preempt_disable(), which calls into lockdep... I think we > determined that was fine last time we went digging? Yes. We reviewed lockdep from the point-of-view of RCU and found that lockdep disabled most of itself when in_nmi() is true. > put_cpu_var() > would call preempt_enable() which I'd hope would be safe in FIQ/NMI > contexts? Yes. preempt_count_add/sub form part of the work done by nmi_enter() and nmi_exit(). However this code gets no benefit from calling get_cpu_var(). I think it would be better to switch it to this_cpu_ptr. >> + >> + (void)armpmu_dispatch_irq(irq, >> + get_cpu_ptr(&cpu_pmu->hw_events->percpu_pmu)); > > Again, get_cpu_xxx() needs to be balanced with a put_cpu_xxx(). > >
next prev parent reply other threads:[~2015-01-20 10:09 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-01-13 16:35 [RFC PATCH 0/5] irq: Allow irqs to be routed to NMI/FIQ Daniel Thompson 2015-01-13 16:35 ` Daniel Thompson 2015-01-13 16:35 ` [RFC PATCH 1/5] arm: irq: Add a __nmi_count stat Daniel Thompson 2015-01-13 16:35 ` Daniel Thompson 2015-01-13 16:35 ` [RFC PATCH 2/5] irq: Allow interrupts to routed to NMI (or similar) Daniel Thompson 2015-01-13 16:35 ` Daniel Thompson 2015-01-19 16:21 ` Joshua Clayton 2015-01-19 16:21 ` Joshua Clayton 2015-01-19 17:33 ` Daniel Thompson 2015-01-19 17:33 ` Daniel Thompson 2015-01-13 16:35 ` [RFC PATCH 3/5] irq: gic: Add support for NMI routing Daniel Thompson 2015-01-13 16:35 ` Daniel Thompson 2015-01-13 16:35 ` [RFC PATCH 4/5] arm: perf: Make v7 support FIQ-safe Daniel Thompson 2015-01-13 16:35 ` Daniel Thompson 2015-01-13 16:35 ` [RFC PATCH 5/5] arm: perf: Use FIQ to handle PMU events Daniel Thompson 2015-01-13 16:35 ` Daniel Thompson 2015-01-19 16:35 ` Joshua Clayton 2015-01-19 16:35 ` Joshua Clayton 2015-01-20 10:18 ` Daniel Thompson 2015-01-20 10:18 ` Daniel Thompson 2015-01-20 17:35 ` Joshua Clayton 2015-01-20 17:35 ` Joshua Clayton 2015-01-19 17:48 ` Russell King - ARM Linux 2015-01-19 17:48 ` Russell King - ARM Linux 2015-01-20 10:04 ` Daniel Thompson [this message] 2015-01-20 10:04 ` Daniel Thompson 2015-01-21 17:03 ` [RFC PATCH v2 0/5] irq: Allow irqs to be routed to NMI/FIQ Daniel Thompson 2015-01-21 17:03 ` Daniel Thompson 2015-01-21 17:03 ` [RFC PATCH v2 1/5] arm: irq: Add a __nmi_count stat Daniel Thompson 2015-01-21 17:03 ` Daniel Thompson 2015-01-21 17:03 ` [RFC PATCH v2 2/5] irq: Allow interrupts to routed to NMI (or similar) Daniel Thompson 2015-01-21 17:03 ` Daniel Thompson 2015-01-24 23:37 ` Thomas Gleixner 2015-01-24 23:37 ` Thomas Gleixner 2015-01-21 17:03 ` [RFC PATCH v2 3/5] irq: gic: Add support for NMI routing Daniel Thompson 2015-01-21 17:03 ` Daniel Thompson 2015-01-21 17:03 ` [RFC PATCH v2 4/5] arm: perf: Make v7 support FIQ-safe Daniel Thompson 2015-01-21 17:03 ` Daniel Thompson 2015-01-21 17:03 ` [RFC PATCH v2 5/5] arm: perf: Use FIQ to handle PMU events Daniel Thompson 2015-01-21 17:03 ` Daniel Thompson
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=54BE2842.5000205@linaro.org \ --to=daniel.thompson@linaro.org \ --cc=dirk.behme@de.bosch.com \ --cc=dpervushin@gmail.com \ --cc=drake@endlessm.com \ --cc=jason@lakedaemon.net \ --cc=john.stultz@linaro.org \ --cc=linaro-kernel@lists.linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=patches@linaro.org \ --cc=sboyd@codeaurora.org \ --cc=sumit.semwal@linaro.org \ --cc=tglx@linutronix.de \ --cc=tim@krieglstein.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.