All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Stephane Eranian <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, eranian@google.com, hpa@zytor.com,
	mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de
Subject: [tip:perf/core] perf/x86: Fix active_entry initialization
Date: Sun, 12 Jan 2014 10:42:47 -0800	[thread overview]
Message-ID: <tip-f3ae75de98c4bac145a87d830c156c96f9414022@git.kernel.org> (raw)
In-Reply-To: <1389176153-3128-2-git-send-email-eranian@google.com>

Commit-ID:  f3ae75de98c4bac145a87d830c156c96f9414022
Gitweb:     http://git.kernel.org/tip/f3ae75de98c4bac145a87d830c156c96f9414022
Author:     Stephane Eranian <eranian@google.com>
AuthorDate: Wed, 8 Jan 2014 11:15:52 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 12 Jan 2014 10:16:07 +0100

perf/x86: Fix active_entry initialization

This patch fixes a problem with the initialization of the
struct perf_event active_entry field. It is defined inside
an anonymous union and was initialized in perf_event_alloc()
using INIT_LIST_HEAD(). However at that time, we do not know
whether the event is going to use active_entry or hlist_entry (SW).
Or at last, we don't want to make that determination there.
The problem is that hlist and list_head are not initialized
the same way. One is okay with NULL (from kzmalloc), the other
needs to pointers to point to self.

This patch resolves this problem by dropping the union.
This will avoid problems later on, if someone starts using
active_entry or hlist_entry without verifying that they
actually overlap. This also solves the initialization
problem.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: ak@linux.intel.com
Cc: acme@redhat.com
Cc: jolsa@redhat.com
Cc: zheng.z.yan@intel.com
Cc: bp@alien8.de
Cc: vincent.weaver@maine.edu
Cc: maria.n.dimakopoulou@gmail.com
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1389176153-3128-2-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/perf_event.h | 6 ++----
 kernel/events/core.c       | 2 ++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 8f4a70f..e56b07f 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -319,10 +319,8 @@ struct perf_event {
 	 */
 	struct list_head		migrate_entry;
 
-	union {
-		struct hlist_node	hlist_entry;
-		struct list_head	active_entry;
-	};
+	struct hlist_node		hlist_entry;
+	struct list_head		active_entry;
 	int				nr_siblings;
 	int				group_flags;
 	struct perf_event		*group_leader;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 89d34f9..c3b6c27 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6670,6 +6670,8 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
 	INIT_LIST_HEAD(&event->sibling_list);
 	INIT_LIST_HEAD(&event->rb_entry);
 	INIT_LIST_HEAD(&event->active_entry);
+	INIT_HLIST_NODE(&event->hlist_entry);
+
 
 	init_waitqueue_head(&event->waitq);
 	init_irq_work(&event->pending, perf_pending_event);

  reply	other threads:[~2014-01-12 18:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 10:15 [PATCH v2 0/2] perf/x86: various RAPL improvements and fixes Stephane Eranian
2014-01-08 10:15 ` [PATCH v2 1/2] perf/x86: fix active_entry initialization Stephane Eranian
2014-01-12 18:42   ` tip-bot for Stephane Eranian [this message]
2014-01-13 15:45     ` [tip:perf/core] perf/x86: Fix " Peter Zijlstra
2014-01-13 15:49       ` Stephane Eranian
2014-01-08 10:15 ` [PATCH v2 2/2] perf/x86: add RAPL PP1 energy counter support Stephane Eranian
2014-01-12 18:42   ` [tip:perf/core] perf/x86/intel: Add Intel " tip-bot for Stephane Eranian
2014-01-08 11:28 ` [PATCH v2 0/2] perf/x86: various RAPL improvements and fixes 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=tip-f3ae75de98c4bac145a87d830c156c96f9414022@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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.