public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, ming.m.lin@intel.com
Subject: Re: [PATCH] perf_event: fix slow and broken cgroup context switch code
Date: Thu, 25 Aug 2011 16:26:14 +0200	[thread overview]
Message-ID: <1314282374.27911.14.camel@twins> (raw)
In-Reply-To: <20110825135803.GA4697@quad>

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!

  parent reply	other threads:[~2011-08-25 14:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 13:58 [PATCH] perf_event: fix slow and broken cgroup context switch code Stephane Eranian
2011-08-25 14:20 ` Peter Zijlstra
2011-08-25 14:36   ` Stephane Eranian
2011-08-25 14:42     ` Peter Zijlstra
2011-08-25 15:03       ` Stephane Eranian
2011-08-25 17:34         ` Peter Zijlstra
2011-08-25 14:22 ` Peter Zijlstra
2011-08-25 14:26 ` Peter Zijlstra [this message]
2011-08-29 14:56 ` [tip:perf/urgent] perf events: Fix " tip-bot for Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314282374.27911.14.camel@twins \
    --to=peterz@infradead.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox