Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163799
b: refs/heads/master
c: a4304f2
h: refs/heads/master
i:
  163797: d6599ad
  163795: ce5f56b
  163791: 9579214
v: v3
  • Loading branch information
Tilman Schmidt authored and Live-CD User committed Sep 19, 2009
1 parent c060f40 commit a2b3863
Show file tree
Hide file tree
Showing 42 changed files with 767 additions and 4,583 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: 467f9957d9283be40101d7255d06fae7e211ff4c
refs/heads/master: a4304f2d5a3823deea894026ec95e43b33912357
17 changes: 17 additions & 0 deletions trunk/Documentation/trace/power.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
The power tracer collects detailed information about C-state and P-state
transitions, instead of just looking at the high-level "average"
information.

There is a helper script found in scrips/tracing/power.pl in the kernel
sources which can be used to parse this information and create a
Scalable Vector Graphics (SVG) picture from the trace data.

To use this tracer:

echo 0 > /sys/kernel/debug/tracing/tracing_enabled
echo power > /sys/kernel/debug/tracing/current_tracer
echo 1 > /sys/kernel/debug/tracing/tracing_enabled
sleep 1
echo 0 > /sys/kernel/debug/tracing/tracing_enabled
cat /sys/kernel/debug/tracing/trace | \
perl scripts/tracing/power.pl > out.sv
7 changes: 5 additions & 2 deletions trunk/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <linux/cpufreq.h>
#include <linux/compiler.h>
#include <linux/dmi.h>
#include <trace/events/power.h>
#include <trace/power.h>

#include <linux/acpi.h>
#include <linux/io.h>
Expand Down Expand Up @@ -72,6 +72,8 @@ static DEFINE_PER_CPU(struct acpi_cpufreq_data *, drv_data);

static DEFINE_PER_CPU(struct aperfmperf, old_perf);

DEFINE_TRACE(power_mark);

/* acpi_perf_data is a pointer to percpu data. */
static struct acpi_processor_performance *acpi_perf_data;

Expand Down Expand Up @@ -330,6 +332,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
unsigned int next_perf_state = 0; /* Index into perf table */
unsigned int i;
int result = 0;
struct power_trace it;

dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);

Expand Down Expand Up @@ -361,7 +364,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
}
}

trace_power_frequency(POWER_PSTATE, data->freq_table[next_state].frequency);
trace_power_mark(&it, POWER_PSTATE, next_perf_state);

switch (data->cpu_feature) {
case SYSTEM_INTEL_MSR_CAPABLE:
Expand Down
60 changes: 23 additions & 37 deletions trunk/arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ static u64 perf_counter_mask __read_mostly;
#define BTS_RECORD_SIZE 24

/* The size of a per-cpu BTS buffer in bytes: */
#define BTS_BUFFER_SIZE (BTS_RECORD_SIZE * 2048)
#define BTS_BUFFER_SIZE (BTS_RECORD_SIZE * 1024)

/* The BTS overflow threshold in bytes from the end of the buffer: */
#define BTS_OVFL_TH (BTS_RECORD_SIZE * 128)
#define BTS_OVFL_TH (BTS_RECORD_SIZE * 64)


/*
Expand Down Expand Up @@ -1488,7 +1488,8 @@ void perf_counter_print_debug(void)
local_irq_restore(flags);
}

static void intel_pmu_drain_bts_buffer(struct cpu_hw_counters *cpuc)
static void intel_pmu_drain_bts_buffer(struct cpu_hw_counters *cpuc,
struct perf_sample_data *data)
{
struct debug_store *ds = cpuc->ds;
struct bts_record {
Expand All @@ -1497,11 +1498,8 @@ static void intel_pmu_drain_bts_buffer(struct cpu_hw_counters *cpuc)
u64 flags;
};
struct perf_counter *counter = cpuc->counters[X86_PMC_IDX_FIXED_BTS];
unsigned long orig_ip = data->regs->ip;
struct bts_record *at, *top;
struct perf_output_handle handle;
struct perf_event_header header;
struct perf_sample_data data;
struct pt_regs regs;

if (!counter)
return;
Expand All @@ -1512,38 +1510,19 @@ static void intel_pmu_drain_bts_buffer(struct cpu_hw_counters *cpuc)
at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
top = (struct bts_record *)(unsigned long)ds->bts_index;

if (top <= at)
return;

ds->bts_index = ds->bts_buffer_base;


data.period = counter->hw.last_period;
data.addr = 0;
regs.ip = 0;

/*
* Prepare a generic sample, i.e. fill in the invariant fields.
* We will overwrite the from and to address before we output
* the sample.
*/
perf_prepare_sample(&header, &data, counter, &regs);

if (perf_output_begin(&handle, counter,
header.size * (top - at), 1, 1))
return;

for (; at < top; at++) {
data.ip = at->from;
data.addr = at->to;
data->regs->ip = at->from;
data->addr = at->to;

perf_output_sample(&handle, &header, &data, counter);
perf_counter_output(counter, 1, data);
}

perf_output_end(&handle);
data->regs->ip = orig_ip;
data->addr = 0;

/* There's new data available. */
counter->hw.interrupts++;
counter->pending_kill = POLL_IN;
}

