stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Andreas Hollmann <hollmann@in.tum.de>,
	Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Stephane Eranian <eranian@google.com>,
	Vince Weaver <vince@deater.net>, Ingo Molnar <mingo@kernel.org>,
	Li Zefan <lizefan@huawei.com>
Subject: [ 12/22] perf: Fix event group context move
Date: Thu,  8 Aug 2013 18:41:28 -0700	[thread overview]
Message-ID: <20130809013951.854896075@linuxfoundation.org> (raw)
In-Reply-To: <20130809013949.226228694@linuxfoundation.org>

3.0-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiri Olsa <jolsa@redhat.com>

commit 0231bb5336758426b44ccd798ccd3c5419c95d58 upstream.

When we have group with mixed events (hw/sw) we want to end up
with group leader being in hw context. So if group leader is
initialy sw event, we move all the events under hw context.

The move is done for each event by removing it from its context
and adding it back into proper one. As a part of the removal the
event is automatically disabled, which is not what we want at
this stage of creating groups.

The fix is to initialize event state after removal from sw
context.

This fix resulted from the following discussion:

  http://thread.gmane.org/gmane.linux.kernel.perf.user/1144

Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vince@deater.net>
Link: http://lkml.kernel.org/r/1359714225-4231-1-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/events/core.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -839,6 +839,15 @@ list_add_event(struct perf_event *event,
 }
 
 /*
+ * Initialize event state based on the perf_event_attr::disabled.
+ */
+static inline void perf_event__state_init(struct perf_event *event)
+{
+	event->state = event->attr.disabled ? PERF_EVENT_STATE_OFF :
+					      PERF_EVENT_STATE_INACTIVE;
+}
+
+/*
  * Called at perf_event creation and when events are attached/detached from a
  * group.
  */
@@ -6241,8 +6250,7 @@ perf_event_alloc(struct perf_event_attr
 
 	event->overflow_handler	= overflow_handler;
 
-	if (attr->disabled)
-		event->state = PERF_EVENT_STATE_OFF;
+	perf_event__state_init(event);
 
 	pmu = NULL;
 
@@ -6616,9 +6624,17 @@ SYSCALL_DEFINE5(perf_event_open,
 
 		mutex_lock(&gctx->mutex);
 		perf_remove_from_context(group_leader);
+
+		/*
+		 * Removing from the context ends up with disabled
+		 * event. What we want here is event in the initial
+		 * startup state, ready to be add into new context.
+		 */
+		perf_event__state_init(group_leader);
 		list_for_each_entry(sibling, &group_leader->sibling_list,
 				    group_entry) {
 			perf_remove_from_context(sibling);
+			perf_event__state_init(sibling);
 			put_ctx(gctx);
 		}
 		mutex_unlock(&gctx->mutex);



  parent reply	other threads:[~2013-08-09  1:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09  1:41 [ 00/22] 3.0.90-stable review Greg Kroah-Hartman
2013-08-09  1:41 ` [ 01/22] serial/mxs-auart: fix race condition in interrupt handler Greg Kroah-Hartman
2013-08-09  1:41 ` [ 02/22] serial/mxs-auart: increase time to wait for transmitter to become idle Greg Kroah-Hartman
2013-08-09  1:41 ` [ 03/22] ath9k_htc: do some initial hardware configuration Greg Kroah-Hartman
2013-08-09  1:41 ` [ 04/22] nl80211: fix mgmt tx status and testmode reporting for netns Greg Kroah-Hartman
2013-08-09  1:41 ` [ 05/22] mac80211: fix duplicate retransmission detection Greg Kroah-Hartman
2013-08-09  1:41 ` [ 06/22] rt2x00: fix stop queue Greg Kroah-Hartman
2013-08-09  1:41 ` [ 07/22] mwifiex: Add missing endian conversion Greg Kroah-Hartman
2013-08-09  1:41 ` [ 08/22] ACPI / battery: Fix parsing _BIX return value Greg Kroah-Hartman
2013-08-09  1:41 ` [ 09/22] sched: Fix the broken sched_rr_get_interval() Greg Kroah-Hartman
2013-08-09  1:41 ` [ 10/22] fanotify: info leak in copy_event_to_user() Greg Kroah-Hartman
2013-08-09  1:41 ` [ 11/22] MAINTAINERS: fix up stable_kernel_rules.txt location Greg Kroah-Hartman
2013-08-09  1:41 ` Greg Kroah-Hartman [this message]
2013-08-09  1:41 ` [ 13/22] x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz Greg Kroah-Hartman
2013-08-09  1:41 ` [ 14/22] perf: Use css_tryget() to avoid propping up css refcount Greg Kroah-Hartman
2013-08-09  1:41 ` [ 15/22] arcnet: cleanup sizeof parameter Greg Kroah-Hartman
2013-08-09  1:41 ` [ 16/22] sysctl net: Keep tcp_syn_retries inside the boundary Greg Kroah-Hartman
2013-08-09  1:41 ` [ 17/22] sctp: fully initialize sctp_outq in sctp_outq_init Greg Kroah-Hartman
2013-08-09  1:41 ` [ 18/22] ipv6: take rtnl_lock and mark mrt6 table as freed on namespace cleanup Greg Kroah-Hartman
2013-08-09  1:41 ` [ 19/22] usbnet: do not pretend to support SG/TSO Greg Kroah-Hartman
2013-08-09  1:41 ` [ 20/22] net_sched: Fix stack info leak in cbq_dump_wrr() Greg Kroah-Hartman
2013-08-09  1:41 ` [ 21/22] af_key: more info leaks in pfkey messages Greg Kroah-Hartman
2013-08-09  1:41 ` [ 22/22] net_sched: info leak in atm_tc_dump_class() Greg Kroah-Hartman
2013-08-09  3:42 ` [ 00/22] 3.0.90-stable review Guenter Roeck
2013-08-09  3:56   ` Greg Kroah-Hartman
2013-08-10 22:08 ` Shuah Khan

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=20130809013951.854896075@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hollmann@in.tum.de \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=stable@vger.kernel.org \
    --cc=vince@deater.net \
    /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;
as well as URLs for NNTP newsgroup(s).