All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lin Ming <ming.m.lin@intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>,
	Matt Fleming <matt@console-pimps.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [RFC PATCH 1/2] perf: Enable group siblings on exec if attr::enable_on_exec set
Date: Wed, 10 Nov 2010 14:15:11 +0800	[thread overview]
Message-ID: <1289369711.2430.38.camel@minggr.sh.intel.com> (raw)

Currently, only group leader is enabled on exec.
This patch enables all group events on exec if attr::enable_on_exec is
set.

This is needed by next patch.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 kernel/perf_event.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 517d827..b94c18d 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -1700,11 +1700,29 @@ static int event_enable_on_exec(struct perf_event *event,
 	if (event->state >= PERF_EVENT_STATE_INACTIVE)
 		return 0;
 
-	__perf_event_mark_enabled(event, ctx);
+	event->state = PERF_EVENT_STATE_INACTIVE;
 
 	return 1;
 }
 
+static int group_enable_on_exec(struct perf_event *event,
+				struct perf_event_context *ctx)
+{
+	int enabled = 0;
+	struct perf_event *sub;
+
+	list_for_each_entry(sub, &event->sibling_list, group_entry)
+		if (event_enable_on_exec(sub, ctx))
+			enabled++;
+
+	if (event_enable_on_exec(event, ctx))
+		enabled++;
+
+	__perf_event_mark_enabled(event, ctx);
+
+	return enabled;
+}
+
 /*
  * Enable all of a task's events that have been marked enable-on-exec.
  * This expects task == current.
@@ -1725,13 +1743,13 @@ static void perf_event_enable_on_exec(struct perf_event_context *ctx)
 	raw_spin_lock(&ctx->lock);
 
 	list_for_each_entry(event, &ctx->pinned_groups, group_entry) {
-		ret = event_enable_on_exec(event, ctx);
+		ret = group_enable_on_exec(event, ctx);
 		if (ret)
 			enabled = 1;
 	}
 
 	list_for_each_entry(event, &ctx->flexible_groups, group_entry) {
-		ret = event_enable_on_exec(event, ctx);
+		ret = group_enable_on_exec(event, ctx);
 		if (ret)
 			enabled = 1;
 	}
-- 
1.7.1




             reply	other threads:[~2010-11-10  6:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-10  6:15 Lin Ming [this message]
2010-11-10 12:19 ` [RFC PATCH 1/2] perf: Enable group siblings on exec if attr::enable_on_exec set Peter Zijlstra
2010-11-10 14:17   ` Lin Ming
2010-11-10 14:38     ` Peter Zijlstra
2010-11-10 14:49       ` Lin Ming
2010-11-10 14:54         ` 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=1289369711.2430.38.camel@minggr.sh.intel.com \
    --to=ming.m.lin@intel.com \
    --cc=acme@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@console-pimps.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rui.zhang@intel.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.