From: Steven Rostedt <rostedt@goodmis.org>
To: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
mingo@redhat.com, corbet@lwn.net, mtosatti@redhat.com
Subject: Re: [RFC] trace: Add option for polling ring buffers
Date: Fri, 28 May 2021 13:32:53 -0400 [thread overview]
Message-ID: <20210528133253.27c749ab@gandalf.local.home> (raw)
In-Reply-To: <20210519175755.670876-1-nsaenzju@redhat.com>
On Wed, 19 May 2021 19:57:55 +0200
Nicolas Saenz Julienne <nsaenzju@redhat.com> wrote:
> To minimize trace's effect on isolated CPUs. That is, CPUs were only a
> handful or a single, process are allowed to run. Introduce a new trace
> option: 'poll-rb'.
>
> This option changes the heuristic used to wait for data on trace
> buffers. The default one, based on wait queues, will trigger an IPI[1]
> on the CPU responsible for new data, which will take care of waking up
> the trace gathering process (generally trace-cmd). Whereas with
> 'poll-rb' we will poll (as in busy-wait) the ring buffers from the trace
> gathering process, releasing the CPUs writing trace data from doing any
> wakeup work.
>
> This wakeup work, although negligible in the vast majority of workloads,
> may cause unwarranted latencies on systems running trace on isolated
> CPUs. This is made worse on PREEMPT_RT kernels, as they defer the IPI
> handling into a kernel thread, forcing unwarranted context switches on
> otherwise extremely busy CPUs.
>
> To illustrate this, tracing with PREEMPT_RT=y on an isolated CPU with a
> single process pinned to it (NO_HZ_FULL=y, and plenty more isolation
> options enabled). I see:
> - 50-100us latency spikes with the default trace-cmd options
> - 14-10us latency spikes with 'poll-rb'
> - 11-8us latency spikes with no tracing at all
>
> The obvious drawback of 'poll-rb' is putting more pressure on the
> housekeeping CPUs. Wasting cycles. Hence the notice in the documentation
> discouraging its use in general.
>
> [1] The IPI, in this case, an irq_work, is needed since trace might run
> in NMI context. Which is not suitable for wake-ups.
Can't this simply be done in user-space?
Set the reading of the trace buffers to O_NONBLOCK and it wont wait for
buffering to happen, and should prevent it from causing the IPI wake ups.
If you need this for trace-cmd, we can add a --poll option that would do
this.
-- Steve
next prev parent reply other threads:[~2021-05-28 17:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-19 17:57 [RFC] trace: Add option for polling ring buffers Nicolas Saenz Julienne
2021-05-19 18:07 ` Matthew Wilcox
2021-05-19 19:33 ` Marcelo Tosatti
2021-05-20 8:57 ` Nicolas Saenz Julienne
2021-05-28 17:32 ` Steven Rostedt [this message]
2021-06-02 9:38 ` Nicolas Saenz Julienne
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=20210528133253.27c749ab@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mtosatti@redhat.com \
--cc=nsaenzju@redhat.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).