Re: [PATCH v6 3/6] perf: Use min_heap in visit_groups_merge
From: Peter Zijlstra
Date: Mon Feb 17 2020 - 12:23:23 EST
On Thu, Feb 13, 2020 at 11:51:30PM -0800, Ian Rogers wrote:
>
> - *evt = perf_event_groups_next(*evt);
> + next = perf_event_groups_next(itrs[0]);
> + if (next) {
> + min_heap_pop_push(&event_heap, &next,
> + &perf_min_heap);
> + } else
> + min_heap_pop(&event_heap, &perf_min_heap);
> }
Like this:
@@ -3585,9 +3581,9 @@ static noinline int visit_groups_merge(s
if (ret)
return ret;
- next = perf_event_groups_next(*evt);
- if (next)
- min_heap_pop_push(&event_heap, &next, &perf_min_heap);
+ *evt = perf_event_groups_next(*evt);
+ if (*evt)
+ min_heapify(&event_heap, 0, &perf_min_heap);
else
min_heap_pop(&event_heap, &perf_min_heap);
}
That's an 'obvious' replace and resort and obviates the need for that
weird pop that doesn't return nothing operation.