All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Lin Ming <ming.m.lin@intel.com>
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 10:50:28 +0200	[thread overview]
Message-ID: <1302511828.2388.17.camel@twins> (raw)
In-Reply-To: <1302511465.29423.13.camel@minggr.sh.intel.com>

On Mon, 2011-04-11 at 16:44 +0800, Lin Ming wrote:
> On Sun, 2011-04-10 at 10:13 +0200, Peter Zijlstra wrote:
> > On Sat, 2011-04-09 at 21:17 +0200, Peter Zijlstra wrote:
> > > +       if (task_ctx) {
> > > +               task_ctx_sched_out(task_ctx);
> > > +               /*
> > > +                * If the context we're installing events in is not the
> > > +                * active task_ctx, flip them.
> > > +                */

> > > +               if (ctx->task && task_ctx != ctx) {
> > > +                       raw_spin_unlock(&cpuctx->ctx.lock);
> > > +                       raw_spin_lock(&ctx->lock);
> > > +                       cpuctx->task_ctx = task_ctx = ctx;
> > > +               }
> > > +               task = task_ctx->task;
> > > +       } 
> > 
> > That is actually buggy, it should read something like:
> > 
> > 	if (task_ctx)
> > 		task_ctx_sched_out(task_ctx);
> > 
> > 	if (ctx->task && task_ctx != ctx) {
		if (task_ctx)
> > 			raw_spin_unlock(&task_ctx->lock);
> > 		raw_spin_lock(&ctx->lock);
> > 		cpuctx->task_ctx = task_ctx = ctx;
> > 	}
> > 
> > 	if (task_ctx)
> > 		task = task_ctx->task;
> > 
> > Aside from the trivial locking bug fixed, the previous version wouldn't
> > actually deal with installing a task_ctx where there was none before.

Let me place your comment with the new version, as the old one is
borken ;-)

> In which case will this happen?
> 
> For task event, we have:
> 
> perf_install_in_context
>    task_function_call(task, __perf_install_in_context, event)
>       __perf_install_in_context
> 
> Doesn't this ensure that the context we're installing events is same
> with the active task_ctx?

With __ARCH_WANT_INTERRUPTS_ON_CTXSW the IPI might land before we did
perf_event_task_sched_in(), in which case we need to set the task_ctx
our-selves.

  reply	other threads:[~2011-04-11  8:50 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 [this message]
2011-04-11  8:12   ` Lin Ming
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=1302511828.2388.17.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.