KGTP (Linux Kernel debugger and tracer) 20120424 release(doc update)[1/3]code
Subsystems (5)
--- arch/arm/include/asm/gtp.h | 15 arch/mips/include/asm/gtp.h | 19 arch/x86/include/asm/gtp.h | 22 include/linux/perf_event.h | 3 kernel/events/core.c | 14 lib/Kconfig.debug | 10 lib/Makefile | 4 lib/gtp.c | 8994 ++++++++++++++++++++++++++++++++++++++++++++ lib/gtp_rb.c | 498 ++ 9 files changed, 9577 insertions(+), 2 deletions(-)
arch/arm/include/asm/gtp.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef _ASM_ARM_GTP_H_ +#define _ASM_ARM_GTP_H_ + +#define ULONGEST uint64_t +#define LONGEST int64_t +#define CORE_ADDR unsigned long + +#define GTP_REGS_PC (regs) ((regs)->uregs[15]) + +#define GTP_REG_ASCII_SIZE 336 +#define GTP_REG_BIN_SIZE 168 + +#define GTP_SP_NUM 13 + +#endif
arch/mips/include/asm/gtp.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef _ASM_MIPS_GTP_H_ +#define _ASM_MIPS_GTP_H_ + +#define ULONGEST uint64_t +#define LONGEST int64_t +#define CORE_ADDR unsigned long + +#define GTP_REGS_PC (regs) ((regs)->cp0_epc) + +#ifdef CONFIG_32BIT +#define GTP_REG_ASCII_SIZE 304 +#define GTP_REG_BIN_SIZE 152 +#else +#define GTP_REG_ASCII_SIZE 608 +#define GTP_REG_BIN_SIZE 304 +#endif + +#define GTP_SP_NUM 29 +#endif
arch/x86/include/asm/gtp.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef _ASM_X86_GTP_H_ +#define _ASM_X86_GTP_H_ + +#define ULONGEST uint64_t +#define LONGEST int64_t +#define CORE_ADDR unsigned long + +#define GTP_REGS_PC (regs) ((regs)->ip) + +#ifdef CONFIG_X86_32 +#define GTP_REG_ASCII_SIZE 128 +#define GTP_REG_BIN_SIZE 64 + +#define GTP_SP_NUM 4 +#else +#define GTP_REG_ASCII_SIZE 296 +#define GTP_REG_BIN_SIZE 148 + +#define GTP_SP_NUM 7 +#endif + +#endif
include/linux/perf_event.h +3 -0
@@ -1287,9 +1287,12 @@ extern void perf_output_copy(struct perf const void *buf, unsigned int len);extern int perf_swevent_get_recursion_context (void );extern void perf_swevent_put_recursion_context (int rctx); +extern int __perf_event_enable (void *info); +extern int __perf_event_disable (void *info);extern void perf_event_enable (struct perf_event *event);extern void perf_event_disable (struct perf_event *event);extern void perf_event_task_tick (void ); +extern void perf_event_set (struct perf_event *event,u64 val);#else static inline void perf_event_task_sched_in(struct task_struct *prev,
kernel/events/core.c +12 -2
@@ -1249,7 +1249,7 @@ retry:/* * Cross CPU call to disable a performance event */ -static int __perf_event_disable (void *info) +int __perf_event_disable (void *info) {struct perf_event *event = info;struct perf_event_context *ctx = event->ctx;
@@ -1286,6 +1286,7 @@ static int __perf_event_disable(void *inreturn 0 ; } +EXPORT_SYMBOL_GPL (__perf_event_disable);/* * Disable a event.
@@ -1697,7 +1698,7 @@ static void __perf_event_mark_enabled(st/* * Cross CPU call to enable a performance event */ -static int __perf_event_enable (void *info) +int __perf_event_enable (void *info) {struct perf_event *event = info;struct perf_event_context *ctx = event->ctx;
@@ -1761,6 +1762,7 @@ unlock:return 0 ; } +EXPORT_SYMBOL_GPL (__perf_event_enable);/* * Enable a event.
@@ -3151,6 +3153,14 @@ static void perf_event_reset(struct perfperf_event_update_userpage (event); } +void perf_event_set (struct perf_event *event,u64 val) +{ + (void )perf_event_read (event); +local64_set (&event->count, val); +perf_event_update_userpage (event); +} +EXPORT_SYMBOL_GPL (perf_event_set); +/* * Holding the top-level event's child_mutex means that any * descendant process that has inherited this event will block
lib/Kconfig.debug +10 -0
@@ -1289,6 +1289,16 @@ config ASYNC_RAID6_TEST If unsure, say N. +config GTP + tristate "GDB tracepoint support" + depends on X86 || ARM || MIPS + select KPROBES + select DEBUG_FS + ---help--- + Supply GDB tracepoint interface in /sys/kernel/debug/gtp. + See Documentation/trace/gtp.txt or + https://code.google.com/p/kgtp/wiki/HOWTO for more info. + source "samples/Kconfig" source "lib/Kconfig.kgdb"
lib/Makefile +4 -0
@@ -123,6 +123,8 @@ obj-$(CONFIG_SIGNATURE) += digsig.o obj-$(CONFIG_CLZ_TAB) += clz_tab.o +obj-$(CONFIG_GTP) += gtp.o + hostprogs-y := gen_crc32table clean-files := crc32table.h
@@ -133,3 +135,5 @@ quiet_cmd_crc32 = GEN $@ $(obj)/crc32table.h: $(obj)/gen_crc32table $(call cmd,crc32) + +gtp.o: gtp_rb.c
lib/gtp.c new file +8994 -0
2,859 lines not on this page · raw message
lib/gtp_rb.c new file +498 -0
498 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Hui Zhu <[email protected]> writes:
Could you please split it down further. a 9kLOC patch is pretty daunting.
Quoted 1 line
From a quick glance over some focus on simplication would be good: no
own allocators (kernel has enough), no own types (that would remove asm), remove optional facilities like the private ring buffer. Some obsolete code like using semaphores vs mutexes. The variable list looks overcomplicated, just use an array? Generally too many macros I would say, try using inlines or removing them.
Do you have any rarely used optional features that could be left out a version 1? If yes do that. I'm sure with some effort the 9kLOC could be much less. A patch half the size would be much easier to merge.
There are some things that checkpatch will likely warn about.
It would be good if you could describe the use case a bit better:
this is for the kernel only or also user applications?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 1 line · Andi Kleen
Hui Zhu <[email protected]> writes:
Hi Andi,
Thanks for your mail.
Quoted 10 lines
Could you please split it down further. a 9kLOC patch is pretty daunting.
From a quick glance over some focus on simplication would be good: no own allocators (kernel has enough), no own types (that would remove asm), remove optional facilities like the private ring buffer. Some obsolete code like using semaphores vs mutexes. The variable list looks overcomplicated, just use an array? Generally too many macros I would say, try using inlines or removing them.
Quoted 4 lines
Do you have any rarely used optional features that could be left out a version 1? If yes do that. I'm sure with some effort the 9kLOC could be much less. A patch half the size would be much easier to merge.
Your comments is very helpful for me. I spent more time on add more function to KGTP, make it more faster and make module support more older kernel in before. But the review patch is not very clear. I will post a new patch for review that just keep the base function of KGTP to make it more easy to review. Please keep help me with it.
Quoted 4 lines
There are some things that checkpatch will likely warn about.
It would be good if you could describe the use case a bit better:
this is for the kernel only or also user applications?
Most of function is for the Linux kernel. You can get them from the doc in http://code.google.com/p/kgtp/wiki/HOWTO
And I am trying to make KGTP can do some thing for user application too. http://code.google.com/p/kgtp/wiki/hotcode this is an example to use KGTP analyze user application performance bottleneck.
I am just adding the function that can access to the memory of an user application memory directly without interrupt it. And another plan is use KGTP get backtrace of user application without interrupt it.
Thanks,
Hui
Quoted 5 lines
-Andi
--
[email protected] -- Speaking for myself only