Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349500
b: refs/heads/master
c: 0231bb5
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Ingo Molnar committed Feb 3, 2013
1 parent 658f465 commit b895c3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 923d8697e24847000490c187de1aeaca622611a3
refs/heads/master: 0231bb5336758426b44ccd798ccd3c5419c95d58
20 changes: 18 additions & 2 deletions trunk/kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,15 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx)
ctx->nr_stat++;
}

/*
* 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.
Expand Down Expand Up @@ -6179,8 +6188,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
event->overflow_handler = overflow_handler;
event->overflow_handler_context = context;

if (attr->disabled)
event->state = PERF_EVENT_STATE_OFF;
perf_event__state_init(event);

pmu = NULL;

Expand Down Expand Up @@ -6609,9 +6617,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);
Expand Down

0 comments on commit b895c3b

Please sign in to comment.