[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1380113447-17144-12-git-send-email-jolsa@redhat.com>
Date: Wed, 25 Sep 2013 14:50:37 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: Jiri Olsa <jolsa@...hat.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 11/21] perf: Split allocation and initialization code
From: Frederic Weisbecker <fweisbec@...il.com>
Do this in order to prepare for toggle event inheritance support
that will rely on pre-allocated perf event.
Signed-off-by: Frederic Weisbecker <fweisbec@...il.com>
Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
---
kernel/events/core.c | 59 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 20 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2a19b64..fa1d229 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6673,31 +6673,23 @@ static void account_event(struct perf_event *event)
account_event_cpu(event, event->cpu);
}
-/*
- * Allocate and initialize a event structure
- */
-static struct perf_event *
-perf_event_alloc(struct perf_event_attr *attr, int cpu,
- struct task_struct *task,
- struct perf_event *group_leader,
- struct perf_event *parent_event,
- perf_overflow_handler_t overflow_handler,
- void *context)
+static int perf_init_event(struct perf_event *event,
+ struct perf_event_attr *attr, int cpu,
+ struct task_struct *task,
+ struct perf_event *group_leader,
+ struct perf_event *parent_event,
+ perf_overflow_handler_t overflow_handler,
+ void *context)
{
struct pmu *pmu;
- struct perf_event *event;
struct hw_perf_event *hwc;
- long err = -EINVAL;
+ int err = -EINVAL;
if ((unsigned)cpu >= nr_cpu_ids) {
if (!task || cpu != -1)
- return ERR_PTR(-EINVAL);
+ return err;
}
- event = kzalloc(sizeof(*event), GFP_KERNEL);
- if (!event)
- return ERR_PTR(-ENOMEM);
-
/*
* Single events are their own group leaders, with an
* empty sibling list:
@@ -6791,7 +6783,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
}
}
- return event;
+ return 0;
err_pmu:
if (event->destroy)
@@ -6799,9 +6791,36 @@ err_pmu:
err_ns:
if (event->ns)
put_pid_ns(event->ns);
- kfree(event);
- return ERR_PTR(err);
+ return err;
+}
+
+/*
+ * Allocate and initialize a event structure
+ */
+static struct perf_event *
+perf_event_alloc(struct perf_event_attr *attr, int cpu,
+ struct task_struct *task,
+ struct perf_event *group_leader,
+ struct perf_event *parent_event,
+ perf_overflow_handler_t overflow_handler,
+ void *context)
+{
+ struct perf_event *event;
+ int err;
+
+ event = kzalloc(sizeof(*event), GFP_KERNEL);
+ if (!event)
+ return ERR_PTR(-ENOMEM);
+
+ err = perf_init_event(event, attr, cpu, task, group_leader,
+ parent_event, overflow_handler, context);
+ if (err) {
+ kfree(event);
+ return ERR_PTR(err);
+ }
+
+ return event;
}
static int perf_copy_attr(struct perf_event_attr __user *uattr,
--
1.7.11.7
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists