Messages in this thread | | | Subject | Re: [PATCH] perf_event: fix slow and broken cgroup context switch code | From | Peter Zijlstra <> | Date | Thu, 25 Aug 2011 16:26:14 +0200 |
| |
On Thu, 2011-08-25 at 15:58 +0200, Stephane Eranian wrote: > +static inline void perf_cgroup_sched_out(struct task_struct *task, > + struct task_struct *next) > { > + struct perf_cgroup *cgrp1; > + struct perf_cgroup *cgrp2 = NULL; > + > + /* > + * we come here when we know perf_cgroup_events > 0 > + */ > + cgrp1 = perf_cgroup_from_task(task); > + > + /* > + * next is NULL when called from perf_event_enable_on_exec() > + * that will systematically cause a cgroup_switch() > + */ > + if (next) > + cgrp2 = perf_cgroup_from_task(next); > + > + /* > + * only schedule out current cgroup events if we know > + * that we are switching to a different cgroup. Otherwise, > + * do no touch the cgroup events. > + */ > + if (cgrp1 != cgrp2) > + perf_cgroup_switch(task, PERF_CGROUP_SWOUT); > } > > +static inline void perf_cgroup_sched_in(struct task_struct *prev, > + struct task_struct *task) > { > + struct perf_cgroup *cgrp1; > + struct perf_cgroup *cgrp2 = NULL; > + > + /* > + * we come here when we know perf_cgroup_events > 0 > + */ > + cgrp1 = perf_cgroup_from_task(task); > + > + /* prev can never be NULL */ > + cgrp2 = perf_cgroup_from_task(prev); > + > + /* > + * only need to schedule in cgroup events if we are changing > + * cgroup during ctxsw. Cgroup events were not scheduled > + * out of ctxsw out if that was not the case. > + */ > + if (cgrp1 != cgrp2) > + perf_cgroup_switch(task, PERF_CGROUP_SWIN); > }
OK, looks sane enough, queued the patch, thanks!
| |