From: Namhyung Kim <namhyung@kernel.org>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: Re: [RFC/PATCH] perf report: Support latency profiling in system-wide mode
Date: Fri, 30 May 2025 15:05:15 -0700 [thread overview]
Message-ID: <aDormwKnOYm_-Jgs@google.com> (raw)
In-Reply-To: <CACT4Y+Y=1aXG_25ONnfD4TxMbsrnW3uFOOL9yrcP+LYeh4pHpg@mail.gmail.com>
On Fri, May 30, 2025 at 07:50:45AM +0200, Dmitry Vyukov wrote:
> On Wed, 28 May 2025 at 20:38, Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Hello,
> >
> > On Tue, May 27, 2025 at 09:14:34AM +0200, Dmitry Vyukov wrote:
> > > On Wed, 21 May 2025 at 09:30, Dmitry Vyukov <dvyukov@google.com> wrote:
> > > >
> > > > > Maybe we can use this
> > > > > only for the frequency mode which means user didn't use -c option or
> > > > > similar in the event description.
> > >
> > >
> > > All-in-all I think the best option for now is using CPU IDs to track
> > > parallelism as you suggested, but be more precise with idle detection.
> > > 2 passes over the trace may be fine to detect idle points. I see the
> > > most time now spent in hist_entry__cmp, which accesses other entries
> > > and is like a part of O(N*logN) processing, so a simple O(N) pass
> > > shouldn't slow it down much.
> > > That's what I would try. But I would also try to assess the precision
> > > of this approach by comparing with results of using explicit switch
> > > events.
> >
> > It's not clear to me how you want to maintain the idle info in the 2
> > pass approach. Please feel free to propose something based on this
> > work.
>
>
> What part of it is unclear?
>
> Basically, in the first pass we only mark events as sched_out/in.
> When we don't see samples on a CPU for 2*period, we mark the previous
> sample on the CPU as sched_out:
>
> // Assuming the period is stable across time and CPUs.
> for_each_cpu(cpu) {
> if (current[cpu]->last_timestamp + 2*period < sample->timestamp) {
> if (current[cpu]->thread != idle)
> current[cpu]->last_sample->sched_out = true;
> }
> }
>
> leader = machine__findnew_thread(machine, sample->pid);
> if (current[sample->cpu]->thread != leader) {
> current[sample->cpu]->last_sample->sched_out = true;
> sample->sched_in = true;
> }
> current[sample->cpu]->thread = leader;
> current[sample->cpu]->last_sample = sample;
> current[sample->cpu]->last_timestamp = sample->timestamp;
Oh, you wanted to save the info in the sample. But I'm afraid it won't
work since it's stack allocated for one-time use in the
perf_session__deliver_event().
>
>
> On the second pass we use the precomputed sched_in/out to calculate parallelism:
>
> leader = machine__findnew_thread(machine, sample->pid);
> if (sample->sched_in)
> leader->parallelism++;
> sample->parallelism = leader->parallelism;
> if (sample->sched_out)
> leader->parallelism--;
>
> This is more precise b/c we don't consider a thread running for
> 2*period after it stopped running.
IIUC it can make some samples have less parallelism right before
they go to idle.
> A more precise approach would probably be to consider the thread
> running for 0.5*period after the last sample (and similarly for
> 0.5*period before the first sample), but it would require injecting
> sched_in/out events into the trace at these points.
Yep, that will fix the issue. But then how to inject the events is the
problem.
Thanks,
Namhyung
next prev parent reply other threads:[~2025-05-30 22:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-03 0:36 [RFC/PATCH] perf report: Support latency profiling in system-wide mode Namhyung Kim
2025-05-04 8:22 ` Ingo Molnar
2025-05-04 19:52 ` Namhyung Kim
2025-05-05 8:03 ` Dmitry Vyukov
2025-05-06 14:57 ` Arnaldo Carvalho de Melo
2025-05-06 16:58 ` Arnaldo Carvalho de Melo
2025-05-07 9:58 ` Dmitry Vyukov
2025-05-07 15:47 ` Arnaldo Carvalho de Melo
2025-05-07 23:51 ` Namhyung Kim
2025-05-05 8:08 ` Dmitry Vyukov
2025-05-06 5:30 ` Namhyung Kim
2025-05-06 5:55 ` Dmitry Vyukov
2025-05-06 6:43 ` Namhyung Kim
2025-05-06 6:46 ` Dmitry Vyukov
2025-05-06 7:09 ` Namhyung Kim
2025-05-06 7:40 ` Dmitry Vyukov
2025-05-07 23:43 ` Namhyung Kim
2025-05-08 12:24 ` Dmitry Vyukov
2025-05-16 16:33 ` Namhyung Kim
2025-05-19 6:00 ` Dmitry Vyukov
2025-05-20 1:43 ` Namhyung Kim
2025-05-20 6:45 ` Dmitry Vyukov
2025-05-20 22:50 ` Namhyung Kim
2025-05-21 7:30 ` Dmitry Vyukov
2025-05-27 7:14 ` Dmitry Vyukov
2025-05-28 18:38 ` Namhyung Kim
2025-05-30 5:50 ` Dmitry Vyukov
2025-05-30 22:05 ` Namhyung Kim [this message]
2025-05-31 6:31 ` Dmitry Vyukov
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=aDormwKnOYm_-Jgs@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dvyukov@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).