Re: [PATCH v3 08/10] perf: cache perf_event_groups_first for cgroups
From: Peter Zijlstra
Date: Mon Nov 18 2019 - 03:37:56 EST
On Fri, Nov 15, 2019 at 05:20:52PM -0800, Ian Rogers wrote:
> On Thu, Nov 14, 2019 at 2:25 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > > @@ -1706,18 +1738,10 @@ perf_event_groups_first(struct perf_event_groups *groups, int cpu,
> > > continue;
> > > }
> > > #ifdef CONFIG_CGROUP_PERF
> > > - node_cgrp_id = 0;
> > > - if (node_event->cgrp && node_event->cgrp->css.cgroup)
> > > - node_cgrp_id = node_event->cgrp->css.cgroup->id;
> > > -
> > > - if (cgrp_id < node_cgrp_id) {
> > > + if (node_event->cgrp) {
> > > node = node->rb_left;
> > > continue;
> > > }
> > > - if (cgrp_id > node_cgrp_id) {
> > > - node = node->rb_right;
> > > - continue;
> > > - }
> > > #endif
> > > match = node_event;
> > > node = node->rb_left;
> >
> > Also, just leave that in and let callers have: .cgrp = NULL. Then you
> > can forgo that monstrous name.
>
> Done. It is a shame that there is some extra logic for the task/no-cgroup case.
Yes, OTOH the primitive is consistent and more generic and possibly the
compiler will notice and fix it for us, it is a static function after
all, so it can be more agressive.