Skip to contentSkip to conversation

Add PM_TRACE x86_64 support.

PATCH In review Nigel Cunningham 5 participants 8 messages Feb 8, 2007 – Feb 15, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add PM_TRACE x86_64 support.

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

Symbol exports are added so tracing can be used from drivers built as modules too.

Please apply.

 arch/x86_64/kernel/vmlinux.lds.S  |    7 +++++++
 drivers/base/power/trace.c        |    4 +++-
 include/asm-i386/resume-trace.h   |   21 +++++++++++++++++++++
 include/asm-x86_64/resume-trace.h |   21 +++++++++++++++++++++
 include/linux/resume-trace.h      |   24 ++++++------------------
 kernel/power/Kconfig              |    2 +-
 6 files changed, 59 insertions(+), 20 deletions(-)
arch/x86_64/kernel/vmlinux.lds.S +7 -0
diff -ruNp 930-PM_TRACE.patch-old/arch/x86_64/kernel/vmlinux.lds.S 930-PM_TRACE.patch-new/arch/x86_64/kernel/vmlinux.lds.S
@@ -54,6 +54,13 @@ SECTIONS
 
   BUG_TABLE
 
+  . = 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) {
drivers/base/power/trace.c +3 -1
diff -ruNp 930-PM_TRACE.patch-old/drivers/base/power/trace.c 930-PM_TRACE.patch-new/drivers/base/power/trace.c
@@ -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
@@ -162,6 +163,7 @@ void generate_resume_trace(void *traceda
 	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)
@@ -170,7 +172,7 @@ static int show_file_hash(unsigned int v
 	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);
include/asm-i386/resume-trace.h +21 -0
diff -ruNp 930-PM_TRACE.patch-old/include/asm-i386/resume-trace.h 930-PM_TRACE.patch-new/include/asm-i386/resume-trace.h
@@ -0,0 +1,21 @@
+#ifndef ARCH_RESUME_TRACE_H
+#define ARCH_RESUME_TRACE_H
+
+#ifdef CONFIG_PM_TRACE
+#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)
+#else
+#define TRACE_RESUME(user) do { } while (0)
+#endif
+#endif
include/asm-x86_64/resume-trace.h +21 -0
diff -ruNp 930-PM_TRACE.patch-old/include/asm-x86_64/resume-trace.h 930-PM_TRACE.patch-new/include/asm-x86_64/resume-trace.h
@@ -0,0 +1,21 @@
+#ifndef ARCH_RESUME_TRACE_H
+#define ARCH_RESUME_TRACE_H
+
+#ifdef CONFIG_PM_TRACE
+#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)
+#else
+#define TRACE_RESUME(user) do { } while (0)
+#endif
+#endif
include/linux/resume-trace.h +6 -18
diff -ruNp 930-PM_TRACE.patch-old/include/linux/resume-trace.h 930-PM_TRACE.patch-new/include/linux/resume-trace.h
@@ -1,6 +1,8 @@
 #ifndef RESUME_TRACE_H
 #define RESUME_TRACE_H
 
+#include <asm/resume-trace.h>
+
 #ifdef CONFIG_PM_TRACE
 
 extern int pm_trace_enabled;
@@ -9,26 +11,12 @@ 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
-
 #define TRACE_DEVICE(dev) do { } while (0)
-#define TRACE_RESUME(dev) do { } while (0)
-
 #endif
 
 #endif
kernel/power/Kconfig +1 -1
diff -ruNp 930-PM_TRACE.patch-old/kernel/power/Kconfig 930-PM_TRACE.patch-new/kernel/power/Kconfig
@@ -50,7 +50,7 @@ config DISABLE_CONSOLE_SUSPEND
 
 config PM_TRACE
 	bool "Suspend/resume event tracing"
-	depends on PM && PM_DEBUG && X86_32 && EXPERIMENTAL
+	depends on PM && PM_DEBUG && X86 && EXPERIMENTAL
 	default n
 	---help---
 	This enables some cheesy code to save the last PM event point in the
#1 lore raw

drivers/base/power/trace.c static int show_file_hash(unsigned int v · line 175

Quoted 2 lines · Nigel Cunningham
drivers/base/power/trace.c +1 -1
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
+	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 2 + sizeof(unsigned long)) {

Could you split this line?

Signature · 8 lines
        O T A V I O    S A L V A D O R
---------------------------------------------
 E-mail: [email protected]      UIN: 5906116
 GNU/Linux User: 239058     GPG ID: 49A5F855
 Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
 you the whole house."
#2 lore raw
Quoted 6 lines · Otavio Salvador

Review

Quoted 2 lines · Nigel Cunningham
(quoted diff) +1 -1
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
+	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 2 + sizeof(unsigned long)) {

Could you split this line?

Sure.

-- New version -- (What's the right way to do this?)

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

Symbol exports are added so tracing can be used from drivers built as modules too.

Please apply.

 arch/x86_64/kernel/vmlinux.lds.S  |    7 +++++++
 drivers/base/power/trace.c        |    5 ++++-
 include/asm-i386/resume-trace.h   |   21 +++++++++++++++++++++
 include/asm-x86_64/resume-trace.h |   21 +++++++++++++++++++++
 include/linux/resume-trace.h      |   24 ++++++------------------
 kernel/power/Kconfig              |    2 +-
 6 files changed, 60 insertions(+), 20 deletions(-)
arch/x86_64/kernel/vmlinux.lds.S +7 -0
diff -ruNp 160-PM_TRACE.patch-old/arch/x86_64/kernel/vmlinux.lds.S 160-PM_TRACE.patch-new/arch/x86_64/kernel/vmlinux.lds.S
@@ -54,6 +54,13 @@ SECTIONS
 
   BUG_TABLE
 
+  . = 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) {
drivers/base/power/trace.c +4 -1
diff -ruNp 160-PM_TRACE.patch-old/drivers/base/power/trace.c 160-PM_TRACE.patch-new/drivers/base/power/trace.c
@@ -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
@@ -162,6 +163,7 @@ void generate_resume_trace(void *traceda
 	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)
@@ -170,7 +172,8 @@ static int show_file_hash(unsigned int v
 	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);
include/asm-i386/resume-trace.h +21 -0
diff -ruNp 160-PM_TRACE.patch-old/include/asm-i386/resume-trace.h 160-PM_TRACE.patch-new/include/asm-i386/resume-trace.h
@@ -0,0 +1,21 @@
+#ifndef ARCH_RESUME_TRACE_H
+#define ARCH_RESUME_TRACE_H
+
+#ifdef CONFIG_PM_TRACE
+#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)
+#else
+#define TRACE_RESUME(user) do { } while (0)
+#endif
+#endif
include/asm-x86_64/resume-trace.h +21 -0
diff -ruNp 160-PM_TRACE.patch-old/include/asm-x86_64/resume-trace.h 160-PM_TRACE.patch-new/include/asm-x86_64/resume-trace.h
@@ -0,0 +1,21 @@
+#ifndef ARCH_RESUME_TRACE_H
+#define ARCH_RESUME_TRACE_H
+
+#ifdef CONFIG_PM_TRACE
+#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)
+#else
+#define TRACE_RESUME(user) do { } while (0)
+#endif
+#endif
include/linux/resume-trace.h +6 -18
diff -ruNp 160-PM_TRACE.patch-old/include/linux/resume-trace.h 160-PM_TRACE.patch-new/include/linux/resume-trace.h
@@ -1,6 +1,8 @@
 #ifndef RESUME_TRACE_H
 #define RESUME_TRACE_H
 
+#include <asm/resume-trace.h>
+
 #ifdef CONFIG_PM_TRACE
 
 extern int pm_trace_enabled;
@@ -9,26 +11,12 @@ 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
-
 #define TRACE_DEVICE(dev) do { } while (0)
-#define TRACE_RESUME(dev) do { } while (0)
-
 #endif
 
 #endif
kernel/power/Kconfig +1 -1
diff -ruNp 160-PM_TRACE.patch-old/kernel/power/Kconfig 160-PM_TRACE.patch-new/kernel/power/Kconfig
@@ -50,7 +50,7 @@ config DISABLE_CONSOLE_SUSPEND
 
 config PM_TRACE
 	bool "Suspend/resume event tracing"
-	depends on PM && PM_DEBUG && X86_32 && EXPERIMENTAL
+	depends on PM && PM_DEBUG && X86 && EXPERIMENTAL
 	default n
 	---help---
 	This enables some cheesy code to save the last PM event point in the
#3 lore raw
Quoted 10 lines · Nigel Cunningham
Quoted 6 lines · Otavio Salvador

Review

Quoted 2 lines · Nigel Cunningham
(quoted diff) +1 -1
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
+	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 2 + sizeof(unsigned long)) {

Could you split this line?

Sure.

Quoted 7 lines

-- New version -- (What's the right way to do this?)

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

Symbol exports are added so tracing can be used from drivers built as modules too.

Don't include exports in a patch that doesn't use them. Introduce the exports in a later patch series, for when you actually need it.

Signature · 1 line
Jens Axboe
#4 lore raw

Hi!

Quoted 11 lines
Quoted 11 lines
Quoted 6 lines

Review

Quoted 2 lines · Nigel Cunningham
(quoted diff) +1 -1
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
+	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 2 + sizeof(unsigned long)) {

Could you split this line?

Sure.

-- New version -- (What's the right way to do this?)

Quoted 8 lines
Quoted 5 lines

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

Symbol exports are added so tracing can be used from drivers built as modules too.

Don't include exports in a patch that doesn't use them. Introduce the exports in a later patch series, for when you actually need it.

It is debugging infrastructure, so export actually makes sense... It will not ever be used in mainline kernel; you need to modify code manually to use this code..

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw
Quoted 19 lines · Pavel Machek

Hi!

Quoted 17 lines
Quoted 16 lines
Quoted 6 lines

Review

Quoted 2 lines · Nigel Cunningham
(quoted diff) +1 -1
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
+	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 2 + sizeof(unsigned long)) {

Could you split this line?

Sure.

-- New version -- (What's the right way to do this?)

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

Symbol exports are added so tracing can be used from drivers built as modules too.

Quoted 6 lines
Quoted 2 lines

Don't include exports in a patch that doesn't use them. Introduce the exports in a later patch series, for when you actually need it.

It is debugging infrastructure, so export actually makes sense... It will not ever be used in mainline kernel; you need to modify code manually to use this code..

Then add the exports while you are modifying the other code, it's no reason to put it in mainline.

Signature · 1 line
Jens Axboe
#6 lore raw
Quoted 23 lines · Jens Axboe
Quoted 22 lines · Pavel Machek

Hi!

Quoted 19 lines
Quoted 9 lines
Quoted 6 lines

Review

Quoted 2 lines · Nigel Cunningham
(quoted diff) +1 -1
-	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) {
+	for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 2 + sizeof(unsigned long)) {

Could you split this line?

Sure.

Quoted 7 lines

-- New version -- (What's the right way to do this?)

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

Symbol exports are added so tracing can be used from drivers built as modules too.

Don't include exports in a patch that doesn't use them. Introduce the exports in a later patch series, for when you actually need it.

Quoted 6 lines
Quoted 3 lines

It is debugging infrastructure, so export actually makes sense... It will not ever be used in mainline kernel; you need to modify code manually to use this code..

Then add the exports while you are modifying the other code, it's no reason to put it in mainline.

Same could be said for the rest of the code, too... but Linus added it to the mainline.

(Actually it has one example user somewhere, iirc)

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw
In reply to Nigel Cunningham
Quoted 2 lines · On Thu, 08 Feb 2007 13:08:06 +1100 Nigel Cunningham <[email protected]>…

This patch add x86_64 support for PM_TRACE, and shifts per-arch code to the appropriate subdirectories.

ia64 allmodconfig:

include/linux/resume-trace.h:4:30: asm/resume-trace.h: No such file or directory drivers/base/power/resume.c: In function `resume_device':
drivers/base/power/resume.c:28: warning: implicit declaration of function `TRACE_RESUME'