linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context
@ 2011-10-23 17:10 Gleb Natapov
  2011-11-03  7:41 ` Gleb Natapov
  2011-11-18 23:32 ` [tip:perf/urgent] perf: Do not set task_ctx pointer in cpuctx if there are " tip-bot for Gleb Natapov
  0 siblings, 2 replies; 6+ messages in thread
From: Gleb Natapov @ 2011-10-23 17:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

Do not set task_ctx pointer during sched_in if there is no
events associated with the context.  Otherwise if during task
execution total number of events in the system will become zero
perf_event_context_sched_out() will not be called and cpuctx->task_ctx
will be left with a stale value.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 0f85778..68b13ee 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2172,7 +2172,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
 
 	perf_event_sched_in(cpuctx, ctx, task);
 
-	cpuctx->task_ctx = ctx;
+	if (ctx->nr_events)
+		cpuctx->task_ctx = ctx;
 
 	perf_pmu_enable(ctx->pmu);
 	perf_ctx_unlock(cpuctx, ctx);
--
			Gleb.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context
  2011-10-23 17:10 [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context Gleb Natapov
@ 2011-11-03  7:41 ` Gleb Natapov
  2011-11-07 13:00   ` Peter Zijlstra
  2011-11-18 23:32 ` [tip:perf/urgent] perf: Do not set task_ctx pointer in cpuctx if there are " tip-bot for Gleb Natapov
  1 sibling, 1 reply; 6+ messages in thread
From: Gleb Natapov @ 2011-11-03  7:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

Ingo, Peter can you look into this please.

On Sun, Oct 23, 2011 at 07:10:33PM +0200, Gleb Natapov wrote:
> Do not set task_ctx pointer during sched_in if there is no
> events associated with the context.  Otherwise if during task
> execution total number of events in the system will become zero
> perf_event_context_sched_out() will not be called and cpuctx->task_ctx
> will be left with a stale value.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 0f85778..68b13ee 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -2172,7 +2172,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
>  
>  	perf_event_sched_in(cpuctx, ctx, task);
>  
> -	cpuctx->task_ctx = ctx;
> +	if (ctx->nr_events)
> +		cpuctx->task_ctx = ctx;
>  
>  	perf_pmu_enable(ctx->pmu);
>  	perf_ctx_unlock(cpuctx, ctx);
> --
> 			Gleb.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
			Gleb.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context
  2011-11-03  7:41 ` Gleb Natapov
@ 2011-11-07 13:00   ` Peter Zijlstra
  2011-11-13 16:06     ` Gleb Natapov
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2011-11-07 13:00 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: linux-kernel, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

On Thu, 2011-11-03 at 09:41 +0200, Gleb Natapov wrote:
> Ingo, Peter can you look into this please.

queued it and the jump_label thing.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context
  2011-11-07 13:00   ` Peter Zijlstra
@ 2011-11-13 16:06     ` Gleb Natapov
  2011-11-14 10:50       ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Gleb Natapov @ 2011-11-13 16:06 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

On Mon, Nov 07, 2011 at 02:00:11PM +0100, Peter Zijlstra wrote:
> On Thu, 2011-11-03 at 09:41 +0200, Gleb Natapov wrote:
> > Ingo, Peter can you look into this please.
> 
> queued it and the jump_label thing.
I see jump_label thing in tip/perf/core but not this one yet. This is
good because this one needs amendment :) See below.

---

Do not set task_ctx pointer during sched_in if there is no
events associated with the context.  Otherwise if during task
execution total number of events in the system will become zero
perf_event_context_sched_out() will not be called and cpuctx->task_ctx
will be left with a stale value. Also perf_event_sched_in() shouldn't try
to schedule task events in this case otherwise cpuctx->task_ctx->is_active
will not be cleared during sched_out and will become incorrect.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d1a1bee..7210657 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2171,9 +2171,10 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
 	 */
 	cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
 
-	perf_event_sched_in(cpuctx, ctx, task);
+	if (ctx->nr_events)
+		cpuctx->task_ctx = ctx;
 
