lkml.org 
[lkml]   [2020]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v9 09/15] perf stat: factor out event handling loop into dispatch_events()
From
Date

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

\
 
 \ /
  Last update: 2020-07-06 15:08    [W:0.091 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site