Expand Down Expand Up @@ -1573,9 +1552,13 @@ static void x86_pmu_disable(struct perf_counter *counter)
x86_perf_counter_update(counter, hwc, idx);

/* Drain the remaining BTS records. */
if (unlikely(idx == X86_PMC_IDX_FIXED_BTS))
intel_pmu_drain_bts_buffer(cpuc);
if (unlikely(idx == X86_PMC_IDX_FIXED_BTS)) {
struct perf_sample_data data;
struct pt_regs regs;

data.regs = &regs;
intel_pmu_drain_bts_buffer(cpuc, &data);
}
cpuc->counters[idx] = NULL;
clear_bit(idx, cpuc->used_mask);

Expand Down Expand Up @@ -1636,6 +1619,7 @@ static int p6_pmu_handle_irq(struct pt_regs *regs)
int idx, handled = 0;
u64 val;

data.regs = regs;
data.addr = 0;

cpuc = &__get_cpu_var(cpu_hw_counters);
Expand All @@ -1660,7 +1644,7 @@ static int p6_pmu_handle_irq(struct pt_regs *regs)
if (!x86_perf_counter_set_period(counter, hwc, idx))
continue;

if (perf_counter_overflow(counter, 1, &data, regs))
if (perf_counter_overflow(counter, 1, &data))
p6_pmu_disable_counter(hwc, idx);
}

Expand All @@ -1681,12 +1665,13 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
int bit, loops;
u64 ack, status;

data.regs = regs;
data.addr = 0;

cpuc = &__get_cpu_var(cpu_hw_counters);

perf_disable();
intel_pmu_drain_bts_buffer(cpuc);
intel_pmu_drain_bts_buffer(cpuc, &data);
status = intel_pmu_get_status();
if (!status) {
perf_enable();
Expand Down Expand Up @@ -1717,7 +1702,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)

data.period = counter->hw.last_period;

if (perf_counter_overflow(counter, 1, &data, regs))
if (perf_counter_overflow(counter, 1, &data))
intel_pmu_disable_counter(&counter->hw, bit);
}

Expand All @@ -1744,6 +1729,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)
int idx, handled = 0;
u64 val;

data.regs = regs;
data.addr = 0;

cpuc = &__get_cpu_var(cpu_hw_counters);
Expand All @@ -1768,7 +1754,7 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)
if (!x86_perf_counter_set_period(counter, hwc, idx))
continue;

if (perf_counter_overflow(counter, 1, &data, regs))
if (perf_counter_overflow(counter, 1, &data))
amd_pmu_disable_counter(hwc, idx);
}

Expand Down
25 changes: 19 additions & 6 deletions trunk/arch/x86/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/pm.h>
#include <linux/clockchips.h>
#include <linux/random.h>
#include <trace/events/power.h>
#include <trace/power.h>
#include <asm/system.h>
#include <asm/apic.h>
#include <asm/syscalls.h>
Expand All @@ -25,6 +25,9 @@ EXPORT_SYMBOL(idle_nomwait);

