[perfmon2] [PATCH] Fix error with buffer size and number of events in a group
Status: Beta
Brought to you by:
seranian
From: Corey A. <cja...@li...> - 2010-05-07 02:30:09
|
perf_get_group_nevents was returning the wrong number of events when the group was the last in the list - it always returned 1 instead of the true number. Also, when reading up event groups, only a "max size" (sz) was being passed to the read() function, which resulted in getting fewer bytes than requested and a resulting warning when groups with fewer events follow groups with more events. Signed-off-by: Corey Ashford <cja...@li...> --- perf_examples/perf_util.c | 2 +- perf_examples/task.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/perf_examples/perf_util.c b/perf_examples/perf_util.c index 9c99b15..b84f0e2 100644 --- a/perf_examples/perf_util.c +++ b/perf_examples/perf_util.c @@ -161,7 +161,7 @@ perf_get_group_nevents(perf_event_desc_t *fds, int num, int idx) return i - leader; } } - return 1; + return i - leader; } int diff --git a/perf_examples/task.c b/perf_examples/task.c index c66e3ed..75de973 100644 --- a/perf_examples/task.c +++ b/perf_examples/task.c @@ -99,14 +99,14 @@ read_groups(perf_event_desc_t *fds, int num) if (!values) err(1, "cannot allocate memory for values\n"); - ret = read(fds[evt].fd, values, sz); - if (ret != sz) { /* unsigned */ + ret = read(fds[evt].fd, values, new_sz); + if (ret != new_sz) { /* unsigned */ if (ret == -1) err(1, "cannot read values event %s", fds[evt].name); /* likely pinned and could not be loaded */ warnx("could not read event %d, tried to read %d bytes, but got %d", - evt, (int)sz, ret); + evt, (int)new_sz, ret); } /* -- 1.7.0.4 |