-	cpuctx->task_ctx = ctx;
+	perf_event_sched_in(cpuctx, cpuctx->task_ctx, task);
 
 	perf_pmu_enable(ctx->pmu);
 	perf_ctx_unlock(cpuctx, ctx);
--
			Gleb.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context
  2011-11-13 16:06     ` Gleb Natapov
@ 2011-11-14 10:50       ` Peter Zijlstra
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2011-11-14 10:50 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: linux-kernel, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

On Sun, 2011-11-13 at 18:06 +0200, Gleb Natapov wrote:
> On Mon, Nov 07, 2011 at 02:00:11PM +0100, Peter Zijlstra wrote:
> > On Thu, 2011-11-03 at 09:41 +0200, Gleb Natapov wrote:
> > > Ingo, Peter can you look into this please.
> > 
> > queued it and the jump_label thing.
> I see jump_label thing in tip/perf/core but not this one yet. This is
> good because this one needs amendment :) See below.

Weird ass stuff, because my copy still applies to tip/master. Ingo, wtf
is up?

> ---
> 
> Do not set task_ctx pointer during sched_in if there is no
> events associated with the context.  Otherwise if during task
> execution total number of events in the system will become zero
> perf_event_context_sched_out() will not be called and cpuctx->task_ctx
> will be left with a stale value. Also perf_event_sched_in() shouldn't try
> to schedule task events in this case otherwise cpuctx->task_ctx->is_active
> will not be cleared during sched_out and will become incorrect.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

--- missing right there

> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index d1a1bee..7210657 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -2171,9 +2171,10 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
>  	 */
>  	cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
>  
> -	perf_event_sched_in(cpuctx, ctx, task);
> +	if (ctx->nr_events)
> +		cpuctx->task_ctx = ctx;
>  
> -	cpuctx->task_ctx = ctx;
> +	perf_event_sched_in(cpuctx, cpuctx->task_ctx, task);
>  
>  	perf_pmu_enable(ctx->pmu);
>  	perf_ctx_unlock(cpuctx, ctx);
> --
> 			Gleb.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:perf/urgent] perf: Do not set task_ctx pointer in cpuctx if there are no events in the context
  2011-10-23 17:10 [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context Gleb Natapov
  2011-11-03  7:41 ` Gleb Natapov
@ 2011-11-18 23:32 ` tip-bot for Gleb Natapov
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Gleb Natapov @ 2011-11-18 23:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, gleb, hpa, mingo, a.p.zijlstra, tglx, mingo

Commit-ID:  1d5f003f5a964711853514b04ddc872eec0fdc7b
Gitweb:     http://git.kernel.org/tip/1d5f003f5a964711853514b04ddc872eec0fdc7b
Author:     Gleb Natapov <gleb@redhat.com>
AuthorDate: Sun, 23 Oct 2011 19:10:33 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 14 Nov 2011 13:01:21 +0100

perf: Do not set task_ctx pointer in cpuctx if there are no events in the context

Do not set task_ctx pointer during sched_in if there are no
events associated with the context.  Otherwise if during task
execution total number of events in the system will become zero
perf_event_context_sched_out() will not be called and cpuctx->task_ctx
will be left with a stale value.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20111023171033.GI17571@redhat.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/events/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 0e8457d..b0c1186 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2173,7 +2173,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
 
 	perf_event_sched_in(cpuctx, ctx, task);
 
-	cpuctx->task_ctx = ctx;
+	if (ctx->nr_events)
+		cpuctx->task_ctx = ctx;
 
 	perf_pmu_enable(ctx->pmu);
 	perf_ctx_unlock(cpuctx, ctx);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-18 23:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-23 17:10 [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context Gleb Natapov
2011-11-03  7:41 ` Gleb Natapov
2011-11-07 13:00   ` Peter Zijlstra
2011-11-13 16:06     ` Gleb Natapov
2011-11-14 10:50       ` Peter Zijlstra
2011-11-18 23:32 ` [tip:perf/urgent] perf: Do not set task_ctx pointer in cpuctx if there are " tip-bot for Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).