From: Nicolas Saenz Julienne <nsaenzju@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
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: Wed, 02 Jun 2021 11:38:03 +0200 [thread overview]
Message-ID: <924be4021c3b9f65d15aa12765facb9eb58911b0.camel@redhat.com> (raw)
In-Reply-To: <20210528133253.27c749ab@gandalf.local.home>
Hi Steven, thanks for having a look at this.
On Fri, 2021-05-28 at 13:32 -0400, Steven Rostedt wrote:
> 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.
Yes, I hadn't thought of O_NONBLOCK...
> If you need this for trace-cmd, we can add a --poll option that would do
> this.
I just sent a patch with my attempt at implementing --poll.
--
Nicolás Sáenz
prev parent reply other threads:[~2021-06-02 9:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-19 17:57 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
2021-06-02 9:38 ` Nicolas Saenz Julienne [this message]
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=924be4021c3b9f65d15aa12765facb9eb58911b0.camel@redhat.com \
--to=nsaenzju@redhat.com \
--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=rostedt@goodmis.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
all inboxes | Powered by JetHome®