Re: [PATCH RFC 1/3] perf/core: add logic to collect off-cpu sample

From: Peter Zijlstra
Date: Mon Jul 15 2024 - 07:48:37 EST


On Sun, Jul 14, 2024 at 09:53:10PM +0530, Ajay Kaher wrote:
> On Fri, Jul 12, 2024 at 3:19 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > On Thu, Jul 11, 2024 at 05:46:17PM +0530, Ajay Kaher wrote:
> > > following logics has been added to collect the off-cpu sample:
> > >
> > > - 'task_pt_regs(current)' has been used to capture registers
> > > status off-cpu sample.
> > >
> > > - off-cpu time represent the time period for which the target
> > > process not occupying the cpu cycles. And calculate as:
> > >
> > > off-cpu time = swap-in time - swap-out time
> > >
> >
> > I have absolutely no idea what you're trying to do :/ The above does not
> > constitute a comprehensible Changelog.
>
> Sorry Peter, it’s sched-in/out (not swap-in/out).
>
> 'Perf record' captures on-cpu samples at frequency which is specified by
> the user ( i.e. time period to collect sample is NSEC_PER_SEC / freq).
>
> This patch is to collect the off_cpu sample and time period of off_cpu
> sample is calculated based upon the time when target task was sched_out
> to sched_in, as:
>
> off-cpu time period = sched_in time - sched-out time

But but but... you don't need anything new for that. The sched_wakeup
tracepoint should generate an event in both the task/cpu that does the
wakeup *AND* the task being woken.

So sched_switch + sched_wakeup should get you all this already. What am
I missing?

https://lore.kernel.org/all/1342016098-213063-1-git-send-email-avagin@xxxxxxxxxx/T/#u