When monitoring another process, the kernels up through linux-2.6.34-rc7
have a bug where all of the events except the group leader give a zero
value for the time_running and time_enabled values.  This #define allows
us to work around that bug by copying these two values from the group
leader to all of its siblings.

Signed-off-by: Corey Ashford <cjash...@linux.vnet.ibm.com>

diff --git a/perf_examples/task.c b/perf_examples/task.c
index 75de973..35ba0b8 100644
--- a/perf_examples/task.c
+++ b/perf_examples/task.c
@@ -61,6 +61,15 @@ child(char **arg)
        /* not reached */
 }
 
+/*
+ * When monitoring another process, the kernels up through linux-2.6.34-rc7
+ * have a bug where all of the events except the group leader give a zero
+ * value for the time_running and time_enabled values.  This #define allows
+ * us to work around that bug by copying these two values from the group
+ * leader to all of its siblings.
+ */
+#define KERNEL_HAS_GROUP_SCALING_BUG 1
+
 static void
 read_groups(perf_event_desc_t *fds, int num)
 {
@@ -120,6 +129,16 @@ read_groups(perf_event_desc_t *fds, int num)
                         * thus may be multiplexed
                         */
                        fds[i].prev_value = fds[i].value;
+#if KERNEL_HAS_GROUP_SCALING_BUG
+                       /* only the group leader has non-zero
+                          enabled and running values */
+                       if (fds[i].group_leader != i) {
+                               /* copy the correct values from the group
+                                  leader */
+                               values[1] = fds[fds[i].group_leader].enabled;
+                               values[2] = fds[fds[i].group_leader].running;
+                       }
+#endif
                        fds[i].value = perf_scale(values);
                        fds[i].enabled = values[1];
                        fds[i].running = values[2];

------------------------------------------------------------------------------

_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to