From: Jani Nikula <jani.nikula@linux.intel.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Luca Abeni <lucabe72@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [Intel-gfx] [PATCH 7/8] drm/i915: Disable tracing points on PREEMPT_RT
Date: Tue, 14 Dec 2021 17:41:17 +0200 [thread overview]
Message-ID: <87bl1j5h42.fsf@intel.com> (raw)
In-Reply-To: <20211214093652.0dfa5b6f@gandalf.local.home>
On Tue, 14 Dec 2021, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 14 Dec 2021 15:03:00 +0100
> Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
>
>> Luca Abeni reported this:
>> | BUG: scheduling while atomic: kworker/u8:2/15203/0x00000003
>> | CPU: 1 PID: 15203 Comm: kworker/u8:2 Not tainted 4.19.1-rt3 #10
>> | Call Trace:
>> | rt_spin_lock+0x3f/0x50
>> | gen6_read32+0x45/0x1d0 [i915]
>> | g4x_get_vblank_counter+0x36/0x40 [i915]
>> | trace_event_raw_event_i915_pipe_update_start+0x7d/0xf0 [i915]
>>
>> The tracing events use trace_i915_pipe_update_start() among other events
>> use functions acquire spinlock_t locks which are transformed into
>> sleeping locks on PREEMPT_RT. A few trace points use
>> intel_get_crtc_scanline(), others use ->get_vblank_counter() wich also
>> might acquire a sleeping locks on PREEMPT_RT.
>> At the time the arguments are evaluated within trace point, preemption
>> is disabled and so the locks must not be acquired on PREEMPT_RT.
>>
>> Based on this I don't see any other way than disable trace points on
>> PREMPT_RT.
>
> Another way around this that I can see is if the data for the tracepoints
> can fit on the stack and add wrappers around the tracepoints. For example,
> looking at the first tracepoint in i915_trace.h:
FYI display portions of the file have been split to
display/intel_display_trace.[ch] in current drm-intel-next, headed for
v5.17 merge window.
BR,
Jani.
>
> TRACE_EVENT(intel_pipe_enable,
> TP_PROTO(struct intel_crtc *crtc),
> TP_ARGS(crtc),
>
> TP_STRUCT__entry(
> __array(u32, frame, 3)
> __array(u32, scanline, 3)
> __field(enum pipe, pipe)
> ),
> TP_fast_assign(
> struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> struct intel_crtc *it__;
> for_each_intel_crtc(&dev_priv->drm, it__) {
> __entry->frame[it__->pipe] = intel_crtc_get_vblank_counter(it__);
> __entry->scanline[it__->pipe] = intel_get_crtc_scanline(it__);
> }
> __entry->pipe = crtc->pipe;
> ),
>
> TP_printk("pipe %c enable, pipe A: frame=%u, scanline=%u, pipe B: frame=%u, scanline=%u, pipe C: frame=%u, scanline=%u",
> pipe_name(__entry->pipe),
> __entry->frame[PIPE_A], __entry->scanline[PIPE_A],
> __entry->frame[PIPE_B], __entry->scanline[PIPE_B],
> __entry->frame[PIPE_C], __entry->scanline[PIPE_C])
> );
>
> We could modify this to be:
>
> TRACE_EVENT(intel_pipe_enable,
> TP_PROTO(u32 *frame, u32 *scanline, enum pipe),
> TP_ARGS(frame, scanline, pipe),
>
> TP_STRUCT__entry(
> __array(u32, frame, 3)
> __array(u32, scanline, 3)
> __field(enum pipe, pipe)
> ),
> TP_fast_assign(
> int i;
> for (i = 0; i < 3; i++) {
> __entry->frame[i] = frame[i];
> __entry->scanline[i] = scanline[i];
> }
> __entry->pipe = pipe;
> ),
>
> TP_printk("pipe %c enable, pipe A: frame=%u, scanline=%u, pipe B: frame=%u, scanline=%u, pipe C: frame=%u, scanline=%u",
> pipe_name(__entry->pipe),
> __entry->frame[PIPE_A], __entry->scanline[PIPE_A],
> __entry->frame[PIPE_B], __entry->scanline[PIPE_B],
> __entry->frame[PIPE_C], __entry->scanline[PIPE_C])
> );
>
>
> static inline void do_trace_intel_pipe(struct intel_crtc *crtc)
> {
> u32 frame[3];
> u32 scanline[3];
> enum pipe pipe;
>
> if (!trace_intel_pipe_enable_enabled())
> return;
>
> struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> struct intel_crtc *it__;
> for_each_intel_crtc(&dev_priv->drm, it__) {
> frame[it__->pipe] = intel_crtc_get_vblank_counter(it__);
> scanline[it__->pipe] = intel_get_crtc_scanline(it__);
> }
>
> trace_intel_pipe(frame, scanline, crtc->pipe);
> }
>
>
> The trace_intel_pipe_enable_enabled() is a static_branch that will act the
> same as the nop of a trace event, so this will still not add overhead when
> not enabled.
>
> All the processing will be done outside the trace event allowing it to be
> preempted, and then when the trace event is executed, it will run quickly
> without taking any locks.
>
> Then have the code call do_trace_intel_pipe() instead of trace_intel_pipe()
> and this should fix the issue with preempt rt.
>
> -- Steve
--
Jani Nikula, Intel Open Source Graphics Center
WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Luca Abeni <lucabe72@gmail.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 7/8] drm/i915: Disable tracing points on PREEMPT_RT
Date: Tue, 14 Dec 2021 17:41:17 +0200 [thread overview]
Message-ID: <87bl1j5h42.fsf@intel.com> (raw)
In-Reply-To: <20211214093652.0dfa5b6f@gandalf.local.home>
On Tue, 14 Dec 2021, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 14 Dec 2021 15:03:00 +0100
> Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
>
>> Luca Abeni reported this:
>> | BUG: scheduling while atomic: kworker/u8:2/15203/0x00000003
>> | CPU: 1 PID: 15203 Comm: kworker/u8:2 Not tainted 4.19.1-rt3 #10
>> | Call Trace:
>> | rt_spin_lock+0x3f/0x50
>> | gen6_read32+0x45/0x1d0 [i915]
>> | g4x_get_vblank_counter+0x36/0x40 [i915]
>> | trace_event_raw_event_i915_pipe_update_start+0x7d/0xf0 [i915]
>>
>> The tracing events use trace_i915_pipe_update_start() among other events
>> use functions acquire spinlock_t locks which are transformed into
>> sleeping locks on PREEMPT_RT. A few trace points use
>> intel_get_crtc_scanline(), others use ->get_vblank_counter() wich also
>> might acquire a sleeping locks on PREEMPT_RT.
>> At the time the arguments are evaluated within trace point, preemption
>> is disabled and so the locks must not be acquired on PREEMPT_RT.
>>
>> Based on this I don't see any other way than disable trace points on
>> PREMPT_RT.
>
> Another way around this that I can see is if the data for the tracepoints
> can fit on the stack and add wrappers around the tracepoints. For example,
> looking at the first tracepoint in i915_trace.h:
FYI display portions of the file have been split to
display/intel_display_trace.[ch] in current drm-intel-next, headed for
v5.17 merge window.
BR,
Jani.
>
> TRACE_EVENT(intel_pipe_enable,
> TP_PROTO(struct intel_crtc *crtc),
> TP_ARGS(crtc),
>
> TP_STRUCT__entry(
> __array(u32, frame, 3)
> __array(u32, scanline, 3)
> __field(enum pipe, pipe)
> ),
> TP_fast_assign(
> struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> struct intel_crtc *it__;
> for_each_intel_crtc(&dev_priv->drm, it__) {
> __entry->frame[it__->pipe] = intel_crtc_get_vblank_counter(it__);
> __entry->scanline[it__->pipe] = intel_get_crtc_scanline(it__);
> }
> __entry->pipe = crtc->pipe;
> ),
>
> TP_printk("pipe %c enable, pipe A: frame=%u, scanline=%u, pipe B: frame=%u, scanline=%u, pipe C: frame=%u, scanline=%u",
> pipe_name(__entry->pipe),
> __entry->frame[PIPE_A], __entry->scanline[PIPE_A],
> __entry->frame[PIPE_B], __entry->scanline[PIPE_B],
> __entry->frame[PIPE_C], __entry->scanline[PIPE_C])
> );
>
> We could modify this to be:
>
> TRACE_EVENT(intel_pipe_enable,
> TP_PROTO(u32 *frame, u32 *scanline, enum pipe),
> TP_ARGS(frame, scanline, pipe),
>
> TP_STRUCT__entry(
> __array(u32, frame, 3)
> __array(u32, scanline, 3)
> __field(enum pipe, pipe)
> ),
> TP_fast_assign(
> int i;
> for (i = 0; i < 3; i++) {
> __entry->frame[i] = frame[i];
> __entry->scanline[i] = scanline[i];
> }
> __entry->pipe = pipe;
> ),
>
> TP_printk("pipe %c enable, pipe A: frame=%u, scanline=%u, pipe B: frame=%u, scanline=%u, pipe C: frame=%u, scanline=%u",
> pipe_name(__entry->pipe),
> __entry->frame[PIPE_A], __entry->scanline[PIPE_A],
> __entry->frame[PIPE_B], __entry->scanline[PIPE_B],
> __entry->frame[PIPE_C], __entry->scanline[PIPE_C])
> );
>
>
> static inline void do_trace_intel_pipe(struct intel_crtc *crtc)
> {
> u32 frame[3];
> u32 scanline[3];
> enum pipe pipe;
>
> if (!trace_intel_pipe_enable_enabled())
> return;
>
> struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> struct intel_crtc *it__;
> for_each_intel_crtc(&dev_priv->drm, it__) {
> frame[it__->pipe] = intel_crtc_get_vblank_counter(it__);
> scanline[it__->pipe] = intel_get_crtc_scanline(it__);
> }
>
> trace_intel_pipe(frame, scanline, crtc->pipe);
> }
>
>
> The trace_intel_pipe_enable_enabled() is a static_branch that will act the
> same as the nop of a trace event, so this will still not add overhead when
> not enabled.
>
> All the processing will be done outside the trace event allowing it to be
> preempted, and then when the trace event is executed, it will run quickly
> without taking any locks.
>
> Then have the code call do_trace_intel_pipe() instead of trace_intel_pipe()
> and this should fix the issue with preempt rt.
>
> -- Steve
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2021-12-14 15:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 14:02 [Intel-gfx] [PATCH 0/8] drm/i915: PREEMPT_RT related fixups Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2021-12-14 14:02 ` [Intel-gfx] [PATCH 1/8] drm/i915: Drop the irqs_disabled() check Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2021-12-14 14:02 ` [Intel-gfx] [PATCH 2/8] drm/i915/gt: Queue and wait for the irq_work item Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2021-12-14 14:02 ` [Intel-gfx] [PATCH 3/8] drm/i915/gt: Use spin_lock_irq() instead of local_irq_disable() + spin_lock() Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2021-12-14 14:02 ` [Intel-gfx] [PATCH 4/8] drm/i915: Use preempt_disable/enable_rt() where recommended Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2022-01-26 23:29 ` [Intel-gfx] " Mario Kleiner
2022-01-26 23:29 ` Mario Kleiner
2022-02-11 8:44 ` [Intel-gfx] " Sebastian Andrzej Siewior
2022-02-11 8:44 ` Sebastian Andrzej Siewior
2022-02-14 18:38 ` [Intel-gfx] " Mario Kleiner
2022-02-14 18:38 ` Mario Kleiner
2021-12-14 14:02 ` [Intel-gfx] [PATCH 5/8] drm/i915: Don't disable interrupts on PREEMPT_RT during atomic updates Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2021-12-14 14:02 ` [Intel-gfx] [PATCH 6/8] drm/i915: Don't check for atomic context on PREEMPT_RT Sebastian Andrzej Siewior
2021-12-14 14:02 ` Sebastian Andrzej Siewior
2021-12-14 14:03 ` [Intel-gfx] [PATCH 7/8] drm/i915: Disable tracing points " Sebastian Andrzej Siewior
2021-12-14 14:03 ` Sebastian Andrzej Siewior
2021-12-14 14:36 ` [Intel-gfx] " Steven Rostedt
2021-12-14 14:36 ` Steven Rostedt
2021-12-14 15:41 ` Jani Nikula [this message]
2021-12-14 15:41 ` Jani Nikula
2021-12-14 15:56 ` [Intel-gfx] " Sebastian Andrzej Siewior
2021-12-14 15:56 ` Sebastian Andrzej Siewior
2021-12-14 16:34 ` [Intel-gfx] " Ville Syrjälä
2021-12-14 16:58 ` Steven Rostedt
2022-02-08 17:32 ` Sebastian Andrzej Siewior
2021-12-14 14:03 ` [Intel-gfx] [PATCH 8/8] drm/i915: skip DRM_I915_LOW_LEVEL_TRACEPOINTS with NOTRACE Sebastian Andrzej Siewior
2021-12-14 14:03 ` Sebastian Andrzej Siewior
2021-12-14 15:58 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915: PREEMPT_RT related fixups. (rev4) Patchwork
2021-12-14 16:12 ` Sebastian Andrzej Siewior
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=87bl1j5h42.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@linux.ie \
--cc=bigeasy@linutronix.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lucabe72@gmail.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 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.