From dbc01ecdffd4d803802dc03b915ac3b7b8ac6820 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 16 Jul 2013 10:06:40 +0200 Subject: [PATCH] perf_event_open.2: Update PERF_IOC_FLAG_GROUP info It turns out PERF_IOC_FLAG_GROUP was broken from 75f937f24bd9 (in Linux 2.6.31, the initial perf_event release) until 724b6daa1 (Linux 3.4). I've done some extensive kernel source code digging plus running tests of various kernels and I hope the info presented is accurate now. (Patch edited somewhat by mtk.) Signed-off-by: Vince Weaver Signed-off-by: Michael Kerrisk --- man2/perf_event_open.2 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2 index fac409343..fc245340c 100644 --- a/man2/perf_event_open.2 +++ b/man2/perf_event_open.2 @@ -24,7 +24,7 @@ .\" This document is based on the perf_event.h header file, the .\" tools/perf/design.txt file, and a lot of bitter experience. .\" -.TH PERF_EVENT_OPEN 2 2013-07-02 "Linux" "Linux Programmer's Manual" +.TH PERF_EVENT_OPEN 2 2013-07-16 "Linux" "Linux Programmer's Manual" .SH NAME perf_event_open \- set up performance monitoring .SH SYNOPSIS @@ -1839,7 +1839,8 @@ file descriptor argument. If the .B PERF_IOC_FLAG_GROUP bit is set in the ioctl argument, then all events in a group are -enabled, even if the event specified is not the group leader. +enabled, even if the event specified is not the group leader +(but see BUGS). .TP .B PERF_EVENT_IOC_DISABLE Disables the individual counter or event group specified by the @@ -1855,7 +1856,8 @@ stops that counter from counting but doesn't affect any other counter. If the .B PERF_IOC_FLAG_GROUP bit is set in the ioctl argument, then all events in a group are -disabled, even if the event specified is not the group leader. +disabled, even if the event specified is not the group leader +(but see BUGS). .TP .B PERF_EVENT_IOC_REFRESH Non-inherited overflow counters can use this @@ -1884,14 +1886,8 @@ values. If the .B PERF_IOC_FLAG_GROUP bit is set in the ioctl argument, then all events in a group are -reset, even if the event specified is not the group leader. - -If the -.B PERF_IOC_FLAG_GROUP -bit is not set, then the behavior is somewhat unexpected: -when sent to a group leader only the leader is reset -(children are left alone); -when sent to a child all events in a group are reset. +reset, even if the event specified is not the group leader +(but see BUGS). .TP .B PERF_EVENT_IOC_PERIOD IOC_PERIOD is the command to update the period; it @@ -2078,6 +2074,12 @@ Linux 2.6.36 and Linux 3.0 that ignores the was chosen if the union has a non-zero value in it. +From Linux 2.6.31 to Linux 3.4, the +.B PERF_IOC_FLAG_GROUP +ioctl argument was broken and would repeatedly operate +on the event specified rather than iterating across +all sibling events in a group. + Always double-check your results! Various generalized events have had wrong values. For example, retired branches measured