Skip to content

Commit

Permalink
x86: PM_TRACE support
Browse files Browse the repository at this point in the history
Signed-off-by: Nigel Cunningham <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Pavel Machek <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Andi Kleen <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Nigel Cunningham authored and Linus Torvalds committed Jul 22, 2007
1 parent 9ef231a commit 44bf4ce
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 16 deletions.
7 changes: 7 additions & 0 deletions arch/x86_64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ SECTIONS

RODATA

. = ALIGN(4);
.tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
__tracedata_start = .;
*(.tracedata)
__tracedata_end = .;
}

. = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
/* Data */
.data : AT(ADDR(.data) - LOAD_OFFSET) {
Expand Down
5 changes: 4 additions & 1 deletion drivers/base/power/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void set_trace_device(struct device *dev)
{
dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH);
}
EXPORT_SYMBOL(set_trace_device);

/*
* We could just take the "tracedata" index into the .tracedata
Expand All @@ -162,6 +163,7 @@ void generate_resume_trace(void *tracedata, unsigned int user)
file_hash_value = hash_string(lineno, file, FILEHASH);
set_magic_time(user_hash_value, file_hash_value, dev_hash_value);
}
EXPORT_SYMBOL(generate_resume_trace);

extern char __tracedata_start, __tracedata_end;
static int show_file_hash(unsigned int value)
Expand All @@ -170,7 +172,8 @@ static int show_file_hash(unsigned int value)
char *tracedata;

match = 0;
for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ;
tracedata += 2 + sizeof(unsigned long)) {
unsigned short lineno = *(unsigned short *)tracedata;
const char *file = *(const char **)(tracedata + 2);
unsigned int hash = hash_string(lineno, file, FILEHASH);
Expand Down
13 changes: 13 additions & 0 deletions include/asm-i386/resume-trace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#define TRACE_RESUME(user) do { \
if (pm_trace_enabled) { \
void *tracedata; \
asm volatile("movl $1f,%0\n" \
".section .tracedata,\"a\"\n" \
"1:\t.word %c1\n" \
"\t.long %c2\n" \
".previous" \
:"=r" (tracedata) \
: "i" (__LINE__), "i" (__FILE__)); \
generate_resume_trace(tracedata, user); \
} \
} while (0)
13 changes: 13 additions & 0 deletions include/asm-x86_64/resume-trace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#define TRACE_RESUME(user) do { \
if (pm_trace_enabled) { \
void *tracedata; \
asm volatile("movq $1f,%0\n" \
".section .tracedata,\"a\"\n" \
"1:\t.word %c1\n" \
"\t.quad %c2\n" \
".previous" \
:"=r" (tracedata) \
: "i" (__LINE__), "i" (__FILE__)); \
generate_resume_trace(tracedata, user); \
} \
} while (0)
19 changes: 5 additions & 14 deletions include/linux/resume-trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@
#define RESUME_TRACE_H

#ifdef CONFIG_PM_TRACE
#include <asm/resume-trace.h>

extern int pm_trace_enabled;

struct device;
extern void set_trace_device(struct device *);
extern void generate_resume_trace(void *tracedata, unsigned int user);

#define TRACE_DEVICE(dev) set_trace_device(dev)
#define TRACE_RESUME(user) do { \
if (pm_trace_enabled) { \
void *tracedata; \
asm volatile("movl $1f,%0\n" \
".section .tracedata,\"a\"\n" \
"1:\t.word %c1\n" \
"\t.long %c2\n" \
".previous" \
:"=r" (tracedata) \
: "i" (__LINE__), "i" (__FILE__)); \
generate_resume_trace(tracedata, user); \
} \
} while (0)
#define TRACE_DEVICE(dev) do { \
if (pm_trace_enabled) \
set_trace_device(dev); \
} while(0)

#else

Expand Down
2 changes: 1 addition & 1 deletion kernel/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ config DISABLE_CONSOLE_SUSPEND

config PM_TRACE
bool "Suspend/resume event tracing"
depends on PM_DEBUG && X86_32 && EXPERIMENTAL
depends on PM_DEBUG && X86 && EXPERIMENTAL
default n
---help---
This enables some cheesy code to save the last PM event point in the
Expand Down

0 comments on commit 44bf4ce

Please sign in to comment.