public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	John Kacur <jkacur@redhat.com>
Subject: [PATCH 3/7] perf_counter: sanitize context locking
Date: Sat, 23 May 2009 18:28:57 +0200	[thread overview]
Message-ID: <20090523163012.618790733@chello.nl> (raw)
In-Reply-To: 20090523162854.599719825@chello.nl

[-- Attachment #1: perf_counter-ctx-lock.patch --]
[-- Type: text/plain, Size: 1574 bytes --]

Ensure we're consistent with the context locks.

 context->mutex
   context->lock
     list_{add,del}_counter();

so that either lock is sufficient to stabilize the context.

LKML-Reference: <new-submission>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/perf_counter.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -597,6 +597,8 @@ static void add_counter_to_ctx(struct pe
 
 /*
  * Cross CPU call to install and enable a performance counter
+ *
+ * Must be called with ctx->mutex held
  */
 static void __perf_install_in_context(void *info)
 {
@@ -1496,13 +1498,13 @@ static void perf_counter_for_each_siblin
 	struct perf_counter_context *ctx = counter->ctx;
 	struct perf_counter *sibling;
 
-	spin_lock_irq(&ctx->lock);
+	mutex_lock(&ctx->mutex);
 	counter = counter->group_leader;
 
 	func(counter);
 	list_for_each_entry(sibling, &counter->sibling_list, list_entry)
 		func(sibling);
-	spin_unlock_irq(&ctx->lock);
+	mutex_unlock(&ctx->mutex);
 }
 
 static void perf_counter_for_each_child(struct perf_counter *counter,
@@ -3414,7 +3416,10 @@ __perf_counter_exit_task(struct task_str
 	struct perf_counter *parent_counter;
 
 	update_counter_times(child_counter);
+
+	spin_lock_irq(&child_ctx->lock);
 	list_del_counter(child_counter, child_ctx);
+	spin_unlock_irq(&child_ctx->lock);
 
 	parent_counter = child_counter->parent;
 	/*

-- 


  parent reply	other threads:[~2009-05-23 16:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-23 16:28 [PATCH 0/7] perf counter patches Peter Zijlstra
2009-05-23 16:28 ` [PATCH 1/7] perf_counter: fix dynamic irq_period logging Peter Zijlstra
2009-05-24  7:01   ` [tip:perfcounters/core] perf_counter: Fix " tip-bot for Peter Zijlstra
2009-05-25  0:08   ` [PATCH 1/7] perf_counter: fix " Paul Mackerras
2009-05-25  7:19     ` Peter Zijlstra
2009-05-23 16:28 ` [PATCH 2/7] perf_counter: sanitize counter->mutex Peter Zijlstra
2009-05-24  7:01   ` [tip:perfcounters/core] perf_counter: Sanitize counter->mutex tip-bot for Peter Zijlstra
2009-05-23 16:28 ` Peter Zijlstra [this message]
2009-05-24  7:01   ` [tip:perfcounters/core] perf_counter: Sanitize context locking tip-bot for Peter Zijlstra
2009-05-23 16:28 ` [PATCH 4/7] perf_counter: fix userspace build Peter Zijlstra
2009-05-24  7:01   ` [tip:perfcounters/core] perf_counter: Fix " tip-bot for Peter Zijlstra
2009-05-23 16:28 ` [PATCH 5/7] perf_counter: simplify context cleanup Peter Zijlstra
2009-05-24  7:01   ` [tip:perfcounters/core] perf_counter: Simplify " tip-bot for Peter Zijlstra
2009-05-23 16:29 ` [PATCH 6/7] perf_counter: change pctrl() behaviour Peter Zijlstra
2009-05-23 19:04   ` Peter Zijlstra
2009-05-24  7:02   ` [tip:perfcounters/core] perf_counter: Change " tip-bot for Peter Zijlstra
2009-05-23 16:29 ` [PATCH 7/7] perf_counter: remove perf_counter_context::nr_enabled Peter Zijlstra
2009-05-24  7:02   ` [tip:perfcounters/core] perf_counter: Remove perf_counter_context::nr_enabled 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=20090523163012.618790733@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    /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