Skip to content

Commit

Permalink
Merge branch 'perf-fixes-for-linus-2' of git://git.kernel.org/pub/scm…
Browse files Browse the repository at this point in the history
…/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  perf: Fix crash in swevents
  perf buildid-list: Fix --with-hits event processing
  perf scripts python: Give field dict to unhandled callback
  perf hist: fix objdump output parsing
  perf-record: Check correct pid when forking
  perf: Do the comm inheritance per thread in event__process_task
  perf: Use event__process_task from perf sched
  perf: Process comm events by tid
  blktrace: Fix new kernel-doc warnings
  perf_events: Fix unincremented buffer base on partial copy
  perf_events: Fix event scheduling issues introduced by transactional API
  perf_events, trace: Fix perf_trace_destroy(), mutex went missing
  perf_events, trace: Fix probe unregister race
  perf_events: Fix races in group composition
  perf_events: Fix races and clean up perf_event and perf_mmap_data interaction
  • Loading branch information
Linus Torvalds committed Jun 3, 2010
2 parents 636667a + c6df8d5 commit f150dba
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 176 deletions.
22 changes: 22 additions & 0 deletions arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct cpu_hw_events {

int n_events;
int n_added;
int n_txn;
int assign[X86_PMC_IDX_MAX]; /* event to counter assignment */
u64 tags[X86_PMC_IDX_MAX];
struct perf_event *event_list[X86_PMC_IDX_MAX]; /* in enabled order */
Expand Down Expand Up @@ -983,6 +984,7 @@ static int x86_pmu_enable(struct perf_event *event)
out:
cpuc->n_events = n;
cpuc->n_added += n - n0;
cpuc->n_txn += n - n0;

return 0;
}
Expand Down Expand Up @@ -1089,6 +1091,14 @@ static void x86_pmu_disable(struct perf_event *event)
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
int i;

/*
* If we're called during a txn, we don't need to do anything.
* The events never got scheduled and ->cancel_txn will truncate
* the event_list.
*/
if (cpuc->group_flag & PERF_EVENT_TXN_STARTED)
return;

x86_pmu_stop(event);

for (i = 0; i < cpuc->n_events; i++) {
Expand Down Expand Up @@ -1379,6 +1389,7 @@ static void x86_pmu_start_txn(const struct pmu *pmu)
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);

cpuc->group_flag |= PERF_EVENT_TXN_STARTED;
cpuc->n_txn = 0;
}

/*
Expand All @@ -1391,6 +1402,11 @@ static void x86_pmu_cancel_txn(const struct pmu *pmu)
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);

cpuc->group_flag &= ~PERF_EVENT_TXN_STARTED;
/*
* Truncate the collected events.
*/
cpuc->n_added -= cpuc->n_txn;
cpuc->n_events -= cpuc->n_txn;
}

/*
Expand Down Expand Up @@ -1419,6 +1435,12 @@ static int x86_pmu_commit_txn(const struct pmu *pmu)
*/
memcpy(cpuc->assign, assign, n*sizeof(int));

/*
* Clear out the txn count so that ->cancel_txn() which gets
* run after ->commit_txn() doesn't undo things.
*/
cpuc->n_txn = 0;

return 0;
}

Expand Down
9 changes: 7 additions & 2 deletions include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,14 @@ enum perf_event_active_state {
struct file;

struct perf_mmap_data {
atomic_t refcount;
struct rcu_head rcu_head;
#ifdef CONFIG_PERF_USE_VMALLOC
struct work_struct work;
int page_order; /* allocation order */
#endif
int nr_pages; /* nr of data pages */
int writable; /* are we writable */
int nr_locked; /* nr pages mlocked */

atomic_t poll; /* POLL_ for wakeups */

Expand Down Expand Up @@ -631,6 +631,9 @@ struct swevent_hlist {
struct rcu_head rcu_head;
};

#define PERF_ATTACH_CONTEXT 0x01
#define PERF_ATTACH_GROUP 0x02

/**
* struct perf_event - performance event kernel representation:
*/
Expand All @@ -643,10 +646,10 @@ struct perf_event {
int nr_siblings;
int group_flags;
struct perf_event *group_leader;
struct perf_event *output;
const struct pmu *pmu;

enum perf_event_active_state state;
unsigned int attach_state;
atomic64_t count;

/*
Expand Down Expand Up @@ -704,6 +707,8 @@ struct perf_event {
/* mmap bits */
struct mutex mmap_mutex;
atomic_t mmap_count;
int mmap_locked;
struct user_struct *mmap_user;
struct perf_mmap_data *data;

/* poll related */
Expand Down
2 changes: 1 addition & 1 deletion include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ perf_trace_##call(void *__data, proto) \
\
{ assign; } \
\
head = per_cpu_ptr(event_call->perf_events, smp_processor_id());\
head = this_cpu_ptr(event_call->perf_events); \
perf_trace_buf_submit(entry, __entry_size, rctx, __addr, \
__count, &__regs, head); \
}
Expand Down
Loading

0 comments on commit f150dba

Please sign in to comment.