Messages in this thread | | | Subject | Re: [PATCH v9 09/15] perf stat: factor out event handling loop into dispatch_events() | From | Alexey Budankov <> | Date | Mon, 6 Jul 2020 16:07:54 +0300 |
| |
On 06.07.2020 15:27, Jiri Olsa wrote: > On Fri, Jul 03, 2020 at 10:46:15AM +0300, Alexey Budankov wrote: >> >> Consolidate event dispatching loops for fork, attach and system >> wide monitoring use cases into common dispatch_events() function. >> >> Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com> >> --- >> tools/perf/builtin-stat.c | 42 +++++++++++++++++++++++++-------------- >> 1 file changed, 27 insertions(+), 15 deletions(-) >> >> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c >> index 3e11f854ffc8..723f1fe27d63 100644 >> --- a/tools/perf/builtin-stat.c >> +++ b/tools/perf/builtin-stat.c >> @@ -550,6 +550,30 @@ static bool is_target_alive(struct target *_target, >> return false; >> } >> >> +static int dispatch_events(bool forks, int timeout, int interval, int *times, struct timespec *ts) >> +{ >> + bool stop = false; >> + int child_exited = 0, status = 0; >> + >> + while (1) { >> + if (forks) >> + child_exited = waitpid(child_pid, &status, WNOHANG); >> + else >> + child_exited = !is_target_alive(&target, evsel_list->core.threads) ? 1 : 0; >> + >> + if (done || stop || child_exited) >> + break; > > can (done || stop) be in the while condition and > we'd check just child_exited in here? > >> + >> + nanosleep(ts, NULL); >> + if (timeout) >> + stop = true; > > can we just break out in here? like the original code? > I don't think we need the extra iteration > >> + else >> + stop = handle_interval(interval, times); > > same here..?
Accepted. In v10.
Alexey
| |