From: Song Liu <songliubraving@meta.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <song@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Kernel Team <kernel-team@meta.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] perf: fix perf_event_context->time
Date: Wed, 1 Mar 2023 23:16:32 +0000 [thread overview]
Message-ID: <BBB1A458-25CA-4C0F-AF04-18534D092142@fb.com> (raw)
In-Reply-To: <CAM9d7chLaXDU4mMkD1U6YuOGZXcu7PFWGOuEkFKSkbrCLS+zWg@mail.gmail.com>
> On Mar 1, 2023, at 2:29 PM, Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Song,
>
> On Tue, Feb 28, 2023 at 11:22 AM Song Liu <song@kernel.org> wrote:
>>
>> Time readers rely on perf_event_context->[time|timestamp|timeoffset] to get
>> accurate time_enabled and time_running for an event. The difference between
>> ctx->timestamp and ctx->time is the among of time when the context is not
>> enabled. For cpuctx.ctx, time and timestamp should stay the same, however,
>
> I'm not sure if it's correct. The timestamp can go when the context is disabled
> for example, in ctx_resched() even if the NMI watchdog is enabled, right?
I think we do not disable EVENT_TIME for per cpu ctx?
>
>> it is not the case at the moment. To show this with drgn [1]:
>>
>> drgn 0.0.22 (using Python 3.8.6, elfutils 0.185, with libkdumpfile)
>> For help, type help(drgn).
>> ...
>>>>> ctx = per_cpu_ptr(prog['pmu'].pmu_cpu_context, 0).ctx
>>>>> ctx.timestamp * 1.0 / ctx.time
>> (double)1.0385869134111765
>>>>>
>>
>> ctx->timestamp is about 4% larger than ctx.time. This issue causes time
>> read by perf_event_read_local() goes back in some cases.
>
> I don't think the difference between the ctx.time and the timestamp
> itself is a problem. I think the problem is it CAN update the timestamp
> (and the timeoffset) while the context is enabled. Then depending on
> the timing, event times can return smaller values than before.
For per cpu ctx, I think timeoffset should stay the same (may not be zero
though).
Thanks,
Song
next prev parent reply other threads:[~2023-03-01 23:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 19:21 Song Liu
2023-03-01 22:29 ` Namhyung Kim
2023-03-01 23:16 ` Song Liu [this message]
2023-03-02 21:15 ` Namhyung Kim
2023-03-03 1:21 ` Song Liu
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=BBB1A458-25CA-4C0F-AF04-18534D092142@fb.com \
--to=songliubraving@meta.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.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®