lkml.org 
[lkml]   [2011]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] perf_event: fix slow and broken cgroup context switch code
From
Date
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!


\
 
 \ /
  Last update: 2011-08-25 16:29    [W:0.089 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site