summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-21 09:15:07 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-21 09:15:07 -0700
commit43c1266ce4dc06bfd236cec31e11e9ecd69c0bef (patch)
tree40a86739ca4c36200f447f655b01c57cfe646e26 /kernel
parentb8c7f1dc5ca4e0d10709182233cdab932cef593d (diff)
parent57c0c15b5244320065374ad2c54f4fbec77a6428 (diff)
Merge branch 'perfcounters-rename-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perfcounters-rename-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: perf: Tidy up after the big rename perf: Do the big rename: Performance Counters -> Performance Events perf_counter: Rename 'event' to event_id/hw_event perf_counter: Rename list_entry -> group_entry, counter_list -> group_list Manually resolved some fairly trivial conflicts with the tracing tree in include/trace/ftrace.h and kernel/trace/trace_syscalls.c.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/exit.c8
-rw-r--r--kernel/fork.c8
-rw-r--r--kernel/perf_event.c (renamed from kernel/perf_counter.c)2449
-rw-r--r--kernel/sched.c14
-rw-r--r--kernel/sys.c10
-rw-r--r--kernel/sys_ni.c2
-rw-r--r--kernel/sysctl.c22
-rw-r--r--kernel/timer.c4
-rw-r--r--kernel/trace/trace_syscalls.c6
10 files changed, 1262 insertions, 1263 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 7c9b0a585502..187c89b4783d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -95,7 +95,7 @@ obj-$(CONFIG_X86_DS) += trace/
obj-$(CONFIG_RING_BUFFER) += trace/
obj-$(CONFIG_SMP) += sched_cpupri.o
obj-$(CONFIG_SLOW_WORK) += slow-work.o
-obj-$(CONFIG_PERF_COUNTERS) += perf_counter.o
+obj-$(CONFIG_PERF_EVENTS) += perf_event.o
ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff --git a/kernel/exit.c b/kernel/exit.c
index ae5d8660ddff..e47ee8a06135 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -47,7 +47,7 @@
#include <linux/tracehook.h>
#include <linux/fs_struct.h>
#include <linux/init_task.h>
-#include <linux/perf_counter.h>
+#include <linux/perf_event.h>
#include <trace/events/sched.h>
#include <asm/uaccess.h>
@@ -154,8 +154,8 @@ static void delayed_put_task_struct(struct rcu_head *rhp)
{
struct task_struct *tsk = container_of(rhp, struct task_struct, rcu);
-#ifdef CONFIG_PERF_COUNTERS
- WARN_ON_ONCE(tsk->perf_counter_ctxp);
+#ifdef CONFIG_PERF_EVENTS
+ WARN_ON_ONCE(tsk->perf_event_ctxp);
#endif
trace_sched_process_free(tsk);
put_task_struct(tsk);
@@ -981,7 +981,7 @@ NORET_TYPE void do_exit(long code)
* Flush inherited counters to the parent - before the parent
* gets woken up by child-exit notifications.
*/
- perf_counter_exit_task(tsk);
+ perf_event_exit_task(tsk);
exit_notify(tsk, group_dead);
#ifdef CONFIG_NUMA
diff --git a/kernel/fork.c b/kernel/fork.c
index bfee931ee3fb..2cebfb23b0b8 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -61,7 +61,7 @@
#include <linux/blkdev.h>
#include <linux/fs_struct.h>
#include <linux/magic.h>
-#include <linux/perf_counter.h>
+#include <linux/perf_event.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@@ -1078,7 +1078,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
/* Perform scheduler related setup. Assign this task to a CPU. */
sched_fork(p, clone_flags);
- retval = perf_counter_init_task(p);
+ retval = perf_event_init_task(p);
if (retval)
goto bad_fork_cleanup_policy;
@@ -1253,7 +1253,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
write_unlock_irq(&tasklist_lock);
proc_fork_connector(p);
cgroup_post_fork(p);
- perf_counter_fork(p);
+ perf_event_fork(p);
return p;
bad_fork_free_pid:
@@ -1280,7 +1280,7 @@ bad_fork_cleanup_semundo:
bad_fork_cleanup_audit:
audit_free(p);
bad_fork_cleanup_policy:
- perf_counter_free_task(p);
+ perf_event_free_task(p);
#ifdef CONFIG_NUMA
mpol_put(p->mempolicy);
bad_fork_cleanup_cgroup:
diff --git a/kernel/perf_counter.c b/kernel/perf_event.c
index cc768ab81ac8..76ac4db405e9 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_event.c
@@ -1,12 +1,12 @@
/*
- * Performance counter core code
+ * Performance events core code:
*
* Copyright (C) 2008 Thomas Gleixner <tglx@linutronix.de>
* Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
* Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
* Copyright © 2009 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
*
- * For licensing details see kernel-base/COPYING
+ * For licensing details see kernel-base/COPYING
*/
#include <linux/fs.h>
@@ -26,66 +26,66 @@
#include <linux/syscalls.h>
#include <linux/anon_inodes.h>
#include <linux/kernel_stat.h>
-#include <linux/perf_counter.h>
+#include <linux/perf_event.h>
#include <asm/irq_regs.h>
/*
- * Each CPU has a list of per CPU counters:
+ * Each CPU has a list of per CPU events:
*/
DEFINE_PER_CPU(struct perf_cpu_context, perf_cpu_context);
-int perf_max_counters __read_mostly = 1;
+int perf_max_events __read_mostly = 1;
static int perf_reserved_percpu __read_mostly;
static int perf_overcommit __read_mostly = 1;
-static atomic_t nr_counters __read_mostly;
-static atomic_t nr_mmap_counters __read_mostly;
-static atomic_t nr_comm_counters __read_mostly;
-static atomic_t nr_task_counters __read_mostly;
+static atomic_t nr_events __read_mostly;
+static atomic_t nr_mmap_events __read_mostly;
+static atomic_t nr_comm_events __read_mostly;
+static atomic_t nr_task_events __read_mostly;
/*
- * perf counter paranoia level:
+ * perf event paranoia level:
* -1 - not paranoid at all
* 0 - disallow raw tracepoint access for unpriv
- * 1 - disallow cpu counters for unpriv
+ * 1 - disallow cpu events for unpriv
* 2 - disallow kernel profiling for unpriv
*/
-int sysctl_perf_counter_paranoid __read_mostly = 1;
+int sysctl_perf_event_paranoid __read_mostly = 1;
static inline bool perf_paranoid_tracepoint_raw(void)
{
- return sysctl_perf_counter_paranoid > -1;
+ return sysctl_perf_event_paranoid > -1;
}
static inline bool perf_paranoid_cpu(void)
{
- return sysctl_perf_counter_paranoid > 0;
+ return sysctl_perf_event_paranoid > 0;
}
static inline bool perf_paranoid_kernel(void)
{
- return sysctl_perf_counter_paranoid > 1;
+ return sysctl_perf_event_paranoid > 1;
}
-int sysctl_perf_counter_mlock __read_mostly = 512; /* 'free' kb per user */
+int sysctl_perf_event_mlock __read_mostly = 512; /* 'free' kb per user */
/*
- * max perf counter sample rate
+ * max perf event sample rate
*/
-int sysctl_perf_counter_sample_rate __read_mostly = 100000;
+int sysctl_perf_event_sample_rate __read_mostly = 100000;
-static atomic64_t perf_counter_id;
+static atomic64_t perf_event_id;
/*
- * Lock for (sysadmin-configurable) counter reservations:
+ * Lock for (sysadmin-configurable) event reservations:
*/
static DEFINE_SPINLOCK(perf_resource_lock);
/*
* Architecture provided APIs - weak aliases:
*/
-extern __weak const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
+extern __weak const struct pmu *hw_perf_event_init(struct perf_event *event)
{
return NULL;
}
@@ -93,18 +93,18 @@ extern __weak const struct pmu *hw_perf_counter_init(struct perf_counter *counte
void __weak hw_perf_disable(void) { barrier(); }
void __weak hw_perf_enable(void) { barrier(); }
-void __weak hw_perf_counter_setup(int cpu) { barrier(); }
-void __weak hw_perf_counter_setup_online(int cpu) { barrier(); }
+void __weak hw_perf_event_setup(int cpu) { barrier(); }
+void __weak hw_perf_event_setup_online(int cpu) { barrier(); }
int __weak
-hw_perf_group_sched_in(struct perf_counter *group_leader,
+hw_perf_group_sched_in(struct perf_event *group_leader,
struct perf_cpu_context *cpuctx,
- struct perf_counter_context *ctx, int cpu)
+ struct perf_event_context *ctx, int cpu)
{
return 0;
}
-void __weak perf_counter_print_debug(void) { }
+void __weak perf_event_print_debug(void) { }
static DEFINE_PER_CPU(int, perf_disable_count);
@@ -130,20 +130,20 @@ void perf_enable(void)
hw_perf_enable();
}
-static void get_ctx(struct perf_counter_context *ctx)
+static void get_ctx(struct perf_event_context *ctx)
{
WARN_ON(!atomic_inc_not_zero(&ctx->refcount));
}
static void free_ctx(struct rcu_head *head)
{
- struct perf_counter_context *ctx;
+ struct perf_event_context *ctx;
- ctx = container_of(head, struct perf_counter_context, rcu_head);
+ ctx = container_of(head, struct perf_event_context, rcu_head);
kfree(ctx);
}
-static void put_ctx(struct perf_counter_context *ctx)
+static void put_ctx(struct perf_event_context *ctx)
{
if (atomic_dec_and_test(&ctx->refcount)) {
if (ctx->parent_ctx)
@@ -154,7 +154,7 @@ static void put_ctx(struct perf_counter_context *ctx)
}
}
-static void unclone_ctx(struct perf_counter_context *ctx)
+static void unclone_ctx(struct perf_event_context *ctx)
{
if (ctx->parent_ctx) {
put_ctx(ctx->parent_ctx);
@@ -163,37 +163,37 @@ static void unclone_ctx(struct perf_counter_context *ctx)
}
/*
- * If we inherit counters we want to return the parent counter id
+ * If we inherit events we want to return the parent event id
* to userspace.
*/
-static u64 primary_counter_id(struct perf_counter *counter)
+static u64 primary_event_id(struct perf_event *event)
{
- u64 id = counter->id;
+ u64 id = event->id;
- if (counter->parent)
- id = counter->parent->id;
+ if (event->parent)
+ id = event->parent->id;
return id;
}
/*
- * Get the perf_counter_context for a task and lock it.
+ * Get the perf_event_context for a task and lock it.
* This has to cope with with the fact that until it is locked,
* the context could get moved to another task.
*/
-static struct perf_counter_context *
+static struct perf_event_context *
perf_lock_task_context(struct task_struct *task, unsigned long *flags)
{
- struct perf_counter_context *ctx;
+ struct perf_event_context *ctx;
rcu_read_lock();
retry:
- ctx = rcu_dereference(task->perf_counter_ctxp);
+ ctx = rcu_dereference(task->perf_event_ctxp);
if (ctx) {
/*
* If this context is a clone of another, it might
* get swapped for another underneath us by
- * perf_counter_task_sched_out, though the
+ * perf_event_task_sched_out, though the
* rcu_read_lock() protects us from any context
* getting freed. Lock the context and check if it
* got swapped before we could get the lock, and retry
@@ -201,7 +201,7 @@ perf_lock_task_context(struct task_struct *task, unsigned long *flags)
* can't get swapped on us any more.
*/
spin_lock_irqsave(&ctx->lock, *flags);
- if (ctx != rcu_dereference(task->perf_counter_ctxp)) {
+ if (ctx != rcu_dereference(task->perf_event_ctxp)) {
spin_unlock_irqrestore(&ctx->lock, *flags);
goto retry;
}
@@ -220,9 +220,9 @@ perf_lock_task_context(struct task_struct *task, unsigned long *flags)
* can't get swapped to another task. This also increments its
* reference count so that the context can't get freed.
*/
-static struct perf_counter_context *perf_pin_task_context(struct task_struct *task)
+static struct perf_event_context *perf_pin_task_context(struct task_struct *task)
{
- struct perf_counter_context *ctx;
+ struct perf_event_context *ctx;
unsigned long flags;
ctx = perf_lock_task_context(task, &flags);
@@ -233,7 +233,7 @@ static struct perf_counter_context *perf_pin_task_context(struct task_struct *ta
return ctx;
}
-static void perf_unpin_context(struct perf_counter_context *ctx)
+static void perf_unpin_context(struct perf_event_context *ctx)
{
unsigned long flags;
@@ -244,123 +244,122 @@ static void perf_unpin_context(struct perf_counter_context *ctx)
}
/*
- * Add a counter from the lists for its context.
+ * Add a event from the lists for its context.
* Must be called with ctx->mutex and ctx->lock held.
*/
static void
-list_add_counter(struct perf_counter *counter, struct perf_counter_context *ctx)
+list_add_event(struct perf_event *event, struct perf_event_context *ctx)
{
- struct perf_counter *group_leader = counter->group_leader;
+ struct perf_event *group_leader = event->group_leader;
/*
- * Depending on whether it is a standalone or sibling counter,
- * add it straight to the context's counter list, or to the group
+ * Depending on whether it is a standalone or sibling event,
+ * add it straight to the context's event list, or to the group
* leader's sibling list:
*/
- if (group_leader == counter)
- list_add_tail(&counter->list_entry, &ctx->counter_list);
+ if (group_leader == event)
+ list_add_tail(&event->group_entry, &ctx->group_list);
else {
- list_add_tail(&counter->list_entry, &group_leader->sibling_list);
+ list_add_tail(&event->group_entry, &group_leader->sibling_list);
group_leader->nr_siblings++;
}
- list_add_rcu(&counter->event_entry, &ctx->event_list);
- ctx->nr_counters++;
- if (counter->attr.inherit_stat)
+ list_add_rcu(&event->event_entry, &ctx->event_list);
+ ctx->nr_events++;
+ if (event->attr.inherit_stat)
ctx->nr_stat++;
}
/*
- * Remove a counter from the lists for its context.
+ * Remove a event from the lists for its context.
* Must be called with ctx->mutex and ctx->lock held.
*/
static void
-list_del_counter(struct perf_counter *counter, struct perf_counter_context *ctx)
+list_del_event(struct perf_event *event, struct perf_event_context *ctx)
{
- struct perf_counter *sibling, *tmp;
+ struct perf_event *sibling, *tmp;
- if (list_empty(&counter->list_entry))
+ if (list_empty(&event->group_entry))
return;
- ctx->nr_counters--;
- if (counter->attr.inherit_stat)
+ ctx->nr_events--;
+ if (event->attr.inherit_stat)
ctx->nr_stat--;
- list_del_init(&counter->list_entry);
- list_del_rcu(&counter->event_entry);
+ list_del_init(&event->group_entry);
+ list_del_rcu(&event->event_entry);
- if (counter->group_leader != counter)
- counter->group_leader->nr_siblings--;
+ if (event->group_leader != event)
+ event->group_leader->nr_siblings--;
/*
- * If this was a group counter with sibling counters then
- * upgrade the siblings to singleton counters by adding them
+ * If this was a group event with sibling events then
+ * upgrade the siblings to singleton events by adding them
* to the context list directly:
*/
- list_for_each_entry_safe(sibling, tmp,
- &counter->sibling_list, list_entry) {
+ list_for_each_entry_safe(sibling, tmp, &event->sibling_list, group_entry) {
- list_move_tail(&sibling->list_entry, &ctx->counter_list);
+ list_move_tail(&sibling->group_entry, &ctx->group_list);
sibling->group_leader = sibling;
}
}
static void
-counter_sched_out(struct perf_counter *counter,
+event_sched_out(struct perf_event *event,
struct perf_cpu_context *cpuctx,
- struct perf_counter_context *ctx)
+ struct perf_event_context *ctx)
{
- if (counter->state != PERF_COUNTER_STATE_ACTIVE)
+ if (event->state != PERF_EVENT_STATE_ACTIVE)
return;
- counter->state = PERF_COUNTER_STATE_INACTIVE;
- if (counter->pending_disable) {
- counter->pending_disable = 0;
- counter->state = PERF_COUNTER_STATE_OFF;
+ event->state = PERF_EVENT_STATE_INACTIVE;
+ if (event->pending_disable) {
+ event->pending_disable = 0;
+ event->state = PERF_EVENT_STATE_OFF;
}
- counter->tstamp_stopped = ctx->time;
- counter->pmu->disable(counter);
- counter->oncpu = -1;
+ event->tstamp_stopped = ctx->time;
+ event->pmu->disable(event);
+ event->oncpu = -1;
- if (!is_software_counter(counter))
+ if (!is_software_event(event))
cpuctx->active_oncpu--;
ctx->nr_active--;
- if (counter->attr.exclusive || !cpuctx->active_oncpu)
+ if (event->attr.exclusive || !cpuctx->active_oncpu)
cpuctx->exclusive = 0;
}
static void
-group_sched_out(struct perf_counter *group_counter,
+group_sched_out(struct perf_event *group_event,
struct perf_cpu_context *cpuctx,
- struct perf_counter_context *ctx)
+ struct perf_event_context *ctx)
{
- struct perf_counter *counter;
+ struct perf_event *event;
- if (group_counter->state != PERF_COUNTER_STATE_ACTIVE)
+ if (group_event->state != PERF_EVENT_STATE_ACTIVE)
return;
- counter_sched_out(group_counter, cpuctx, ctx);
+ event_sched_out(group_event, cpuctx, ctx);
/*
* Schedule out siblings (if any):
*/
- list_for_each_entry(counter, &group_counter->sibling_list, list_entry)
- counter_sched_out(counter, cpuctx, ctx);
+ list_for_each_entry(event, &group_event->sibling_list, group_entry)
+ event_sched_out(event, cpuctx, ctx);
- if (group_counter->attr.exclusive)
+ if (group_event->attr.exclusive)
cpuctx->exclusive = 0;
}
/*
- * Cross CPU call to remove a performance counter
+ * Cross CPU call to remove a performance event
*
- * We disable the counter on the hardware level first. After that we
+ * We disable the event on the hardware level first. After that we
* remove it from the context list.
*/
-static void __perf_counter_remove_from_context(void *info)
+static void __perf_event_remove_from_context(void *info)
{
struct perf_cpu_context *cpuctx = &__get_cpu_var(perf_cpu_context);
- struct perf_counter *counter = info;
- struct perf_counter_context *ctx = counter->ctx;
+ struct perf_event *event = info;
+ struct perf_event_context *ctx = event->ctx;
/*
* If this is a task context, we need to check whether it is
@@ -373,22 +372,22 @@ static void __perf_counter_remove_from_context(void *info)
spin_lock(&ctx->lock);
/*
* Protect the list operation against NMI by disabling the
- * counters on a global level.
+ * events on a global level.
*/
perf_disable();
- counter_sched_out(counter, cpuctx, ctx);
+ event_sched_out(event, cpuctx, ctx);
- list_del_counter(counter, ctx);
+ list_del_event(event, ctx);
if (!ctx->task) {
/*
- * Allow more per task counters with respect to the
+ * Allow more per task events with respect to the
* reservation:
*/
cpuctx->max_pertask =
- min(perf_max_counters - ctx->nr_counters,
- perf_max_counters - perf_reserved_percpu);
+ min(perf_max_events - ctx->nr_events,
+ perf_max_events - perf_reserved_percpu);
}
perf_enable();
@@ -397,56 +396,56 @@ static void __perf_counter_remove_from_context(void *info)
/*
- * Remove the counter from a task's (or a CPU's) list of counters.
+ * Remove the event from a task's (or a CPU's) list of events.
*
* Must be called with ctx->mutex held.
*
- * CPU counters are removed with a smp call. For task counters we only
+ * CPU events are removed with a smp call. For task events we only
* call when the task is on a CPU.
*
- * If counter->ctx is a cloned context, callers must make sure that
- * every task struct that counter->ctx->task could possibly point to
+ * If event->ctx is a cloned context, callers must make sure that
+ * every task struct that event->ctx->task could possibly point to
* remains valid. This is OK when called from perf_release since
* that only calls us on the top-level context, which can't be a clone.
- * When called from perf_counter_exit_task, it's OK because the
+ * When called from perf_event_exit_task, it's OK because the
* context has been detached from its task.
*/
-static void perf_counter_remove_from_context(struct perf_counter *counter)
+static void perf_event_remove_from_context(struct perf_event *event)
{
- struct perf_counter_context *ctx = counter->ctx;
+ struct perf_event_context *ctx = event->ctx;
struct task_struct *task = ctx->task;
if (!task) {
/*
- * Per cpu counters are removed via an smp call and
+ * Per cpu events are removed via an smp call and
* the removal is always sucessful.
*/
- smp_call_function_single(counter->cpu,
- __perf_counter_remove_from_context,
- counter, 1);
+ smp_call_function_single(event->cpu,
+ __perf_event_remove_from_context,
+ event, 1);
return;
}
retry:
- task_oncpu_function_call(task, __perf_counter_remove_from_context,
- counter);
+ task_oncpu_function_call(task, __perf_event_remove_from_context,
+ event);
spin_lock_irq(&ctx->lock);
/*
* If the context is active we need to retry the smp call.
*/
- if (ctx->nr_active && !list_empty(&counter->list_entry)) {
+ if (ctx->nr_active && !list_empty(&event->group_entry)) {
spin_unlock_irq(&ctx->lock);
goto retry;
}
/*
* The lock prevents that this context is scheduled in so we
- * can remove the counter safely, if the call above did not
+ * can remove the event safely, if the call above did not
* succeed.
*/
- if (!list_empty(&counter->list_entry)) {
- list_del_counter(counter, ctx);
+ if (!list_empty(&event->group_entry)) {
+ list_del_event(event, ctx);
}
spin_unlock_irq(&ctx->lock);
}
@@ -459,7 +458,7 @@ static inline u64 perf_clock(void)
/*
* Update the record of the current time in a context.
*/
-static void update_context_time(struct perf_counter_context *ctx)
+static void update_context_time(struct perf_event_context *ctx)
{
u64 now = perf_clock();
@@ -468,51 +467,51 @@ static void update_context_time(struct perf_counter_context *ctx)
}
/*
- * Update the total_time_enabled and total_time_running fields for a counter.
+ * Update the total_time_enabled and total_time_running fields for a event.
*/
-static void update_counter_times(struct perf_counter *counter)
+static void update_event_times(struct perf_event *event)
{
- struct perf_counter_context *ctx = counter->ctx;
+ struct perf_event_context *ctx = event->ctx;
u64 run_end;
- if (counter->state < PERF_COUNTER_STATE_INACTIVE ||
- counter->group_leader->state < PERF_COUNTER_STATE_INACTIVE)
+ if (event->state < PERF_EVENT_STATE_INACTIVE ||
+ event->group_leader->state < PERF_EVENT_STATE_INACTIVE)
return;
- counter->total_time_enabled = ctx->time - counter->tstamp_enabled;
+ event->total_time_enabled = ctx->time - event->tstamp_enabled;
- if (counter->state == PERF_COUNTER_STATE_INACTIVE)
- run_end = counter->tstamp_stopped;
+ if (event->state == PERF_EVENT_STATE_INACTIVE)
+ run_end = event->tstamp_stopped;
else
run_end = ctx->time;
- counter->total_time_running = run_end - counter->tstamp_running;
+ event->total_time_running = run_end - event->tstamp_running;
}
/*
- * Update total_time_enabled and total_time_running for all counters in a group.
+ * Update total_time_enabled and total_time_running for all events in a group.
*/
-static void update_group_times(struct perf_counter *leader)
+static void update_group_times(struct perf_event *leader)
{
- struct perf_counter *counter;
+ struct perf_event *event;
- update_counter_times(leader);
- list_for_each_entry(counter, &leader->sibling_list, list_entry)
- update_counter_times(counter);
+ update_event_times(leader);
+ list_for_each_entry(event, &leader->sibling_list, group_entry)
+ update_event_times(event);
}
/*
- * Cross CPU call to disable a performance counter
+ * Cross CPU call to disable a performance event
*/
-static void __perf_counter_disable(void *info)
+static void __perf_event_disable(void *info)
{
- struct perf_counter *counter = info;
+ struct perf_event *event = info;
struct perf_cpu_context *cpuctx = &__get_cpu_var(perf_cpu_context);
- struct perf_counter_context *ctx = counter->ctx;
+ struct perf_event_context *ctx = event->ctx;
/*
- * If this is a per-task counter, need to check whether this
- * counter's task is the current task on this cpu.
+ * If this is a per-task event, need to check whether this
+ * event's task is the current task on this cpu.
*/
if (ctx->task && cpuctx->task_ctx != ctx)
return;
@@ -520,57 +519,57 @@ static void __perf_counter_disable(void *info)
spin_lock(&ctx->lock);
/*
- * If the counter is on, turn it off.
+ * If the event is on, turn it off.
* If it is in error state, leave it in error state.
*/
- if (counter->state >= PERF_COUNTER_STATE_INACTIVE) {
+ if (event->state >= PERF_EVENT_STATE_INACTIVE) {
update_context_time(ctx);
- update_group_times(counter);
- if (counter == counter->group_leader)
- group_sched_out(counter, cpuctx, ctx);
+ update_group_times(event);
+ if (event == event->group_leader)
+ group_sched_out(event, cpuctx, ctx);
else
- counter_sched_out(counter, cpuctx, ctx);
- counter->state = PERF_COUNTER_STATE_OFF;
+ event_sched_out(event, cpuctx, ctx);
+ event->state = PERF_EVENT_STATE_OFF;
}
spin_unlock(&ctx->lock);
}
/*
- * Disable a counter.
+ * Disable a event.
*
- * If counter->ctx is a cloned context, callers must make sure that
- * every task struct that counter->ctx->task could possibly point to
+ * If event->ctx is a cloned context, callers must make sure that
+ * every task struct that event->ctx->task could possibly point to
* remains valid. This condition is satisifed when called through
- * perf_counter_for_each_child or perf_counter_for_each because they
- * hold the top-level counter's child_mutex, so any descendant that
- * goes to exit will block in sync_child_counter.
- * When called from perf_pending_counter it's OK because counter->ctx
+ * perf_event_for_each_child or perf_event_for_each because they
+ * hold the top-level event's child_mutex, so any descendant that
+ * goes to exit will block in sync_child_event.
+ * When called from perf_pending_event it's OK because event->ctx
* is the current context on this CPU and preemption is disabled,
- * hence we can't get into perf_counter_task_sched_out for this context.
+ * hence we can't get into perf_event_task_sched_out for this context.
*/
-static void perf_counter_disable(struct perf_counter *counter)
+static void perf_event_disable(struct perf_event *event)
{
- struct perf_counter_context *ctx = counter->ctx;
+ struct perf_event_context *ctx = event->ctx;
struct task_struct *task = ctx->task;
if (!task) {
/*
- * Disable the counter on the cpu that it's on
+ * Disable the event on the cpu that it's on
*/
- smp_call_function_single(counter->cpu, __perf_counter_disable,
- counter, 1);
+ smp_call_function_single(event->cpu, __perf_event_disable,
+ event, 1);
return;
}
retry:
- task_oncpu_function_call(task, __perf_counter_disable, counter);
+ task_oncpu_function_call(task, __perf_event_disable, event);
spin_lock_irq(&ctx->lock);
/*
- * If the counter is still active, we need to retry the cross-call.
+ * If the event is still active, we need to retry the cross-call.
*/
- if (counter->state == PERF_COUNTER_STATE_ACTIVE) {
+ if (event->state == PERF_EVENT_STATE_ACTIVE) {
spin_unlock_irq(&ctx->lock);
goto retry;
}
@@ -579,73 +578,73 @@ static void perf_counter_disable(struct perf_counter *counter)
* Since we have the lock this context can't be scheduled
* in, so we can change the state safely.
*/
- if (counter->state == PERF_COUNTER_STATE_INACTIVE) {
- update_group_times(counter);
- counter->state = PERF_COUNTER_STATE_OFF;
+ if (event->state == PERF_EVENT_STATE_INACTIVE) {
+ update_group_times(event);
+ event->state = PERF_EVENT_STATE_OFF;
}
spin_unlock_irq(&ctx->lock);
}
static int
-counter_sched_in(struct perf_counter *counter,
+event_sched_in(struct perf_event *event,
struct perf_cpu_context *cpuctx,
- struct perf_counter_context *ctx,
+ struct perf_event_context *ctx,
int cpu)
{
- if (counter->state <= PERF_COUNTER_STATE_OFF)
+ if (event->state <= PERF_EVENT_STATE_OFF)
return 0;
- counter->state = PERF_COUNTER_STATE_ACTIVE;
- counter->oncpu = cpu; /* TODO: put 'cpu' into cpuctx->cpu */
+ event->state = PERF_EVENT_STATE_ACTIVE;
+ event->oncpu = cpu; /* TODO: put 'cpu' into cpuctx->cpu */
/*
* The new state must be visible before we turn it on in the hardware:
*/
smp_wmb();
- if (counter->pmu->enable(counter)) {
- counter->state = PERF_COUNTER_STATE_INACTIVE;
- counter->oncpu = -1;
+ if (event->pmu->enable(event)) {
+ event->state = PERF_EVENT_STATE_INACTIVE;
+ event->oncpu = -1;
return -EAGAIN;
}
- counter->tstamp_running += ctx->time - counter->tstamp_stopped;
+ event->tstamp_running += ctx->time - event->tstamp_stopped;
- if (!is_software_counter(counter))
+ if (!is_software_event(event))
cpuctx->active_oncpu++;
ctx->nr_active++;
- if (counter->attr.exclusive)
+ if (event->attr.exclusive)
cpuctx->exclusive = 1;
return 0;
}
static int
-group_sched_in(struct perf_counter *group_counter,
+group_sched_in(struct perf_event *group_event,
struct perf_cpu_context *cpuctx,
- struct perf_counter_context *ctx,
+ struct perf_event_context *ctx,
int cpu)
{
- struct perf_counter *counter, *partial_group;
+ struct perf_event *event, *partial_group;
int ret;
- if (group_counter->state == PERF_COUNTER_STATE_OFF)
+ if (group_event->state == PERF_EVENT_STATE_OFF)
return 0;
- ret = hw_perf_group_sched_in(group_counter, cpuctx, ctx, cpu);
+ ret = hw_perf_group_sched_in(group_event, cpuctx, ctx, cpu);
if (ret)
return ret < 0 ? ret : 0;
- if (counter_sched_in(group_counter, cpuctx, ctx, cpu))
+ if (event_sched_in(group_event, cpuctx, ctx, cpu))
return -EAGAIN;
/*
* Schedule in siblings as one group (if any):
*/
- list_for_each_entry(counter, &group_counter->sibling_list, list_entry) {
- if (counter_sched_in(counter, cpuctx, ctx, cpu)) {
- partial_group = counter;
+ list_for_each_entry(event, &group_event->sibling_list, group_entry) {
+ if (event_sched_in(event, cpuctx, ctx, cpu)) {
+ partial_group = event;
goto group_error;
}
}
@@ -657,57 +656,57 @@ group_error:
* Groups can be scheduled in as one unit only, so undo any
* partial group before returning:
*/
- list_for_each_entry(counter, &group_counter->sibling_list, list_entry) {
- if (counter == partial_group)
+ list_for_each_entry(event, &group_event->sibling_list, group_entry) {
+ if (event == partial_group)
break;
- counter_sched_out(counter, cpuctx, ctx);
+ event_sched_out(event, cpuctx, ctx);
}
- counter_sched_out(group_counter, cpuctx, ctx);
+ event_sched_out(group_event, cpuctx, ctx);
return -EAGAIN;
}
/*
- * Return 1 for a group consisting entirely of software counters,
- * 0 if the group contains any hardware counters.
+ * Return 1 for a group consisting entirely of software events,
+ * 0 if the group contains any hardware events.
*/
-static int is_software_only_group(struct perf_counter *leader)
+static int is_software_only_group(struct perf_event *leader)
{
- struct perf_counter *counter;
+ struct perf_event *event;
- if (!is_software_counter(leader))
+ if (!is_software_event(leader))
return 0;
- list_for_each_entry(counter, &leader->sibling_list, list_entry)
- if (!is_software_counter(counter))
+ list_for_each_entry(event, &leader->sibling_list, group_entry)
+ if (!is_software_event(event))
return 0;
return 1;
}
/*
- * Work out whether we can put this counter group on the CPU now.
+ * Work out whether we can put this event group on the CPU now.
*/
-static int group_can_go_on(struct perf_counter *counter,
+static int group_can_go_on(struct perf_event *event,
struct perf_cpu_context *cpuctx,
int can_add_hw)
{
/*
- * Groups consisting entirely of software counters can always go on.
+ * Groups consisting entirely of software events can always go on.
*/
- if (is_software_only_group(counter))
+ if (is_software_only_group(event))
return 1;
/*
* If an exclusive group is already on, no other hardware
- * counters can go on.
+ * events can go on.
*/
if (cpuctx->exclusive)
return 0;
/*
* If this group is exclusive and there are already
- * counters on the CPU, it can't go on.
+ * events on the CPU, it can't go on.
*/
- if (counter->attr.exclusive && cpuctx->active_oncpu)
+ if (event->attr.exclusive && cpuctx->active_oncpu)
return 0;
/*
* Otherwise, try to add it if all previous groups were able
@@ -716,26 +715,26 @@ static int group_can_go_on(struct perf_counter *counter,
return can_add_hw;
}
-static void add_counter_to_ctx(struct perf_counter *counter,
- struct perf_counter_context *ctx)
+static void add_event_to_ctx(struct perf_event *event,
+ struct perf_event_context *ctx)
{
- list_add_counter(counter, ctx);
- counter->tstamp_enabled = ctx->time;
- counter->tstamp_running = ctx->time;
- counter->tstamp_stopped = ctx->time;
+ list_add_event(event, ctx);
+ event->tstamp_enabled = ctx->time;
+ event->tstamp_running = ctx->time;
+ event->tstamp_stopped = ctx->time;
}
/*
- * Cross CPU call to install and enable a performance counter
+ * Cross CPU call to install and enable a performance event
*
* Must be called with ctx->mutex held
*/
static void __perf_install_in_context(void *info)
{
struct perf_cpu_context *cpuctx = &__get_cpu_var(perf_cpu_context);
- struct perf_counter *counter = info;
- struct perf_counter_context *ctx = counter->ctx;
- struct perf_counter *leader = counter->group_leader;
+ struct perf_event *event = info;
+ struct perf_event_context *ctx = event->ctx;
+ struct perf_event *leader = event->group_leader;
int cpu = smp_processor_id();
int