Skip to content

Commit

Permalink
perf_events: Move code around to prepare for cgroup
Browse files Browse the repository at this point in the history
In particular this patch move perf_event_exit_task() before
cgroup_exit() to allow for cgroup support. The cgroup_exit()
function detaches the cgroups attached to a task.

Other movements include hoisting some definitions and inlines
at the top of perf_event.c

Signed-off-by: Stephane Eranian <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Jan 7, 2011
1 parent 23a2f3a commit 0b3fcf1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
14 changes: 9 additions & 5 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,15 @@ NORET_TYPE void do_exit(long code)
exit_fs(tsk);
check_stack_usage();
exit_thread();

/*
* Flush inherited counters to the parent - before the parent
* gets woken up by child-exit notifications.
*
* because of cgroup mode, must be called before cgroup_exit()
*/
perf_event_exit_task(tsk);

cgroup_exit(tsk, 1);

if (group_dead)
Expand All @@ -1007,11 +1016,6 @@ NORET_TYPE void do_exit(long code)
* FIXME: do that only when needed, using sched_exit tracepoint
*/
flush_ptrace_hw_breakpoint(tsk);
/*
* Flush inherited counters to the parent - before the parent
* gets woken up by child-exit notifications.
*/
perf_event_exit_task(tsk);

exit_notify(tsk, group_dead);
#ifdef CONFIG_NUMA
Expand Down
28 changes: 17 additions & 11 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@

#include <asm/irq_regs.h>

enum event_type_t {
EVENT_FLEXIBLE = 0x1,
EVENT_PINNED = 0x2,
EVENT_ALL = EVENT_FLEXIBLE | EVENT_PINNED,
};

atomic_t perf_task_events __read_mostly;
static atomic_t nr_mmap_events __read_mostly;
static atomic_t nr_comm_events __read_mostly;
Expand Down Expand Up @@ -65,13 +71,24 @@ int sysctl_perf_event_sample_rate __read_mostly = 100000;

static atomic64_t perf_event_id;

static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
enum event_type_t event_type);

static void cpu_ctx_sched_in(struct perf_cpu_context *cpuctx,
enum event_type_t event_type);

void __weak perf_event_print_debug(void) { }

extern __weak const char *perf_pmu_name(void)
{
return "pmu";
}

static inline u64 perf_clock(void)
{
return local_clock();
}

void perf_pmu_disable(struct pmu *pmu)
{
int *count = this_cpu_ptr(pmu->pmu_disable_count);
Expand Down Expand Up @@ -240,11 +257,6 @@ static void perf_unpin_context(struct perf_event_context *ctx)
put_ctx(ctx);
}

static inline u64 perf_clock(void)
{
return local_clock();
}

/*
* Update the record of the current time in a context.
*/
Expand Down Expand Up @@ -1193,12 +1205,6 @@ static int perf_event_refresh(struct perf_event *event, int refresh)
return 0;
}

enum event_type_t {
EVENT_FLEXIBLE = 0x1,
EVENT_PINNED = 0x2,
EVENT_ALL = EVENT_FLEXIBLE | EVENT_PINNED,
};

static void ctx_sched_out(struct perf_event_context *ctx,
struct perf_cpu_context *cpuctx,
enum event_type_t event_type)
Expand Down

0 comments on commit 0b3fcf1

Please sign in to comment.