--- diff -L arch/ppc64/Kconfig -puN /dev/null /dev/null diff -puN arch/ppc64/defconfig~trace-lib arch/ppc64/defconfig diff -puN /dev/null include/linux/trace.h --- /dev/null Fri Mar 14 06:52:15 2003 +++ vmx-miscompare-moilanen/include/linux/trace.h Mon Oct 11 09:00:42 2004 @@ -0,0 +1,74 @@ +/* + * Jake Moilanen + * + * Trace library + * + */ +#ifndef __TRACE_H_ +#define __TRACE_H_ + +#ifdef CONFIG_TRACE + +#include + +#define TRACE_NO_OPS 0x8000 +#define TRACE_MSG_SIZE 0x200 +#define TRACE_SIZE TRACE_NO_OPS * TRACE_MSG_SIZE +#define TRACE_TB_SIZE 32 + +struct trace { + char time[32]; + char trace_tmp_buf[TRACE_MSG_SIZE]; +}; + +extern unsigned long trace_index; +extern char trace_buf[TRACE_SIZE]; +extern int tracing_on; +extern int trace_wrapped; +extern unsigned long trace_last_entry; +extern spinlock_t tracing_lock; + +static __inline__ void trace_add (const char *fmt, ...) +{ + char * tb; + va_list args; + unsigned long s; + + if (!tracing_on) + return; + + spin_lock_irqsave(&tracing_lock, s); + + if (trace_index + TRACE_MSG_SIZE + TRACE_TB_SIZE > TRACE_SIZE) { + *(char *)(trace_buf + trace_index) = '\0'; + trace_last_entry = trace_index; + trace_wrapped = 1; + trace_index = 0; + } + + tb = trace_buf + trace_index; + + /* XXX need some arch independent mftb() */ + trace_index += sprintf(tb, "%lx\t%d\t", mftb(), smp_processor_id()); + + tb = trace_buf + trace_index; + + va_start (args, fmt); + trace_index += vsnprintf (tb, TRACE_MSG_SIZE, fmt, args); + va_end (args); + + if (!trace_wrapped) { + trace_last_entry = trace_index; + } + + spin_unlock_irqrestore(&tracing_lock, s); + +} + +#else /* CONFIG_TRACE */ + +#define trace_add(x) { 0 } + +#endif /* CONFIG_TRACE */ + +#endif diff -puN kernel/Makefile~trace-lib kernel/Makefile --- vmx-miscompare/kernel/Makefile~trace-lib Fri Oct 8 13:16:55 2004 +++ vmx-miscompare-moilanen/kernel/Makefile Fri Oct 8 13:17:57 2004 @@ -25,6 +25,7 @@ obj-$(CONFIG_PM) += pm.o obj-$(CONFIG_CPU_FREQ) += cpufreq.o obj-$(CONFIG_IKCONFIG) += configs.o obj-$(CONFIG_KALLSYMS) += kallsyms.o +obj-$(CONFIG_TRACE) += trace.o ifneq ($(CONFIG_IA64),y) # According to Alan Modra , the -fno-omit-frame-pointer is diff -puN /dev/null kernel/trace.c --- /dev/null Fri Mar 14 06:52:15 2003 +++ vmx-miscompare-moilanen/kernel/trace.c Fri Oct 8 15:43:41 2004 @@ -0,0 +1,101 @@ +/* + * + * Jake Moilanen + * + * Trace Library + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +static ssize_t trace_proc_read(struct file * file, char * buf, + size_t count, loff_t *ppos); +static ssize_t trace_proc_write(struct file * file, char * buf, + size_t count, loff_t *ppos); + + +//atomic_t trace_index; +unsigned long trace_index; +char trace_buf[TRACE_SIZE]__page_aligned; +int tracing_on = 1; +int trace_wrapped = 0; +unsigned long trace_last_entry = 0; +spinlock_t tracing_lock = SPIN_LOCK_UNLOCKED; + +EXPORT_SYMBOL(tracing_lock); +EXPORT_SYMBOL(tracing_on); +EXPORT_SYMBOL(trace_wrapped); +EXPORT_SYMBOL(trace_last_entry); +EXPORT_SYMBOL(trace_index); +EXPORT_SYMBOL(trace_buf); + +struct file_operations trace_ops = { + .read = trace_proc_read, + .write = trace_proc_write +}; + +int __init trace_init(void) +{ + struct proc_dir_entry *entry; + + entry = create_proc_entry("trace", S_IRUGO, 0); + if (!entry) + printk(KERN_ERR "Failed to create /proc/trace\n"); + else + entry->proc_fops = &trace_ops; + + return 0; +} + +static ssize_t trace_proc_read(struct file * file, char * buf, + size_t count, loff_t *ppos) +{ + ssize_t n = 0; + unsigned long s; + char * tmp_buf = (char *)trace_buf; + + if (*ppos >= TRACE_SIZE) + return 0; + +// spin_lock_irqsave(&tracing_lock, s); + + n = trace_last_entry; + + if (n > trace_last_entry - *ppos) + n = trace_last_entry - *ppos; + + if (n > count) + n = count; + + if (copy_to_user(buf, tmp_buf + (*ppos), n)) { + return -EFAULT; + } + +// spin_unlock_irqrestore(&tracing_lock, s); + + *ppos += n; + return n; +} + +static ssize_t trace_proc_write(struct file * file, char * buf, + size_t count, loff_t *ppos) +{ + char tmp_buf[30]; + + if (copy_from_user (tmp_buf, buf, count)) { + return -EFAULT; + } + + tracing_on = simple_strtoul(tmp_buf, NULL, 16); + + printk(KERN_INFO "Tracing is %s\n", tracing_on ? "on" : "off"); + +} +__initcall(trace_init); _