struct kmem_cache *task_xstate_cachep;

DEFINE_TRACE(power_start);
DEFINE_TRACE(power_end);

int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
{
*dst = *src;
Expand Down Expand Up @@ -296,7 +299,9 @@ static inline int hlt_use_halt(void)
void default_idle(void)
{
if (hlt_use_halt()) {
trace_power_start(POWER_CSTATE, 1);
struct power_trace it;

trace_power_start(&it, POWER_CSTATE, 1);
current_thread_info()->status &= ~TS_POLLING;
/*
* TS_POLLING-cleared state must be visible before we
Expand All @@ -309,6 +314,7 @@ void default_idle(void)
else
local_irq_enable();
current_thread_info()->status |= TS_POLLING;
trace_power_end(&it);
} else {
local_irq_enable();
/* loop is done by the caller */
Expand Down Expand Up @@ -366,7 +372,9 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
*/
void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
{
trace_power_start(POWER_CSTATE, (ax>>4)+1);
struct power_trace it;

trace_power_start(&it, POWER_CSTATE, (ax>>4)+1);
if (!need_resched()) {
if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
clflush((void *)&current_thread_info()->flags);
Expand All @@ -376,13 +384,15 @@ void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
if (!need_resched())
__mwait(ax, cx);
}
trace_power_end(&it);
}

/* Default MONITOR/MWAIT with no hints, used for default C1 state */
static void mwait_idle(void)
{
struct power_trace it;
if (!need_resched()) {
trace_power_start(POWER_CSTATE, 1);
trace_power_start(&it, POWER_CSTATE, 1);
if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
clflush((void *)&current_thread_info()->flags);

Expand All @@ -392,6 +402,7 @@ static void mwait_idle(void)
__sti_mwait(0, 0);
else
local_irq_enable();
trace_power_end(&it);
} else
local_irq_enable();
}
Expand All @@ -403,11 +414,13 @@ static void mwait_idle(void)
*/
static void poll_idle(void)
{
trace_power_start(POWER_CSTATE, 0);
struct power_trace it;

trace_power_start(&it, POWER_CSTATE, 0);
local_irq_enable();
while (!need_resched())
cpu_relax();
trace_power_end(0);
trace_power_end(&it);
}

/*
Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/cpuidle/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <linux/cpuidle.h>
#include <linux/ktime.h>
#include <linux/hrtimer.h>
#include <trace/events/power.h>

#include "cpuidle.h"

Expand Down Expand Up @@ -92,7 +91,6 @@ static void cpuidle_idle_call(void)
/* give the governor an opportunity to reflect on the outcome */
if (cpuidle_curr_governor->reflect)
cpuidle_curr_governor->reflect(dev);
trace_power_end(0);
}

/**
Expand Down
19 changes: 7 additions & 12 deletions trunk/drivers/isdn/gigaset/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,33 +408,28 @@ static int if_write_room(struct tty_struct *tty)
return retval;
}

/* FIXME: This function does not have error returns */

static int if_chars_in_buffer(struct tty_struct *tty)
{
struct cardstate *cs;
int retval = -ENODEV;
int retval = 0;

cs = (struct cardstate *) tty->driver_data;
if (!cs) {
pr_err("%s: no cardstate\n", __func__);
return -ENODEV;
return 0;
}

gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);

if (mutex_lock_interruptible(&cs->mutex))
return -ERESTARTSYS; // FIXME -EINTR?
mutex_lock(&cs->mutex);

if (!cs->connected) {
if (!cs->connected)
gig_dbg(DEBUG_IF, "not connected");
retval = -ENODEV;
} else if (!cs->open_count)
else if (!cs->open_count)
dev_warn(cs->dev, "%s: device not opened\n", __func__);
else if (cs->mstate != MS_LOCKED) {
else if (cs->mstate != MS_LOCKED)
dev_warn(cs->dev, "can't write to unlocked device\n");
retval = -EBUSY;
} else
else
retval = cs->ops->chars_in_buffer(cs);

mutex_unlock(&cs->mutex);
Expand Down
Loading

0 comments on commit a2b3863

Please sign in to comment.