Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163881
b: refs/heads/master
c: b0999cc
h: refs/heads/master
i:
  163879: d660639
v: v3
  • Loading branch information
Mikael Pettersson authored and Ben Dooks committed Sep 19, 2009
1 parent 1f05d73 commit 6eede41
Show file tree
Hide file tree
Showing 189 changed files with 4,413 additions and 7,263 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: a57c21c7159e07c27e317ea3513dfb382be3f153
refs/heads/master: b0999cc55bd49e315ec82d2fb770a0d9ef7cbed8
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
6 changes: 3 additions & 3 deletions trunk/arch/mn10300/kernel/asm-offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void foo(void)
OFFSET(__iobase, mn10300_serial_port, _iobase);

DEFINE(__UART_XMIT_SIZE, UART_XMIT_SIZE);
OFFSET(__xmit_buffer, uart_state, xmit.buf);
OFFSET(__xmit_head, uart_state, xmit.head);
OFFSET(__xmit_tail, uart_state, xmit.tail);
OFFSET(__xmit_buffer, uart_info, xmit.buf);
OFFSET(__xmit_head, uart_info, xmit.head);
OFFSET(__xmit_tail, uart_info, xmit.tail);
}
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
4 changes: 2 additions & 2 deletions trunk/arch/x86/kernel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static struct notifier_block __refdata cpuid_class_cpu_notifier =
.notifier_call = cpuid_class_cpu_callback,
};

static char *cpuid_devnode(struct device *dev, mode_t *mode)
static char *cpuid_nodename(struct device *dev)
{
return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt));
}
Expand All @@ -203,7 +203,7 @@ static int __init cpuid_init(void)
err = PTR_ERR(cpuid_class);
goto out_chrdev;
}
cpuid_class->devnode = cpuid_devnode;
cpuid_class->nodename = cpuid_nodename;
for_each_online_cpu(i) {
err = cpuid_device_create(i);
if (err != 0)
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/microcode_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static const struct file_operations microcode_fops = {
static struct miscdevice microcode_dev = {
.minor = MICROCODE_MINOR,
.name = "microcode",
.nodename = "cpu/microcode",
.devnode = "cpu/microcode",
.fops = &microcode_fops,
};

Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/x86/kernel/msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static struct notifier_block __refdata msr_class_cpu_notifier = {
.notifier_call = msr_class_cpu_callback,
};

static char *msr_devnode(struct device *dev, mode_t *mode)
static char *msr_nodename(struct device *dev)
{
return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt));
}
Expand All @@ -262,7 +262,7 @@ static int __init msr_init(void)
err = PTR_ERR(msr_class);
goto out_chrdev;
}
msr_class->devnode = msr_devnode;
msr_class->nodename = msr_nodename;
for_each_online_cpu(i) {
err = msr_device_create(i);
if (err != 0)
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
4 changes: 2 additions & 2 deletions trunk/block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ EXPORT_SYMBOL_GPL(bsg_register_queue);

static struct cdev bsg_cdev;

static char *bsg_devnode(struct device *dev, mode_t *mode)
static char *bsg_nodename(struct device *dev)
{
return kasprintf(GFP_KERNEL, "bsg/%s", dev_name(dev));
}
Expand All @@ -1087,7 +1087,7 @@ static int __init bsg_init(void)
ret = PTR_ERR(bsg_class);
goto destroy_kmemcache;
}
bsg_class->devnode = bsg_devnode;
bsg_class->nodename = bsg_nodename;

ret = alloc_chrdev_region(&devid, 0, BSG_MAX_DEVS, "bsg");
if (ret)
Expand Down
8 changes: 4 additions & 4 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,20 +998,20 @@ struct class block_class = {
.name = "block",
};

static char *block_devnode(struct device *dev, mode_t *mode)
static char *block_nodename(struct device *dev)
{
struct gendisk *disk = dev_to_disk(dev);

if (disk->devnode)
return disk->devnode(disk, mode);
if (disk->nodename)
return disk->nodename(disk);
return NULL;
}

static struct device_type disk_type = {
.name = "disk",
.groups = disk_attr_groups,
.release = disk_release,
.devnode = block_devnode,
.nodename = block_nodename,
};

#ifdef CONFIG_PROC_FS
Expand Down
Loading

0 comments on commit 6eede41

Please sign in to comment.