Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147261
b: refs/heads/master
c: 4a0deca
h: refs/heads/master
i:
  147259: d38ff53
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 6, 2009
1 parent 38f8a1f commit e136f29
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 64 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: 01ef09d9ffb5ce9f8d62d1e5206da3d5ca612acc
refs/heads/master: 4a0deca657f3dbb8a707b5dc8f173beec01e7ed2
1 change: 0 additions & 1 deletion trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ extern unsigned long nr_running(void);
extern unsigned long nr_uninterruptible(void);
extern unsigned long nr_active(void);
extern unsigned long nr_iowait(void);
extern u64 cpu_nr_switches(int cpu);
extern u64 cpu_nr_migrations(int cpu);

extern unsigned long get_parent_ip(unsigned long addr);
Expand Down
60 changes: 4 additions & 56 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,13 @@ void perf_counter_task_sched_out(struct task_struct *task, int cpu)
{
struct perf_cpu_context *cpuctx = &per_cpu(perf_cpu_context, cpu);
struct perf_counter_context *ctx = &task->perf_counter_ctx;
struct pt_regs *regs;

if (likely(!cpuctx->task_ctx))
return;

regs = task_pt_regs(task);
perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs);
__perf_counter_sched_out(ctx, cpuctx);

cpuctx->task_ctx = NULL;
Expand Down Expand Up @@ -1667,58 +1670,6 @@ static const struct hw_perf_counter_ops perf_ops_task_clock = {
.read = task_clock_perf_counter_read,
};

/*
* Software counter: context switches
*/

static u64 get_context_switches(struct perf_counter *counter)
{
struct task_struct *curr = counter->ctx->task;

if (curr)
return curr->nvcsw + curr->nivcsw;
return cpu_nr_switches(smp_processor_id());
}

static void context_switches_perf_counter_update(struct perf_counter *counter)
{
u64 prev, now;
s64 delta;

prev = atomic64_read(&counter->hw.prev_count);
now = get_context_switches(counter);

atomic64_set(&counter->hw.prev_count, now);

delta = now - prev;

atomic64_add(delta, &counter->count);
}

static void context_switches_perf_counter_read(struct perf_counter *counter)
{
context_switches_perf_counter_update(counter);
}

static int context_switches_perf_counter_enable(struct perf_counter *counter)
{
if (counter->prev_state <= PERF_COUNTER_STATE_OFF)
atomic64_set(&counter->hw.prev_count,
get_context_switches(counter));
return 0;
}

static void context_switches_perf_counter_disable(struct perf_counter *counter)
{
context_switches_perf_counter_update(counter);
}

static const struct hw_perf_counter_ops perf_ops_context_switches = {
.enable = context_switches_perf_counter_enable,
.disable = context_switches_perf_counter_disable,
.read = context_switches_perf_counter_read,
};

/*
* Software counter: cpu migrations
*/
Expand Down Expand Up @@ -1808,11 +1759,8 @@ sw_perf_counter_init(struct perf_counter *counter)
case PERF_COUNT_PAGE_FAULTS:
case PERF_COUNT_PAGE_FAULTS_MIN:
case PERF_COUNT_PAGE_FAULTS_MAJ:
hw_ops = &perf_ops_generic;
break;
case PERF_COUNT_CONTEXT_SWITCHES:
if (!counter->hw_event.exclude_kernel)
hw_ops = &perf_ops_context_switches;
hw_ops = &perf_ops_generic;
break;
case PERF_COUNT_CPU_MIGRATIONS:
if (!counter->hw_event.exclude_kernel)
Expand Down
6 changes: 0 additions & 6 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2900,14 +2900,8 @@ unsigned long nr_active(void)

/*
* Externally visible per-cpu scheduler statistics:
* cpu_nr_switches(cpu) - number of context switches on that cpu
* cpu_nr_migrations(cpu) - number of migrations into that cpu
*/
u64 cpu_nr_switches(int cpu)
{
return cpu_rq(cpu)->nr_switches;
}

u64 cpu_nr_migrations(int cpu)
{
return cpu_rq(cpu)->nr_migrations_in;
Expand Down

0 comments on commit e136f29

Please sign in to comment.