[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1314282374.27911.14.camel@twins>
Date: Thu, 25 Aug 2011 16:26:14 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Stephane Eranian <eranian@...gle.com>
Cc: linux-kernel@...r.kernel.org, mingo@...e.hu, ming.m.lin@...el.com
Subject: Re: [PATCH] perf_event: fix slow and broken cgroup context switch
code
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!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists