From: Peter Zijlstra <peterz@infradead.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>, Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Stephane Eranian <eranian@google.com>,
Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
Song Liu <songliubraving@fb.com>
Subject: Re: [PATCH v3] perf/core: Set event shadow time for inactive events too
Date: Thu, 9 Dec 2021 00:22:03 +0100 [thread overview]
Message-ID: <20211208232203.GC16608@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20211205224843.1503081-1-namhyung@kernel.org>
On Sun, Dec 05, 2021 at 02:48:43PM -0800, Namhyung Kim wrote:
> While commit f79256532682 ("perf/core: fix userpage->time_enabled of
> inactive events") fixed this problem for user rdpmc usage,
You're referring to 'this problem' before actually describing a problem :-(
Also, you now have me looking at that commit again, and I'm still hating
it. Also, I'm again struggling to make sense of it; all except the very
last hunk that is.
So the whole, full-fat, mmap self-monitor thing looks like:
u32 seq, time_mult, time_shift, index, width = 64;
u64 count, enabled, running;
u64 cyc, time_offset, time_cycles = 0, time_mask = ~0ULL;
u64 quot, rem, delta;
s64 pmc = 0;
do {
seq = pc->lock;
barrier();
enabled = pc->time_enabled;
running = pc->time_running;
if (pc->cap_user_time && enabled != running) {
cyc = rdtsc();
time_offset = pc->time_offset;
time_mult = pc->time_mult;
time_shift = pc->time_shift;
}
if (pc->cap_user_time_short) {
time_cycles = pc->time_cycles;
time_mask = pc->time_mask;
}
index = pc->index;
count = pc->offset;
if (pc->cap_user_rdpmc && index) {
width = pc->pmc_width;
pmc = rdpmc(index - 1);
}
barrier();
} while (pc->lock != seq);
if (width < 64) {
pmc <<= 64 - width;
pmc >>= 64 - width;
}
count += pmc;
cyc = time_cycles + ((cyc - time_cycles) & time_mask);
quot = (cyc >> time_shift);
rem = cyc & ((1ULL < time_shift) - 1);
delta = time_offset + quot * time_mult +
((rem * time_mult) >> time_shift);
enabled += delta;
if (index)
running += delta;
quot = count / running;
rem = count % running;
count = quot * enabled + (rem * enabled) / running;
Now, the thing that sticks out to me is that 'enabled' is
unconditionally advanced. It *always* runs.
So how can not updating ->time_enabled when the counter is INACTIVE due
to rotation (which causes ->index == 0), cause enabled to not be
up-to-date?
Can we please figure that out so I can go revert all but the last hunk
of that patch?
next prev parent reply other threads:[~2021-12-08 23:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-05 22:48 [PATCH v3] perf/core: Set event shadow time for inactive events too Namhyung Kim
2021-12-06 23:11 ` Song Liu
2021-12-08 23:22 ` Peter Zijlstra [this message]
2021-12-09 5:52 ` Namhyung Kim
2021-12-09 8:21 ` Peter Zijlstra
2021-12-09 11:26 ` Peter Zijlstra
2021-12-09 11:34 ` Peter Zijlstra
2021-12-09 21:51 ` Namhyung Kim
2021-12-10 10:19 ` Peter Zijlstra
2021-12-10 18:59 ` Namhyung Kim
2021-12-20 9:39 ` Peter Zijlstra
2021-12-09 21:35 ` Namhyung Kim
2021-12-10 10:33 ` Peter Zijlstra
2021-12-10 23:19 ` Namhyung Kim
2021-12-17 16:35 ` Peter Zijlstra
2021-12-18 9:09 ` Song Liu
2021-12-20 9:30 ` Peter Zijlstra
2021-12-20 9:54 ` Peter Zijlstra
2021-12-21 12:39 ` Peter Zijlstra
2021-12-20 12:19 ` Peter Zijlstra
2021-12-21 5:54 ` Namhyung Kim
2021-12-21 7:23 ` Song Liu
2021-12-21 11:21 ` Peter Zijlstra
2022-01-18 11:17 ` [tip: perf/urgent] perf: Fix perf_event_read_local() time tip-bot2 for Peter Zijlstra
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=20211208232203.GC16608@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=songliubraving@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.