Hi Jiri,
On 5/5/2020 8:03 AM, Jiri Olsa wrote:
On Sat, May 02, 2020 at 10:33:59AM +0800, Jin, Yao wrote:
SNIP
@@ -1461,6 +1461,9 @@ static int get_group_fd(struct evsel *evsel, int cpu, int thread)
ÂÂÂÂÂÂ BUG_ON(!leader->core.fd);
ÂÂÂÂÂÂ fd = FD(leader, cpu, thread);
+ÂÂÂ if (fd == -1 && leader->core.system_wide)
fd does not need to be -1 in here.. in my setup cstate_pkg/c2-residency/
has cpumask 0, so other cpus never get open and are 0, and the whole thing
ends up with:
ÂÂÂÂsys_perf_event_open: pid -1Â cpu 1Â group_fd 0Â flags 0
ÂÂÂÂsys_perf_event_open failed, error -9
I actualy thought we put -1 to fd array but couldn't find it.. perhaps we should od that
I have tested on two platforms. On KBL desktop fd is 0 for this case, but on
oncascadelakex server, fd is -1, so the BUG_ON(fd == -1) is triggered.
+ÂÂÂÂÂÂÂ fd = FD(leader, 0, thread);
+
so how do we group following events?
ÂÂÂ cstate_pkg/c2-residency/ - cpumask 0
ÂÂÂ msr/tsc/ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ - all cpus
Not sure if it's enough to only use cpumask 0 because
cstate_pkg/c2-residency/ should be per-socket.
cpu 0 is fine.. the rest I have no idea ;-)
Perhaps we directly remove the BUG_ON(fd == -1) assertion?
I think we need to make clear how to deal with grouping over
events that comes for different cpus
ÂÂÂÂso how do we group following events?
ÂÂÂÂÂÂ cstate_pkg/c2-residency/ - cpumask 0
ÂÂÂÂÂÂ msr/tsc/ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ - all cpus
what's the reason/expected output of groups with above events?
seems to make sense only if we limit msr/tsc/ to cpumask 0 as well
jirka
On 2-socket machine (e.g cascadelakex), "cstate_pkg/c2-residency/" is per-socket event and the cpumask is 0 and 24.
root@lkp-csl-2sp5 /sys/devices/cstate_pkg# cat cpumask
0,24
We can't limit it to cpumask 0. It should be programmed on CPU0 and CPU24 (the first CPU on each socket).
The "msr/tsc" are per-cpu event, it should be programmed on all cpus. So I don't think we can limit msr/tsc to cpumask 0.
The issue is how we deal with get_group_fd().
static int get_group_fd(struct evsel *evsel, int cpu, int thread)
{
ÂÂÂÂÂÂÂ struct evsel *leader = evsel->leader;
ÂÂÂÂÂÂÂ int fd;
ÂÂÂÂÂÂÂ if (evsel__is_group_leader(evsel))
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -1;
ÂÂÂÂÂÂÂ /*
ÂÂÂÂÂÂÂÂ * Leader must be already processed/open,
ÂÂÂÂÂÂÂÂ * if not it's a bug.
ÂÂÂÂÂÂÂÂ */
ÂÂÂÂÂÂÂ BUG_ON(!leader->core.fd);
ÂÂÂÂÂÂÂ fd = FD(leader, cpu, thread);
ÂÂÂÂÂÂÂ BUG_ON(fd == -1);
ÂÂÂÂÂÂÂ return fd;
}
When evsel is "msr/tsc/",
FD(leader, 0, 0) is 3 (3 is the fd of "cstate_pkg/c2-residency/" on CPU0)
FD(leader, 1, 0) is -1
BUG_ON asserted.
If we just return group_fd(-1) for "msr/tsc", it looks like it's not a problem, is it?
Thanks
Jin Yao