public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lin Ming <ming.m.lin@intel.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Oleg Nesterov <oleg@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org,
	Stephane Eranian <eranian@google.com>
Subject: Re: [RFC][PATCH 5/9] perf: Simplify and fix __perf_install_in_context
Date: Mon, 11 Apr 2011 16:12:31 +0800	[thread overview]
Message-ID: <1302509551.29423.7.camel@minggr.sh.intel.com> (raw)
In-Reply-To: <20110409192141.870894224@chello.nl>

On Sat, 2011-04-09 at 21:17 +0200, Peter Zijlstra wrote:
> plain text document attachment (perf_install_in_context.patch)
> Currently __perf_install_in_context() will try and schedule in the
> event irrespective of our event scheduling rules, that is, we try to
> schedule CPU-pinned, TASK-pinned, CPU-flexible, TASK-flexible, but
> when creating a new event we simply try and schedule it on top of
> whatever is already on the PMU, this can lead to errors for pinned
> events.
> 
> Therefore, simplify things and simply schedule everything out, add the
> event to the corresponding context and schedule everything back in.
> 
> This also nicely handles the case where with
> __ARCH_WANT_INTERRUPTS_ON_CTXSW the IPI can come right in the middle
> of schedule, before we managed to call perf_event_task_sched_in().
> 
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
>  kernel/perf_event.c |   80 ++++++++++++++++++++++------------------------------
>  1 file changed, 35 insertions(+), 45 deletions(-)
> 
> Index: linux-2.6/kernel/perf_event.c
> ===================================================================
> --- linux-2.6.orig/kernel/perf_event.c
> +++ linux-2.6/kernel/perf_event.c
> @@ -1476,8 +1476,12 @@ static void add_event_to_ctx(struct perf
>  	event->tstamp_stopped = tstamp;
>  }
>  
> -static void perf_event_context_sched_in(struct perf_event_context *ctx,
> -					struct task_struct *tsk);
> +static void task_ctx_sched_out(struct perf_event_context *ctx);
> +static void
> +ctx_sched_in(struct perf_event_context *ctx,
> +	     struct perf_cpu_context *cpuctx,
> +	     enum event_type_t event_type,
> +	     struct task_struct *task);
>  
>  /*
>   * Cross CPU call to install and enable a performance event
> @@ -1488,20 +1492,31 @@ static int  __perf_install_in_context(vo
>  {
>  	struct perf_event *event = info;
>  	struct perf_event_context *ctx = event->ctx;
> -	struct perf_event *leader = event->group_leader;
>  	struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
> -	int err;
> +	struct perf_event_context *task_ctx = cpuctx->task_ctx;
> +	struct task_struct *task = current;
> +
> +	perf_ctx_lock(cpuctx, cpuctx->task_ctx);

perf_ctx_lock(cpuctx, task_ctx)

since task_ctx is assigned with cpuctx->task_ctx.

Lin Ming


  parent reply	other threads:[~2011-04-11  8:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-09 19:17 [RFC][PATCH 0/9] perf: Rework event scheduling Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 1/9] perf: Optimize ctx_sched_out Peter Zijlstra
2011-05-28 16:38   ` [tip:perf/core] perf: Optimize ctx_sched_out() tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 2/9] perf: Clean up ctx reference counting Peter Zijlstra
2011-04-11  6:05   ` Lin Ming
2011-04-11  8:35     ` Peter Zijlstra
2011-05-28 16:39   ` [tip:perf/core] perf: Clean up 'ctx' " tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 3/9] perf: Change event scheduling locking Peter Zijlstra
2011-05-28 16:39   ` [tip:perf/core] perf: Optimize " tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 4/9] perf: Remove task_ctx_sched_in Peter Zijlstra
2011-05-28 16:39   ` [tip:perf/core] perf: Remove task_ctx_sched_in() tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 5/9] perf: Simplify and fix __perf_install_in_context Peter Zijlstra
2011-04-10  8:13   ` Peter Zijlstra
2011-04-11  8:44     ` Lin Ming
2011-04-11  8:50       ` Peter Zijlstra
2011-04-11  8:12   ` Lin Ming [this message]
2011-05-28 16:40   ` [tip:perf/core] perf: Simplify and fix __perf_install_in_context() tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 6/9] perf: Change ctx::is_active semantics Peter Zijlstra
2011-05-28 16:40   ` [tip:perf/core] perf: Change and simplify " tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 7/9] perf: Collect the schedule in rules in one function Peter Zijlstra
2011-05-28 16:41   ` [tip:perf/core] perf: Collect the schedule-in " tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 8/9] perf: Change close() semantics for group events Peter Zijlstra
2011-05-28 16:41   ` [tip:perf/core] " tip-bot for Peter Zijlstra
2011-04-09 19:17 ` [RFC][PATCH 9/9] perf: De-schedule a task context when removing the last event Peter Zijlstra
2011-05-28 16:42   ` [tip:perf/core] " tip-bot for Peter Zijlstra

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=1302509551.29423.7.camel@minggr.sh.intel.com \
    --to=ming.m.lin@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    /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