rpms/kernel/devel kernel-2.6.spec, 1.2070, 1.2071 linux-2.6-debug-latency-tracing.patch, 1.10, 1.11

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Mar 20 22:24:04 UTC 2006


Author: davej

Update of /cvs/dist/rpms/kernel/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv573

Modified Files:
	kernel-2.6.spec linux-2.6-debug-latency-tracing.patch 
Log Message:
updated latency tracer



Index: kernel-2.6.spec
===================================================================
RCS file: /cvs/dist/rpms/kernel/devel/kernel-2.6.spec,v
retrieving revision 1.2070
retrieving revision 1.2071
diff -u -r1.2070 -r1.2071
--- kernel-2.6.spec	20 Mar 2006 22:19:53 -0000	1.2070
+++ kernel-2.6.spec	20 Mar 2006 22:24:02 -0000	1.2071
@@ -1652,6 +1652,7 @@
 * Mon Mar 20 2006 Dave Jones <davej at redhat.com>
 - 2.6.16 & 2.6.16-git1
 - Tux 2.6.16-A0 (Just rediffing)
+- Update Ingo's latency tracer patch.
 
 * Sun Mar 19 2006 Dave Jones <davej at redhat.com>
 - 2.6.16rc6-git12

linux-2.6-debug-latency-tracing.patch:
 Makefile                           |   10 
 arch/arm/boot/compressed/head.S    |   13 
 arch/arm/boot/compressed/misc.c    |    1 
 arch/arm/kernel/entry-common.S     |  109 +
 arch/arm/kernel/fiq.c              |    4 
 arch/arm/kernel/irq.c              |    4 
 arch/arm/kernel/traps.c            |    2 
 arch/arm/mm/copypage-v4mc.c        |    4 
 arch/arm/mm/copypage-xscale.c      |    4 
 arch/arm/mm/fault.c                |   14 
 arch/arm26/boot/compressed/misc.c  |    1 
 arch/i386/Kconfig                  |    2 
 arch/i386/boot/compressed/misc.c   |    9 
 arch/i386/kernel/Makefile          |    1 
 arch/i386/kernel/entry.S           |   41 
 arch/i386/kernel/irq.c             |    8 
 arch/i386/kernel/mcount-wrapper.S  |   27 
 arch/i386/kernel/traps.c           |    1 
 arch/i386/mm/fault.c               |    1 
 arch/ppc/boot/Makefile             |    9 
 arch/ppc/boot/lib/Makefile         |   48 
 arch/ppc/kernel/entry.S            |   82 +
 arch/x86_64/boot/compressed/misc.c |    1 
 arch/x86_64/kernel/entry.S         |   48 
 arch/x86_64/kernel/vsyscall.c      |    2 
 arch/x86_64/mm/fault.c             |    1 
 fs/proc/proc_misc.c                |   17 
 include/asm-arm/pgalloc.h          |    4 
 include/asm-arm/timex.h            |   10 
 include/asm-arm/unistd.h           |    4 
 include/asm-i386/system.h          |    8 
 include/asm-x86_64/system.h        |   15 
 include/asm-x86_64/unistd.h        |    2 
 include/linux/interrupt.h          |   10 
 include/linux/kernel.h             |    2 
 include/linux/latency_hist.h       |   32 
 include/linux/linkage.h            |    2 
 include/linux/preempt.h            |   20 
 include/linux/sched.h              |   86 +
 kernel/Makefile                    |    3 
 kernel/latency.c                   | 2465 +++++++++++++++++++++++++++++++++++++
 kernel/latency_hist.c              |  267 ++++
 kernel/sched.c                     |  101 +
 kernel/sysctl.c                    |   77 +
 kernel/time.c                      |   19 
 lib/Kconfig.debug                  |  152 ++
 lib/inflate.c                      |   44 
 lib/zlib_inflate/inftrees.c        |   45 
 48 files changed, 3734 insertions(+), 98 deletions(-)

Index: linux-2.6-debug-latency-tracing.patch
===================================================================
RCS file: /cvs/dist/rpms/kernel/devel/linux-2.6-debug-latency-tracing.patch,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- linux-2.6-debug-latency-tracing.patch	13 Mar 2006 22:17:56 -0000	1.10
+++ linux-2.6-debug-latency-tracing.patch	20 Mar 2006 22:24:02 -0000	1.11
@@ -1,393 +1,8 @@
-
-this patch reduces the ~2500+ worst-case stack footprint of zlib to 
-~500 bytes, by making the largest arrays static and by introducing a
-spinlock to protect access to them.
-
-Signed-off-by: Ingo Molnar <mingo at elte.hu>
-
- arch/arm/boot/compressed/misc.c    |    1 
- arch/arm26/boot/compressed/misc.c  |    1 
- arch/i386/boot/compressed/misc.c   |    1 
- arch/x86_64/boot/compressed/misc.c |    1 
- lib/inflate.c                      |   44 +++++++++++++++++++++++++++---------
- lib/zlib_inflate/inftrees.c        |   45 ++++++++++++++++++++++++++++---------
- 6 files changed, 72 insertions(+), 21 deletions(-)
-
-Index: linux/arch/arm/boot/compressed/misc.c
-===================================================================
---- linux.orig/arch/arm/boot/compressed/misc.c
-+++ linux/arch/arm/boot/compressed/misc.c
-@@ -199,6 +199,7 @@ static ulg free_mem_ptr_end;
- 
- #define HEAP_SIZE 0x2000
- 
-+#define ZLIB_INFLATE_NO_INFLATE_LOCK
- #include "../../../../lib/inflate.c"
- 
- #ifndef STANDALONE_DEBUG
-Index: linux/arch/arm26/boot/compressed/misc.c
-===================================================================
---- linux.orig/arch/arm26/boot/compressed/misc.c
-+++ linux/arch/arm26/boot/compressed/misc.c
-@@ -184,6 +184,7 @@ static ulg free_mem_ptr_end;
- 
- #define HEAP_SIZE 0x2000
- 
-+#define ZLIB_INFLATE_NO_INFLATE_LOCK
- #include "../../../../lib/inflate.c"
- 
- #ifndef STANDALONE_DEBUG
-Index: linux/arch/i386/boot/compressed/misc.c
-===================================================================
---- linux.orig/arch/i386/boot/compressed/misc.c
-+++ linux/arch/i386/boot/compressed/misc.c
-@@ -125,6 +125,7 @@ static int lines, cols;
- static void * xquad_portio = NULL;
- #endif
- 
-+#define ZLIB_INFLATE_NO_INFLATE_LOCK
- #include "../../../../lib/inflate.c"
- 
- static void *malloc(int size)
-Index: linux/arch/x86_64/boot/compressed/misc.c
-===================================================================
---- linux.orig/arch/x86_64/boot/compressed/misc.c
-+++ linux/arch/x86_64/boot/compressed/misc.c
-@@ -114,6 +114,7 @@ static char *vidmem = (char *)0xb8000;
- static int vidport;
- static int lines, cols;
- 
-+#define ZLIB_INFLATE_NO_INFLATE_LOCK
- #include "../../../../lib/inflate.c"
- 
- static void *malloc(int size)
-Index: linux/lib/inflate.c
-===================================================================
---- linux.orig/lib/inflate.c
-+++ linux/lib/inflate.c
-@@ -141,6 +141,25 @@ struct huft {
-   } v;
- };
- 
-+/*
-+ * turn off the inflate_lock for the bootloader code, it is
-+ * single-threaded and has no need for (nor access to) the
-+ * kernel's locking primitives:
-+ */
-+#ifdef ZLIB_INFLATE_NO_INFLATE_LOCK
-+# undef DEFINE_SPINLOCK
-+# undef spin_lock
-+# undef spin_unlock
-+# define DEFINE_SPINLOCK(x)	int x
-+# define spin_lock(x)		(void)(x)
-+# define spin_unlock(x)		(void)(x)
-+#endif
-+
-+/*
-+ * lock protecting static variables of huft_build() and other inflate
-+ * functions, to reduce their insane stack footprint.
-+ */
-+static DEFINE_SPINLOCK(inflate_lock);
- 
- /* Function prototypes */
- STATIC int INIT huft_build OF((unsigned *, unsigned, unsigned, 
-@@ -304,7 +323,7 @@ STATIC int INIT huft_build(
-   register struct huft *q;      /* points to current table */
-   struct huft r;                /* table entry for structure assignment */
-   struct huft *u[BMAX];         /* table stack */
--  unsigned v[N_MAX];            /* values in order of bit length */
-+  static unsigned v[N_MAX];     /* values in order of bit length */
-   register int w;               /* bits before this table == (l * h) */
-   unsigned x[BMAX+1];           /* bit offsets, then code stack */
-   unsigned *xp;                 /* pointer into x */
-@@ -705,7 +724,7 @@ STATIC int noinline INIT inflate_fixed(v
-   struct huft *td;      /* distance code table */
-   int bl;               /* lookup bits for tl */
-   int bd;               /* lookup bits for td */
--  unsigned l[288];      /* length list for huft_build */
-+  static unsigned l[288];      /* length list for huft_build */
- 
- DEBG("<fix");
- 
-@@ -767,9 +786,9 @@ STATIC int noinline INIT inflate_dynamic
-   unsigned nl;          /* number of literal/length codes */
-   unsigned nd;          /* number of distance codes */
- #ifdef PKZIP_BUG_WORKAROUND
--  unsigned ll[288+32];  /* literal/length and distance code lengths */
-+  static unsigned ll[288+32];  /* literal/length and distance code lengths */
- #else
--  unsigned ll[286+30];  /* literal/length and distance code lengths */
-+  static unsigned ll[286+30];  /* literal/length and distance code lengths */
- #endif
-   register ulg b;       /* bit buffer */
-   register unsigned k;  /* number of bits in bit buffer */
-@@ -940,6 +959,7 @@ STATIC int INIT inflate_block(
-   unsigned t;           /* block type */
-   register ulg b;       /* bit buffer */
-   register unsigned k;  /* number of bits in bit buffer */
-+  unsigned ret;         /* return code */
- 
-   DEBG("<blk");
- 
-@@ -965,17 +985,19 @@ STATIC int INIT inflate_block(
-   bk = k;
- 
-   /* inflate that block type */
--  if (t == 2)
--    return inflate_dynamic();
--  if (t == 0)
--    return inflate_stored();
--  if (t == 1)
--    return inflate_fixed();
-+  ret = 2;
-+  spin_lock(&inflate_lock);
-+  switch (t) {
-+	case 2: ret = inflate_dynamic(); break;
-+	case 0: ret = inflate_stored();  break;
-+	case 1: ret = inflate_fixed();   break;
-+  }
-+  spin_unlock(&inflate_lock);
- 
-   DEBG(">");
- 
-   /* bad block type */
--  return 2;
-+  return ret;
- 
-  underrun:
-   return 4;			/* Input underrun */
-Index: linux/lib/zlib_inflate/inftrees.c
-===================================================================
---- linux.orig/lib/zlib_inflate/inftrees.c
-+++ linux/lib/zlib_inflate/inftrees.c
-@@ -4,11 +4,19 @@
-  */
- 
- #include <linux/zutil.h>
-+#include <linux/spinlock.h>
- #include "inftrees.h"
- #include "infutil.h"
- 
- static const char inflate_copyright[] __attribute_used__ =
-    " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
-+
-+/*
-+ * lock protecting static variables of huft_build() and other inflate
-+ * functions, to reduce their insane stack footprint.
-+ */
-+static DEFINE_SPINLOCK(inflate_lock);
-+
- /*
-   If you use the zlib library in a product, an acknowledgment is welcome
-   in the documentation of your product. If for some reason you cannot
-@@ -107,7 +115,7 @@ static int huft_build(
- {
- 
-   uInt a;                       /* counter for codes of length k */
--  uInt c[BMAX+1];               /* bit length count table */
-+  static uInt c[BMAX+1];        /* bit length count table */
-   uInt f;                       /* i repeats in table every f entries */
-   int g;                        /* maximum code length */
-   int h;                        /* table level */
-@@ -118,10 +126,10 @@ static int huft_build(
-   uInt mask;                    /* (1 << w) - 1, to avoid cc -O bug on HP */
-   register uInt *p;             /* pointer into c[], b[], or v[] */
-   inflate_huft *q;              /* points to current table */
--  struct inflate_huft_s r;      /* table entry for structure assignment */
--  inflate_huft *u[BMAX];        /* table stack */
-+  static struct inflate_huft_s r; /* table entry for structure assignment */
-+  static inflate_huft *u[BMAX]; /* table stack */
-   register int w;               /* bits before this table == (l * h) */
--  uInt x[BMAX+1];               /* bit offsets, then code stack */
-+  static uInt x[BMAX+1];        /* bit offsets, then code stack */
-   uInt *xp;                     /* pointer into x */
-   int y;                        /* number of dummy codes added */
-   uInt z;                       /* number of entries in current table */
-@@ -300,9 +308,13 @@ int zlib_inflate_trees_bits(
-   int r;
-   uInt hn = 0;          /* hufts used in space */
-   uInt *v;              /* work area for huft_build */
--  
-+
-   v = WS(z)->tree_work_area_1;
-+
-+  spin_lock(&inflate_lock);
-   r = huft_build(c, 19, 19, NULL, NULL, tb, bb, hp, &hn, v);
-+  spin_unlock(&inflate_lock);
-+
-   if (r == Z_DATA_ERROR)
-     z->msg = (char*)"oversubscribed dynamic bit lengths tree";
-   else if (r == Z_BUF_ERROR || *bb == 0)
-@@ -333,7 +345,10 @@ int zlib_inflate_trees_dynamic(
-   v = WS(z)->tree_work_area_2;
- 
-   /* build literal/length tree */
-+  spin_lock(&inflate_lock);
-   r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
-+  spin_unlock(&inflate_lock);
-+
-   if (r != Z_OK || *bl == 0)
-   {
-     if (r == Z_DATA_ERROR)
-@@ -347,7 +362,10 @@ int zlib_inflate_trees_dynamic(
-   }
- 
-   /* build distance tree */
-+  spin_lock(&inflate_lock);
-   r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
-+  spin_unlock(&inflate_lock);
-+
-   if (r != Z_OK || (*bd == 0 && nl > 257))
-   {
-     if (r == Z_DATA_ERROR)
-@@ -383,9 +401,11 @@ int zlib_inflate_trees_fixed(
- 	z_streamp z              /* for memory allocation */
- )
- {
--  int i;                /* temporary variable */
--  unsigned l[288];      /* length list for huft_build */
--  uInt *v;              /* work area for huft_build */
-+  int i;                       /* temporary variable */
-+  static unsigned l[288];      /* length list for huft_build */
-+  uInt *v;                     /* work area for huft_build */
-+
-+  spin_lock(&inflate_lock);
- 
-   /* set up literal table */
-   for (i = 0; i < 144; i++)
-@@ -398,15 +418,20 @@ int zlib_inflate_trees_fixed(
-     l[i] = 8;
-   *bl = 9;
-   v = WS(z)->tree_work_area_1;
--  if ((i = huft_build(l, 288, 257, cplens, cplext, tl, bl, hp,  &i, v)) != 0)
-+  if ((i = huft_build(l, 288, 257, cplens, cplext, tl, bl, hp,  &i, v)) != 0) {
-+    spin_unlock(&inflate_lock);
-     return i;
-+  }
- 
-   /* set up distance table */
-   for (i = 0; i < 30; i++)      /* make an incomplete code set */
-     l[i] = 5;
-   *bd = 5;
--  if ((i = huft_build(l, 30, 0, cpdist, cpdext, td, bd, hp, &i, v)) > 1)
-+  if ((i = huft_build(l, 30, 0, cpdist, cpdext, td, bd, hp, &i, v)) > 1) {
-+    spin_unlock(&inflate_lock);
-     return i;
-+  }
- 
-+  spin_unlock(&inflate_lock);
-   return Z_OK;
- }
- arch/ppc/boot/lib/Makefile |   48 ++++++++++++++++++++++++++++++++++++---------
- 1 files changed, 39 insertions(+), 9 deletions(-)
-
-Index: linux/arch/ppc/boot/lib/Makefile
-===================================================================
---- linux.orig/arch/ppc/boot/lib/Makefile
-+++ linux/arch/ppc/boot/lib/Makefile
-@@ -5,19 +5,49 @@
- CFLAGS_kbd.o	:= -Idrivers/char
- CFLAGS_vreset.o := -I$(srctree)/arch/ppc/boot/include
- 
--zlib  := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
--	 
--lib-y += $(zlib:.c=.o) div64.o
--lib-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
--
-+zlib       := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
-+zlibheader := infblock.h infcodes.h inffast.h inftrees.h infutil.h
-+zliblinuxheader := zlib.h zconf.h zutil.h
-+
-+$(addprefix $(obj)/,$(zlib)): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
-+
-+src-boot := div64.S
-+src-boot += $(zlib)
-+#src-boot := $(addprefix $(obj)/, $(src-boot))
-+obj-boot := $(addsuffix .o, $(basename $(src-boot)))
- 
--# zlib files needs header from their original place
--EXTRA_CFLAGS += -Ilib/zlib_inflate
-+BOOTCFLAGS	+= -I$(obj) -I$(srctree)/$(obj) $(CFLAGS)
- 
- quiet_cmd_copy_zlib = COPY    $@
--      cmd_copy_zlib = cat $< > $@
-+      cmd_copy_zlib = sed "s at __attribute_used__@@;s at .include.<linux/module.h>@@;s at .include.<linux/spinlock.h>@@;s at .*spin.*lock.*@@;s at .*SPINLOCK.*@@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
-+
-+quiet_cmd_copy_zlibheader = COPY    $@
-+      cmd_copy_zlibheader = sed "s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
-+# stddef.h for NULL
-+quiet_cmd_copy_zliblinuxheader = COPY    $@
-+      cmd_copy_zliblinuxheader = sed "s at .include.<linux/string.h>@@;s at .include.<linux/errno.h>@@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
- 
- $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
- 	$(call cmd,copy_zlib)
- 
--clean-files := $(zlib)
-+$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
-+	$(call cmd,copy_zlibheader)
-+
-+$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
-+	$(call cmd,copy_zliblinuxheader)
-+
-+clean-files := $(zlib) $(zlibheader) $(zliblinuxheader)
-+
-+quiet_cmd_bootcc = BOOTCC  $@
-+      cmd_bootcc = $(CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
-+
-+quiet_cmd_bootas = BOOTAS  $@
-+      cmd_bootas = $(CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
-+
-+$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
-+	$(call if_changed_dep,bootcc)
-+$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
-+	$(call if_changed_dep,bootas)
-+
-+lib-y += $(obj-boot)
-+lib-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
- Makefile                          |   10 
- arch/arm/boot/compressed/head.S   |   13 
- arch/arm/kernel/calls.S           |    6 
- arch/arm/kernel/entry-common.S    |  111 +
- arch/arm/kernel/fiq.c             |    4 
- arch/arm/kernel/irq.c             |    4 
- arch/arm/kernel/traps.c           |    2 
- arch/arm/mm/copypage-v4mc.c       |    4 
- arch/arm/mm/copypage-xscale.c     |    4 
- arch/arm/mm/fault.c               |   14 
- arch/i386/Kconfig                 |    2 
- arch/i386/boot/compressed/misc.c  |    8 
- arch/i386/kernel/Makefile         |    1 
- arch/i386/kernel/entry.S          |   41 
- arch/i386/kernel/irq.c            |    8 
- arch/i386/kernel/mcount-wrapper.S |   27 
- arch/ppc/boot/Makefile            |    9 
- arch/ppc/kernel/entry.S           |   82 +
- arch/x86_64/kernel/entry.S        |   48 
- arch/x86_64/kernel/vsyscall.c     |    2 
- fs/proc/proc_misc.c               |   17 
- include/asm-arm/pgalloc.h         |    4 
- include/asm-arm/timex.h           |   10 
- include/asm-arm/unistd.h          |    3 
- include/asm-i386/system.h         |    8 
- include/linux/interrupt.h         |   10 
- include/linux/latency_hist.h      |   32 
- include/linux/linkage.h           |    2 
- include/linux/preempt.h           |   20 
- include/linux/sched.h             |   86 +
- kernel/Makefile                   |    3 
- kernel/latency.c                  | 2390 ++++++++++++++++++++++++++++++++++++++
- kernel/latency_hist.c             |  267 ++++
- kernel/sched.c                    |  103 +
- kernel/sysctl.c                   |   77 +
- kernel/time.c                     |   19 
- lib/Kconfig.debug                 |  149 ++
- 37 files changed, 3530 insertions(+), 70 deletions(-)
-
 Index: linux-latency-tracing.q/Makefile
 ===================================================================
 --- linux-latency-tracing.q.orig/Makefile
 +++ linux-latency-tracing.q/Makefile
-@@ -519,10 +519,14 @@ CFLAGS		+= $(call add-align,CONFIG_CC_AL
+@@ -511,10 +511,14 @@ CFLAGS		+= $(call add-align,CONFIG_CC_AL
  CFLAGS		+= $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
  CFLAGS		+= $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
  
@@ -409,7 +24,7 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/arm/boot/compressed/head.S
 +++ linux-latency-tracing.q/arch/arm/boot/compressed/head.S
-@@ -710,6 +710,19 @@ memdump:	mov	r12, r0
+@@ -714,6 +714,19 @@ memdump:	mov	r12, r0
  		mov	pc, r10
  #endif
  
@@ -429,28 +44,18 @@
  reloc_end:
  
  		.align
-Index: linux-latency-tracing.q/arch/arm/kernel/calls.S
+Index: linux-latency-tracing.q/arch/arm/boot/compressed/misc.c
 ===================================================================
---- linux-latency-tracing.q.orig/arch/arm/kernel/calls.S
-+++ linux-latency-tracing.q/arch/arm/kernel/calls.S
-@@ -7,11 +7,8 @@
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-- *  This file is included twice in entry-common.S
-+ *  NR_syscalls now defined in include/asm-arm/unistd.h - tglx
-  */
--#ifndef NR_syscalls
--#define NR_syscalls 328
--#else
- 
- __syscall_start:
- /* 0 */		.long	sys_restart_syscall
-@@ -341,4 +338,3 @@ __syscall_end:
- 		.rept	NR_syscalls - (__syscall_end - __syscall_start) / 4
- 			.long	sys_ni_syscall
- 		.endr
--#endif
+--- linux-latency-tracing.q.orig/arch/arm/boot/compressed/misc.c
++++ linux-latency-tracing.q/arch/arm/boot/compressed/misc.c
+@@ -199,6 +199,7 @@ static ulg free_mem_ptr_end;
+ 
+ #define HEAP_SIZE 0x2000
+ 
++#define ZLIB_INFLATE_NO_INFLATE_LOCK
+ #include "../../../../lib/inflate.c"
+ 
+ #ifndef STANDALONE_DEBUG
 Index: linux-latency-tracing.q/arch/arm/kernel/entry-common.S
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/arm/kernel/entry-common.S
@@ -464,20 +69,10 @@
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
-@@ -87,8 +89,6 @@ ENTRY(ret_from_fork)
- 	b	ret_slow_syscall
- 	
+@@ -389,5 +391,112 @@ ENTRY(sys_oabi_call_table)
+ #undef ABI
+ #undef OBSOLETE
  
--#include "calls.S"
--
- /*=============================================================================
-  * SWI handler
-  *-----------------------------------------------------------------------------
-@@ -271,3 +271,110 @@ sys_mmap2:
- 		str	r5, [sp, #4]
- 		b	do_mmap2
- #endif
-+
 +#ifdef CONFIG_FRAME_POINTER
 +
 +#ifdef CONFIG_MCOUNT
@@ -584,6 +179,9 @@
 +	mov	pc, lr
 +
 +#endif
++
+ #endif
+ 
 Index: linux-latency-tracing.q/arch/arm/kernel/fiq.c
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/arm/kernel/fiq.c
@@ -748,11 +346,23 @@
  do_PrefetchAbort(unsigned long addr, struct pt_regs *regs)
  {
  	do_translation_fault(addr, 0, regs);
+Index: linux-latency-tracing.q/arch/arm26/boot/compressed/misc.c
+===================================================================
+--- linux-latency-tracing.q.orig/arch/arm26/boot/compressed/misc.c
++++ linux-latency-tracing.q/arch/arm26/boot/compressed/misc.c
+@@ -184,6 +184,7 @@ static ulg free_mem_ptr_end;
+ 
+ #define HEAP_SIZE 0x2000
+ 
++#define ZLIB_INFLATE_NO_INFLATE_LOCK
+ #include "../../../../lib/inflate.c"
+ 
+ #ifndef STANDALONE_DEBUG
 Index: linux-latency-tracing.q/arch/i386/Kconfig
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/i386/Kconfig
 +++ linux-latency-tracing.q/arch/i386/Kconfig
-@@ -619,7 +619,7 @@ config BOOT_IOREMAP
+@@ -661,7 +661,7 @@ config BOOT_IOREMAP
  
  config REGPARM
  	bool "Use register arguments (EXPERIMENTAL)"
@@ -787,6 +397,14 @@
  static unsigned int low_buffer_end, low_buffer_size;
  static int high_loaded =0;
  static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/;
+@@ -125,6 +131,7 @@ static int lines, cols;
+ static void * xquad_portio = NULL;
+ #endif
+ 
++#define ZLIB_INFLATE_NO_INFLATE_LOCK
+ #include "../../../../lib/inflate.c"
+ 
+ static void *malloc(int size)
 Index: linux-latency-tracing.q/arch/i386/kernel/Makefile
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/i386/kernel/Makefile
@@ -857,7 +475,7 @@
  	RESTORE_REGS
  	addl $4, %esp
  1:	iret
-@@ -351,6 +377,11 @@ syscall_trace_entry:
+@@ -353,6 +379,11 @@ syscall_trace_entry:
  syscall_exit_work:
  	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
  	jz work_pending
@@ -869,7 +487,7 @@
  	sti				# could let do_syscall_trace() call
  					# schedule() instead
  	movl %esp, %eax
-@@ -412,9 +443,16 @@ ENTRY(irq_entries_start)
+@@ -414,9 +445,16 @@ ENTRY(irq_entries_start)
  vector=vector+1
  .endr
  
@@ -886,7 +504,7 @@
  	movl %esp,%eax
  	call do_IRQ
  	jmp ret_from_intr
-@@ -423,6 +461,7 @@ common_interrupt:
+@@ -425,6 +463,7 @@ common_interrupt:
  ENTRY(name)				\
  	pushl $nr-256;			\
  	SAVE_ALL			\
@@ -894,7 +512,7 @@
  	movl %esp,%eax;			\
  	call smp_/**/name;		\
  	jmp ret_from_intr;
-@@ -552,7 +591,7 @@ nmi_stack_correct:
+@@ -554,7 +593,7 @@ nmi_stack_correct:
  	xorl %edx,%edx		# zero error code
  	movl %esp,%eax		# pt_regs pointer
  	call do_nmi
@@ -962,6 +580,30 @@
 +out:
 +	ret
 +
+Index: linux-latency-tracing.q/arch/i386/kernel/traps.c
+===================================================================
+--- linux-latency-tracing.q.orig/arch/i386/kernel/traps.c
++++ linux-latency-tracing.q/arch/i386/kernel/traps.c
+@@ -169,6 +169,7 @@ static void show_trace_log_lvl(struct ta
+ 		printk(log_lvl);
+ 		printk(" =======================\n");
+ 	}
++	print_traces(task);
+ }
+ 
+ void show_trace(struct task_struct *task, unsigned long * stack)
+Index: linux-latency-tracing.q/arch/i386/mm/fault.c
+===================================================================
+--- linux-latency-tracing.q.orig/arch/i386/mm/fault.c
++++ linux-latency-tracing.q/arch/i386/mm/fault.c
+@@ -39,6 +39,7 @@ void bust_spinlocks(int yes)
+ 	int loglevel_save = console_loglevel;
+ 
+ 	if (yes) {
++		stop_trace();
+ 		oops_in_progress = 1;
+ 		return;
+ 	}
 Index: linux-latency-tracing.q/arch/ppc/boot/Makefile
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/ppc/boot/Makefile
@@ -982,11 +624,74 @@
  HOSTCFLAGS	+= -Iarch/$(ARCH)/boot/include
  
  BOOT_TARGETS	= zImage zImage.initrd znetboot znetboot.initrd
+Index: linux-latency-tracing.q/arch/ppc/boot/lib/Makefile
+===================================================================
+--- linux-latency-tracing.q.orig/arch/ppc/boot/lib/Makefile
++++ linux-latency-tracing.q/arch/ppc/boot/lib/Makefile
+@@ -5,19 +5,49 @@
+ CFLAGS_kbd.o	:= -Idrivers/char
+ CFLAGS_vreset.o := -I$(srctree)/arch/ppc/boot/include
+ 
+-zlib  := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
+-	 
+-lib-y += $(zlib:.c=.o) div64.o
+-lib-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
+-
++zlib       := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
++zlibheader := infblock.h infcodes.h inffast.h inftrees.h infutil.h
++zliblinuxheader := zlib.h zconf.h zutil.h
++
++$(addprefix $(obj)/,$(zlib)): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
++
++src-boot := div64.S
++src-boot += $(zlib)
++#src-boot := $(addprefix $(obj)/, $(src-boot))
++obj-boot := $(addsuffix .o, $(basename $(src-boot)))
+ 
+-# zlib files needs header from their original place
+-EXTRA_CFLAGS += -Ilib/zlib_inflate
++BOOTCFLAGS	+= -I$(obj) -I$(srctree)/$(obj) $(CFLAGS)
+ 
+ quiet_cmd_copy_zlib = COPY    $@
+-      cmd_copy_zlib = cat $< > $@
++      cmd_copy_zlib = sed "s at __attribute_used__@@;s at .include.<linux/module.h>@@;s at .include.<linux/spinlock.h>@@;s at .*spin.*lock.*@@;s at .*SPINLOCK.*@@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
++
++quiet_cmd_copy_zlibheader = COPY    $@
++      cmd_copy_zlibheader = sed "s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
++# stddef.h for NULL
++quiet_cmd_copy_zliblinuxheader = COPY    $@
++      cmd_copy_zliblinuxheader = sed "s at .include.<linux/string.h>@@;s at .include.<linux/errno.h>@@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
+ 
+ $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
+ 	$(call cmd,copy_zlib)
+ 
+-clean-files := $(zlib)
++$(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
++	$(call cmd,copy_zlibheader)
++
++$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
++	$(call cmd,copy_zliblinuxheader)
++
++clean-files := $(zlib) $(zlibheader) $(zliblinuxheader)
++
++quiet_cmd_bootcc = BOOTCC  $@
++      cmd_bootcc = $(CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
++
++quiet_cmd_bootas = BOOTAS  $@
++      cmd_bootas = $(CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
++
++$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
++	$(call if_changed_dep,bootcc)
++$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
++	$(call if_changed_dep,bootas)
++
++lib-y += $(obj-boot)
++lib-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o
 Index: linux-latency-tracing.q/arch/ppc/kernel/entry.S
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/ppc/kernel/entry.S
 +++ linux-latency-tracing.q/arch/ppc/kernel/entry.S
-@@ -1000,3 +1000,85 @@ machine_check_in_rtas:
+@@ -978,3 +978,85 @@ machine_check_in_rtas:
  	/* XXX load up BATs and panic */
  
  #endif /* CONFIG_PPC_OF */
@@ -1072,11 +777,23 @@
 +	bctr
 +
 +#endif /* CONFIG_MCOUNT */
+Index: linux-latency-tracing.q/arch/x86_64/boot/compressed/misc.c
+===================================================================
+--- linux-latency-tracing.q.orig/arch/x86_64/boot/compressed/misc.c
++++ linux-latency-tracing.q/arch/x86_64/boot/compressed/misc.c
+@@ -114,6 +114,7 @@ static char *vidmem = (char *)0xb8000;
+ static int vidport;
+ static int lines, cols;
+ 
++#define ZLIB_INFLATE_NO_INFLATE_LOCK
+ #include "../../../../lib/inflate.c"
+ 
+ static void *malloc(int size)
 Index: linux-latency-tracing.q/arch/x86_64/kernel/entry.S
 ===================================================================
 --- linux-latency-tracing.q.orig/arch/x86_64/kernel/entry.S
 +++ linux-latency-tracing.q/arch/x86_64/kernel/entry.S
-@@ -48,6 +48,15 @@
+@@ -49,6 +49,15 @@
  #define retint_kernel retint_restore_args
  #endif	
  	
@@ -1092,7 +809,7 @@
  /*
   * C code is not supposed to know about undefined top of stack. Every time 
   * a C function with an pt_regs argument is called from the SYSCALL based 
-@@ -593,6 +602,7 @@ retint_kernel:	
+@@ -600,6 +609,7 @@ retint_kernel:	
  	bt   $9,EFLAGS-ARGOFFSET(%rsp)	/* interrupts off? */
  	jnc  retint_restore_args
  	call preempt_schedule_irq
@@ -1100,8 +817,8 @@
  	jmp exit_intr
  #endif	
  	CFI_ENDPROC
-@@ -1041,3 +1051,41 @@ ENTRY(call_softirq)
- 	CFI_ADJUST_CFA_OFFSET -8
+@@ -1059,3 +1069,41 @@ ENTRY(call_softirq)
+ 	decl %gs:pda_irqcount
  	ret
  	CFI_ENDPROC
 +
@@ -1152,14 +869,26 @@
  
 -#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
 +#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) notrace
- #define force_inline __attribute__((always_inline)) inline
  
  int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
+ seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
+Index: linux-latency-tracing.q/arch/x86_64/mm/fault.c
+===================================================================
+--- linux-latency-tracing.q.orig/arch/x86_64/mm/fault.c
++++ linux-latency-tracing.q/arch/x86_64/mm/fault.c
+@@ -45,6 +45,7 @@ void bust_spinlocks(int yes)
+ {
+ 	int loglevel_save = console_loglevel;
+ 	if (yes) {
++		stop_trace();
+ 		oops_in_progress = 1;
+ 	} else {
+ #ifdef CONFIG_VT
 Index: linux-latency-tracing.q/fs/proc/proc_misc.c
 ===================================================================
 --- linux-latency-tracing.q.orig/fs/proc/proc_misc.c
 +++ linux-latency-tracing.q/fs/proc/proc_misc.c
-@@ -531,6 +531,20 @@ static int execdomains_read_proc(char *p
+@@ -673,6 +673,20 @@ static int execdomains_read_proc(char *p
  	return proc_calc_metrics(page, start, off, count, eof, len);
  }
  
@@ -1180,7 +909,7 @@
  #ifdef CONFIG_MAGIC_SYSRQ
  /*
   * writing 'C' to /proc/sysrq-trigger is like sysrq-C
-@@ -611,6 +625,9 @@ void __init proc_misc_init(void)
+@@ -755,6 +769,9 @@ void __init proc_misc_init(void)
  #ifdef CONFIG_SCHEDSTATS
  	create_seq_entry("schedstat", 0, &proc_schedstat_operations);
  #endif
@@ -1239,11 +968,12 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/include/asm-arm/unistd.h
 +++ linux-latency-tracing.q/include/asm-arm/unistd.h
-@@ -526,6 +526,9 @@ type name(type1 arg1, type2 arg2, type3 
- #define __ARCH_WANT_SYS_SIGPENDING
- #define __ARCH_WANT_SYS_SIGPROCMASK
- #define __ARCH_WANT_SYS_RT_SIGACTION
+@@ -533,6 +533,10 @@ type name(type1 arg1, type2 arg2, type3 
+ #define __ARCH_WANT_OLD_READDIR
+ #define __ARCH_WANT_SYS_SOCKETCALL
+ #endif
 +
++// FIXME: check this number ...
 +#define NR_syscalls	328
 +
  #endif
@@ -1253,7 +983,7 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/include/asm-i386/system.h
 +++ linux-latency-tracing.q/include/asm-i386/system.h
-@@ -531,13 +531,17 @@ struct alt_instr { 
+@@ -528,13 +528,17 @@ struct alt_instr { 
  /* used when interrupts are already enabled or to shutdown the processor */
  #define halt()			__asm__ __volatile__("hlt": : :"memory")
  
@@ -1273,6 +1003,61 @@
  /* For spinlocks etc */
  #define local_irq_save(x)	__asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
  
+Index: linux-latency-tracing.q/include/asm-x86_64/system.h
+===================================================================
+--- linux-latency-tracing.q.orig/include/asm-x86_64/system.h
++++ linux-latency-tracing.q/include/asm-x86_64/system.h
+@@ -341,10 +341,8 @@ static inline unsigned long __cmpxchg(vo
+ #define local_irq_disable()	do { unsigned long flags; local_save_flags(flags); local_irq_restore((flags & ~(1 << 9)) | (1 << 18)); } while (0)
+ #define local_irq_enable()	do { unsigned long flags; local_save_flags(flags); local_irq_restore((flags | (1 << 9)) & ~(1 << 18)); } while (0)
+ 
+-#define irqs_disabled()					\
++#define irqs_disabled_flags(flags)			\
+ ({							\
+-	unsigned long flags;				\
+-	local_save_flags(flags);			\
+ 	(flags & (1<<18)) || !(flags & (1<<9));		\
+ })
+ 
+@@ -354,10 +352,8 @@ static inline unsigned long __cmpxchg(vo
+ #define local_irq_disable() 	__asm__ __volatile__("cli": : :"memory")
+ #define local_irq_enable()	__asm__ __volatile__("sti": : :"memory")
+ 
+-#define irqs_disabled()			\
++#define irqs_disabled_flags(flags)	\
+ ({					\
+-	unsigned long flags;		\
+-	local_save_flags(flags);	\
+ 	!(flags & (1<<9));		\
+ })
+ 
+@@ -365,6 +361,13 @@ static inline unsigned long __cmpxchg(vo
+ #define local_irq_save(x) 	do { warn_if_not_ulong(x); __asm__ __volatile__("# local_irq_save \n\t pushfq ; popq %0 ; cli":"=g" (x): /* no input */ :"memory"); } while (0)
+ #endif
+ 
++#define irqs_disabled()			\
++({					\
++	unsigned long flags;		\
++	local_save_flags(flags);	\
++	irqs_disabled_flags(flags);	\
++})
++
+ /* used in the idle loop; sti takes one instruction cycle to complete */
+ #define safe_halt()		__asm__ __volatile__("sti; hlt": : :"memory")
+ /* used when interrupts are already enabled or to shutdown the processor */
+Index: linux-latency-tracing.q/include/asm-x86_64/unistd.h
+===================================================================
+--- linux-latency-tracing.q.orig/include/asm-x86_64/unistd.h
++++ linux-latency-tracing.q/include/asm-x86_64/unistd.h
+@@ -11,6 +11,8 @@
+  * Note: holes are not allowed.
+  */
+ 
++#define NR_syscalls (__NR_syscall_max+1)
++
+ /* at least 8 syscall per cacheline */
+ #define __NR_read                                0
+ __SYSCALL(__NR_read, sys_read)
 Index: linux-latency-tracing.q/include/linux/interrupt.h
 ===================================================================
 --- linux-latency-tracing.q.orig/include/linux/interrupt.h
@@ -1292,6 +1077,19 @@
 +#endif
 +
  #endif
+Index: linux-latency-tracing.q/include/linux/kernel.h
+===================================================================
+--- linux-latency-tracing.q.orig/include/linux/kernel.h
++++ linux-latency-tracing.q/include/linux/kernel.h
+@@ -132,6 +132,8 @@ asmlinkage int vprintk(const char *fmt, 
+ 	__attribute__ ((format (printf, 1, 0)));
+ asmlinkage int printk(const char * fmt, ...)
+ 	__attribute__ ((format (printf, 1, 2)));
++extern void early_printk(const char *fmt, ...)
++	__attribute__ ((format (printf, 1, 2)));
+ #else
+ static inline int vprintk(const char *s, va_list args)
+ 	__attribute__ ((format (printf, 1, 0)));
 Index: linux-latency-tracing.q/include/linux/latency_hist.h
 ===================================================================
 --- /dev/null
@@ -1380,7 +1178,7 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/include/linux/sched.h
 +++ linux-latency-tracing.q/include/linux/sched.h
-@@ -39,6 +39,84 @@
+@@ -40,6 +40,84 @@
  
  struct exec_domain;
  
@@ -1419,7 +1217,7 @@
 +#ifdef CONFIG_LATENCY_TRACE
 +  extern int mcount_enabled, trace_enabled, trace_user_triggered,
 +		trace_user_trigger_irq, trace_freerunning, trace_verbose,
-+		trace_print_at_crash, trace_all_cpus;
++		trace_print_at_crash, trace_all_cpus, print_functions;
 +  extern void notrace trace_special(unsigned long v1, unsigned long v2, unsigned long v3);
 +  extern void notrace trace_special_pid(int pid, unsigned long v1, unsigned long v2);
 +  extern void notrace trace_special_u64(unsigned long long v1, unsigned long v2);
@@ -1465,9 +1263,9 @@
  /*
   * cloning flags:
   */
-@@ -820,6 +898,13 @@ struct task_struct {
- /* Protection of proc_dentry: nesting proc_lock, dcache_lock, write_lock_irq(&tasklist_lock); */
- 	spinlock_t proc_lock;
+@@ -833,6 +911,13 @@ struct task_struct {
+ 	struct mutex_waiter *blocked_on;
+ #endif
  
 +#define MAX_PREEMPT_TRACE 16
 +
@@ -1479,7 +1277,7 @@
  /* journalling filesystem info */
  	void *journal_info;
  
-@@ -1349,6 +1434,7 @@ static inline unsigned int task_cpu(cons
+@@ -1355,6 +1440,7 @@ static inline unsigned int task_cpu(cons
  
  static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
  {
@@ -1491,25 +1289,25 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/kernel/Makefile
 +++ linux-latency-tracing.q/kernel/Makefile
-@@ -9,6 +9,9 @@ obj-y     = sched.o fork.o exec_domain.o
- 	    rcupdate.o intermodule.o extable.o params.o posix-timers.o \
- 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o
- 
+@@ -29,6 +29,9 @@ obj-$(CONFIG_STOP_MACHINE) += stop_machi
+ obj-$(CONFIG_AUDIT) += audit.o
+ obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
+ obj-$(CONFIG_KPROBES) += kprobes.o
 +obj-$(CONFIG_DEBUG_PREEMPT) += latency.o
 +obj-$(CONFIG_LATENCY_TIMING) += latency.o
 +obj-$(CONFIG_LATENCY_HIST) += latency_hist.o
- obj-$(CONFIG_FUTEX) += futex.o
- obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
- obj-$(CONFIG_SMP) += cpu.o spinlock.o
+ obj-$(CONFIG_SYSFS) += ksysfs.o
+ obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o
+ obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
 Index: linux-latency-tracing.q/kernel/latency.c
 ===================================================================
 --- /dev/null
 +++ linux-latency-tracing.q/kernel/latency.c
-@@ -0,0 +1,2390 @@
+@@ -0,0 +1,2465 @@
 +/*
 + *  kernel/latency.c
 + *
-+ *  Copyright (C) 2004, 2005 Ingo Molnar
++ *  Copyright (C) 2004-2006 Ingo Molnar
 + *  Copyright (C) 2004 William Lee Irwin III
 + */
 +
@@ -1535,6 +1333,7 @@
 +
 +#ifndef CONFIG_PREEMPT_RT
 +# define DEFINE_RAW_SPINLOCK		DEFINE_SPINLOCK
++# define RAW_SPIN_LOCK_UNLOCKED		SPIN_LOCK_UNLOCKED
 +# define raw_spinlock_t			spinlock_t
 +# define raw_irqs_disabled		irqs_disabled
 +# define irqs_off			irqs_disabled
@@ -1563,11 +1362,7 @@
 +} ____cacheline_aligned_in_smp;
 +
 +static __cacheline_aligned_in_smp struct sch_struct sch =
-+#ifdef CONFIG_PREEMPT_RT
 +		{ trace_lock: RAW_SPIN_LOCK_UNLOCKED };
-+#else
-+		{ trace_lock: SPIN_LOCK_UNLOCKED };
-+#endif
 +
 +int wakeup_timing = 1;
 +#endif
@@ -1579,9 +1374,9 @@
 + * we clear it after bootup.
 + */
 +#ifdef CONFIG_LATENCY_HIST
-+cycles_t preempt_max_latency = (cycles_t)0UL;
++static cycles_t preempt_max_latency = (cycles_t)0UL;
 +#else
-+cycles_t preempt_max_latency = (cycles_t)ULONG_MAX;
++static cycles_t preempt_max_latency = (cycles_t)ULONG_MAX;
 +#endif
 +
 +static cycles_t preempt_thresh;
@@ -1772,6 +1567,7 @@
 +int trace_print_at_crash = 0;
 +int trace_verbose = 0;
 +int trace_all_cpus = 0;
++int print_functions = 0;
 +
 +/*
 + * user-triggered via gettimeofday(0,1)/gettimeofday(0,0)
@@ -1934,10 +1730,17 @@
 +
 +static notrace void __print_worst_stack(void)
 +{
++	unsigned long fill_ratio;
 +	printk("----------------------------->\n");
-+	printk("| new stack-footprint maximum: %s/%d, %ld bytes (out of %ld bytes).\n",
++	printk("| new stack fill maximum: %s/%d, %ld bytes (out of %ld bytes).\n",
 +		worst_stack_comm, worst_stack_pid,
 +		MAX_STACK-worst_stack_left, (long)MAX_STACK);
++	fill_ratio = (MAX_STACK-worst_stack_left)*100/(long)MAX_STACK;
++	printk("| Stack fill ratio: %02ld%%", fill_ratio);
++	if (fill_ratio >= 90)
++		printk(" - BUG: that's quite high, please report this!\n");
++	else
++		printk(" - that's still OK, no need to report this.\n");
 +	printk("------------|\n");
 +
 +	show_stackframe();
@@ -2002,10 +1805,76 @@
 +			print_worst_stack();
 +			tr->stack_check++;
 +		}
-+out:
-+	atomic_dec(&tr->disabled);
-+}
++out:
++	atomic_dec(&tr->disabled);
++}
++
++#endif
++
++#ifdef CONFIG_EARLY_PRINTK
++static void notrace early_printk_name(unsigned long eip)
++{
++	char namebuf[KSYM_NAME_LEN+1];
++	unsigned long size, offset;
++	const char *sym_name;
++	char *modname;
++
++	sym_name = kallsyms_lookup(eip, &size, &offset, &modname, namebuf);
++	if (sym_name)
++		early_printk("%s <%08lx>", sym_name, eip);
++	else
++		early_printk("<%08lx>", eip);
++}
++
++static DEFINE_RAW_SPINLOCK(early_print_lock);
++
++static void notrace early_print_entry(struct trace_entry *entry)
++{
++	int hardirq, softirq;
++
++	spin_lock(&early_print_lock);
++	early_printk("%-5d ", entry->pid);
++
++	early_printk("%d%c%c",
++		entry->cpu,
++		(entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
++		(entry->flags & TRACE_FLAG_IRQS_HARD_OFF) ? 'D' : '.',
++ 		(entry->flags & TRACE_FLAG_NEED_RESCHED) ? 'n' : '.');
++
++	hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
++	softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
++	if (hardirq && softirq)
++		early_printk("H");
++	else {
++		if (hardirq)
++			early_printk("h");
++		else {
++			if (softirq)
++				early_printk("s");
++			else
++				early_printk(".");
++		}
++	}
 +
++	early_printk(":%d: ", entry->preempt_count);
++
++	if (entry->type == TRACE_FN) {
++		early_printk_name(entry->u.fn.eip);
++		early_printk("  <= (");
++		early_printk_name(entry->u.fn.parent_eip);
++		early_printk(")\n");
++	} else {
++		/* special entries: */
++		early_printk_name(entry->u.special.eip);
++		early_printk(": <%08lx> <%08lx> <%08lx>\n",
++			entry->u.special.v1,
++			entry->u.special.v2,
++			entry->u.special.v3);
++	}
++	spin_unlock(&early_print_lock);
++}
++#else
++#  define early_print_entry(x) do { } while(0)
 +#endif
 +
 +static void notrace
@@ -2022,7 +1891,7 @@
 +#ifdef CONFIG_DEBUG_PREEMPT
 +//	WARN_ON(!atomic_read(&tr->disabled));
 +#endif
-+	if (!tr->critical_start && !trace_user_triggered && !trace_all_cpus && !trace_print_at_crash)
++	if (!tr->critical_start && !trace_user_triggered && !trace_all_cpus && !trace_print_at_crash && !print_functions)
 +		goto out;
 +	/*
 +	 * Allocate the next index. Make sure an NMI (or interrupt)
@@ -2035,7 +1904,8 @@
 +	idx_next = idx + 1;
 +	timestamp = get_cycles();
 +
-+	if (unlikely(trace_freerunning && (idx_next >= MAX_TRACE)))
++	if (unlikely((trace_freerunning || print_functions) &&
++						(idx_next >= MAX_TRACE)))
 +		idx_next = 0;
 +	if (unlikely(idx_next >= MAX_TRACE)) {
 +		atomic_inc(&tr->overrun);
@@ -2046,7 +1916,7 @@
 +		goto again;
 +#else
 +# ifdef CONFIG_SMP
-+#  error CMPXHG missing
++#  error CMPXCHG missing
 +# else
 +	/* No worry, we are protected by the atomic_incr(&tr->disabled)
 +	 * in __trace further down
@@ -2074,6 +1944,8 @@
 +	case TRACE_FN:
 +		entry->u.fn.eip = eip;
 +		entry->u.fn.parent_eip = parent_eip;
++		if (unlikely(print_functions && !in_interrupt()))
++			early_print_entry(entry);
 +		break;
 +	case TRACE_SPECIAL:
 +	case TRACE_SPECIAL_PID:
@@ -2082,6 +1954,8 @@
 +		entry->u.special.v1 = v1;
 +		entry->u.special.v2 = v2;
 +		entry->u.special.v3 = v3;
++		if (unlikely(print_functions && !in_interrupt()))
++			early_print_entry(entry);
 +		break;
 +	case TRACE_SYSCALL:
 +		entry->u.syscall.nr = eip;
@@ -2125,7 +1999,7 @@
 +	 * is waiting to become runnable:
 +	 */
 +#ifdef CONFIG_WAKEUP_TIMING
-+	if (wakeup_timing && !trace_all_cpus && !trace_print_at_crash) {
++	if (wakeup_timing && !trace_all_cpus && !trace_print_at_crash && !print_functions) {
 +		if (!sch.tr || cpu != sch.cpu)
 +			goto out;
 +		tr = sch.tr;
@@ -2159,14 +2033,14 @@
 +	___trace(TRACE_SPECIAL, CALLER_ADDR0, 0, v1, v2, v3);
 +}
 +
-+EXPORT_SYMBOL_GPL(trace_special);
++EXPORT_SYMBOL(trace_special);
 +
 +void notrace trace_special_pid(int pid, unsigned long v1, unsigned long v2)
 +{
 +	___trace(TRACE_SPECIAL_PID, CALLER_ADDR0, 0, pid, v1, v2);
 +}
 +
-+EXPORT_SYMBOL_GPL(trace_special_pid);
++EXPORT_SYMBOL(trace_special_pid);
 +
 +void notrace trace_special_u64(unsigned long long v1, unsigned long v2)
 +{
@@ -2174,7 +2048,7 @@
 +		 (unsigned long) (v1 >> 32), (unsigned long) (v1 & 0xFFFFFFFF), v2);
 +}
 +
-+EXPORT_SYMBOL_GPL(trace_special_u64);
++EXPORT_SYMBOL(trace_special_u64);
 +
 +/*
 + * Non-inlined function:
@@ -2186,7 +2060,7 @@
 +
 +extern void mcount(void);
 +
-+EXPORT_SYMBOL_GPL(mcount);
++EXPORT_SYMBOL(mcount);
 +
 +void notrace __mcount(void)
 +{
@@ -2527,7 +2401,18 @@
 +			"rt",
 +#endif
 +			0, 0,
-+			0, 0);
++#ifdef CONFIG_PREEMPT_SOFTIRQS
++			softirq_preemption
++#else
++			0
++#endif
++			,
++#ifdef CONFIG_PREEMPT_HARDIRQS
++ hardirq_preemption
++#else
++			0
++#endif
++		);
 +#ifdef CONFIG_SMP
 +		seq_printf(m, " #P:%d)\n", num_online_cpus());
 +#else
@@ -2880,7 +2765,7 @@
 +	max_tr.cpu = tr->cpu;
 +	save = max_tr.traces + tr->cpu;
 +
-+	if ((wakeup_timing || trace_user_triggered || trace_print_at_crash) &&
++	if ((wakeup_timing || trace_user_triggered || trace_print_at_crash || print_functions) &&
 +				trace_all_cpus) {
 +		all_cpus = 1;
 +		for_each_online_cpu(cpu)
@@ -3077,7 +2962,7 @@
 +		atomic_dec(&tr->disabled);
 +	}
 +}
-+EXPORT_SYMBOL_GPL(touch_critical_timing);
++EXPORT_SYMBOL(touch_critical_timing);
 +
 +void notrace stop_critical_timing(void)
 +{
@@ -3085,7 +2970,7 @@
 +
 +	tr->critical_start = 0;
 +}
-+EXPORT_SYMBOL_GPL(stop_critical_timing);
++EXPORT_SYMBOL(stop_critical_timing);
 +
 +static inline void notrace
 +__start_critical_timing(unsigned long eip, unsigned long parent_eip, int latency_type)
@@ -3137,6 +3022,7 @@
 +
 +#ifdef CONFIG_CRITICAL_IRQSOFF_TIMING
 +
++/* FIXME: do we have to save flags here? */
 +void notrace trace_irqs_off_lowlevel(void)
 +{
 +	unsigned long flags;
@@ -3157,7 +3043,7 @@
 +		__start_critical_timing(CALLER_ADDR0, CALLER_ADDR1, INTERRUPT_LATENCY);
 +}
 +
-+EXPORT_SYMBOL_GPL(trace_irqs_off);
++EXPORT_SYMBOL(trace_irqs_off);
 +
 +void notrace trace_irqs_on(void)
 +{
@@ -3167,11 +3053,9 @@
 +
 +	if (!irqs_off_preempt_count() && raw_irqs_disabled_flags(flags))
 +		__stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
-+
-+	__raw_local_irq_restore(flags);
 +}
 +
-+EXPORT_SYMBOL_GPL(trace_irqs_on);
++EXPORT_SYMBOL(trace_irqs_on);
 +
 +#endif
 +
@@ -3192,7 +3076,7 @@
 +	return parent_eip;
 +}
 +
-+void notrace add_preempt_count_ti(struct thread_info *ti, unsigned int val)
++void notrace add_preempt_count(unsigned int val)
 +{
 +	unsigned long eip = CALLER_ADDR0;
 +	unsigned long parent_eip = get_parent_eip();
@@ -3201,17 +3085,17 @@
 +	/*
 +	 * Underflow?
 +	 */
-+	BUG_ON(((int)ti->preempt_count < 0));
++	BUG_ON(((int)preempt_count() < 0));
 +	/*
 +	 * Spinlock count overflowing soon?
 +	 */
-+	BUG_ON((ti->preempt_count & PREEMPT_MASK) >= PREEMPT_MASK-10);
++	BUG_ON((preempt_count() & PREEMPT_MASK) >= PREEMPT_MASK-10);
 +#endif
 +
-+	ti->preempt_count += val;
++	preempt_count() += val;
 +#ifdef CONFIG_PREEMPT_TRACE
 +	if (val <= 10) {
-+		unsigned int idx = ti->preempt_count & PREEMPT_MASK;
++		unsigned int idx = preempt_count() & PREEMPT_MASK;
 +		if (idx < MAX_PREEMPT_TRACE) {
 +			current->preempt_trace_eip[idx] = eip;
 +			current->preempt_trace_parent_eip[idx] = parent_eip;
@@ -3233,27 +3117,20 @@
 +#endif
 +	(void)eip, (void)parent_eip;
 +}
-+EXPORT_SYMBOL_GPL(add_preempt_count_ti);
-+
-+void notrace add_preempt_count(unsigned int val)
-+{
-+	add_preempt_count_ti(current_thread_info(), val);
-+}
++EXPORT_SYMBOL(add_preempt_count);
 +
-+EXPORT_SYMBOL_GPL(add_preempt_count);
-+
-+void notrace sub_preempt_count_ti(struct thread_info *ti, unsigned int val)
++void notrace sub_preempt_count(unsigned int val)
 +{
 +#ifdef CONFIG_DEBUG_PREEMPT
 +	/*
 +	 * Underflow?
 +	 */
-+	BUG_ON(unlikely(val > ti->preempt_count));
++	BUG_ON(unlikely(val > preempt_count()));
 +
 +	/*
 +	 * Is the spinlock portion underflowing?
 +	 */
-+	BUG_ON((val < PREEMPT_MASK) && !(ti->preempt_count & PREEMPT_MASK));
++	BUG_ON((val < PREEMPT_MASK) && !(preempt_count() & PREEMPT_MASK));
 +#endif
 +
 +#ifdef CONFIG_CRITICAL_PREEMPT_TIMING
@@ -3265,21 +3142,14 @@
 +
 +		if (!raw_irqs_disabled_flags(flags))
 +#endif
-+			if (ti->preempt_count == val)
++			if (preempt_count() == val)
 +				__stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
 +	}
 +#endif
-+	ti->preempt_count -= val;
-+}
-+
-+EXPORT_SYMBOL_GPL(sub_preempt_count_ti);
-+
-+void notrace sub_preempt_count(unsigned int val)
-+{
-+	sub_preempt_count_ti(current_thread_info(), val);
++	preempt_count() -= val;
 +}
 +
-+EXPORT_SYMBOL_GPL(sub_preempt_count);
++EXPORT_SYMBOL(sub_preempt_count);
 +
 +void notrace mask_preempt_count(unsigned int mask)
 +{
@@ -3303,7 +3173,7 @@
 +#endif
 +	(void) eip, (void) parent_eip;
 +}
-+EXPORT_SYMBOL_GPL(mask_preempt_count);
++EXPORT_SYMBOL(mask_preempt_count);
 +
 +void notrace unmask_preempt_count(unsigned int mask)
 +{
@@ -3322,7 +3192,7 @@
 +#endif
 +	preempt_count() &= ~mask;
 +}
-+EXPORT_SYMBOL_GPL(unmask_preempt_count);
++EXPORT_SYMBOL(unmask_preempt_count);
 +
 +
 +#endif
@@ -3430,7 +3300,7 @@
 +		return;
 +
 +	spin_lock(&sch.trace_lock);
-+	if (sch.task && (sch.task->prio >= p->prio))
++	if (sch.task && (sch.task->prio <= p->prio))
 +		goto out_unlock;
 +
 +	/*
@@ -3531,7 +3401,7 @@
 +	unsigned long flags;
 +	int cpu;
 +
-+	if (!trace_user_triggered || trace_print_at_crash)
++	if (!trace_user_triggered || trace_print_at_crash || print_functions)
 +		return -EINVAL;
 +
 +	/*
@@ -3583,8 +3453,7 @@
 +	struct cpu_trace *tr;
 +	cycles_t delta;
 +
-+
-+	if (!trace_user_triggered || trace_print_at_crash)
++	if (!trace_user_triggered || trace_print_at_crash || print_functions)
 +		return -EINVAL;
 +
 +	preempt_disable();
@@ -3663,7 +3532,7 @@
 +	return 0;
 +}
 +
-+EXPORT_SYMBOL_GPL(user_trace_stop);
++EXPORT_SYMBOL(user_trace_stop);
 +
 +void stop_trace(void)
 +{
@@ -3671,14 +3540,15 @@
 +		trace_enabled = -1;
 +}
 +
++EXPORT_SYMBOL(stop_trace);
++
 +static void print_entry(struct trace_entry *entry, struct trace_entry *entry0,
 +			struct trace_entry *next_entry)
 +{
-+	unsigned long abs_usecs, rel_usecs;
++	unsigned long abs_usecs;
 +	int hardirq, softirq;
 +
 +	abs_usecs = cycles_to_usecs(entry->timestamp - entry0->timestamp);
-+	rel_usecs = cycles_to_usecs(next_entry->timestamp - entry->timestamp);
 +
 +	printk("%-5d ", entry->pid);
 +
@@ -3820,6 +3690,9 @@
 +#if defined(CONFIG_PREEMPT_TRACE) || defined(CONFIG_LATENCY_TRACE)
 +void print_traces(struct task_struct *task)
 +{
++	if (!task)
++		task = current;
++
 +#ifdef CONFIG_PREEMPT_TRACE
 +	print_preempt_trace(task);
 +#endif
@@ -4172,9 +4045,9 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/kernel/sched.c
 +++ linux-latency-tracing.q/kernel/sched.c
-@@ -715,11 +715,18 @@ static inline void dec_nr_running(task_t
+@@ -661,11 +661,18 @@ static int effective_prio(task_t *p)
+ 	return prio;
  }
- #endif
  
 +static inline void trace_start_sched_wakeup(task_t *p, runqueue_t *rq)
 +{
@@ -4189,17 +4062,17 @@
  {
 +	trace_special_pid(p->pid, p->prio, rq->nr_running);
  	enqueue_task(p, rq->active);
- 	inc_nr_running(p, rq);
+ 	rq->nr_running++;
  }
-@@ -731,6 +738,7 @@ static inline void __activate_idle_task(
+@@ -677,6 +684,7 @@ static inline void __activate_idle_task(
  {
  	enqueue_task_head(p, rq->active);
- 	inc_nr_running(p, rq);
+ 	rq->nr_running++;
 +	WARN_ON(rt_task(p));
  }
  
  static int recalc_task_prio(task_t *p, unsigned long long now)
-@@ -1381,8 +1389,10 @@ out_activate:
+@@ -1297,8 +1305,10 @@ out_activate:
  	 * to be considered on this CPU.)
  	 */
  	if (!sync || cpu != this_cpu) {
@@ -4211,7 +4084,7 @@
  	}
  	success = 1;
  
-@@ -1396,15 +1406,19 @@ out:
+@@ -1312,15 +1322,19 @@ out:
  
  int fastcall wake_up_process(task_t *p)
  {
@@ -4233,15 +4106,15 @@
  }
  
  /*
-@@ -1512,6 +1526,7 @@ void fastcall wake_up_new_task(task_t *p
- 				inc_nr_running(p, rq);
+@@ -1428,6 +1442,7 @@ void fastcall wake_up_new_task(task_t *p
+ 				rq->nr_running++;
  			}
  			set_need_resched();
 +			trace_start_sched_wakeup(p, rq);
  		} else
  			/* Run child last */
  			__activate_task(p, rq);
-@@ -1633,6 +1648,7 @@ static inline void finish_task_switch(ru
+@@ -1549,6 +1564,7 @@ static inline void finish_task_switch(ru
  	prev_task_flags = prev->flags;
  	finish_arch_switch(prev);
  	finish_lock_switch(rq, prev);
@@ -4249,7 +4122,7 @@
  	if (mm)
  		mmdrop(mm);
  	if (unlikely(prev_task_flags & PF_DEAD))
-@@ -1679,6 +1695,8 @@ task_t * context_switch(runqueue_t *rq, 
+@@ -1595,6 +1611,8 @@ task_t * context_switch(runqueue_t *rq, 
  		rq->prev_mm = oldmm;
  	}
  
@@ -4258,13 +4131,7 @@
  	/* Here we just switch the register state and the stack. */
  	switch_to(prev, next, prev);
  
-@@ -2795,13 +2813,13 @@ static inline unsigned long smt_slice(ta
- 	return p->time_slice * (100 - sd->per_cpu_gain) / 100;
- }
- 
--static inline int dependent_sleeper(int this_cpu, runqueue_t *this_rq)
-+static int dependent_sleeper(int this_cpu, runqueue_t *this_rq)
- {
+@@ -2716,8 +2734,8 @@ static int dependent_sleeper(int this_cp
  	struct sched_domain *tmp, *sd = NULL;
  	cpumask_t sibling_map;
  	prio_array_t *array;
@@ -4275,7 +4142,7 @@
  
  	for_each_domain(this_cpu, tmp)
  		if (tmp->flags & SD_SHARE_CPUPOWER)
-@@ -2863,6 +2881,12 @@ static inline int dependent_sleeper(int 
+@@ -2779,6 +2797,12 @@ static int dependent_sleeper(int this_cp
  				!TASK_PREEMPTS_CURR(p, smt_rq) &&
  				smt_slice(smt_curr, sd) > task_timeslice(p))
  					ret = 1;
@@ -4288,7 +4155,7 @@
  
  check_smt_task:
  		if ((!smt_curr->mm && smt_curr != smt_rq->idle) ||
-@@ -2893,6 +2917,9 @@ check_smt_task:
+@@ -2809,6 +2833,9 @@ check_smt_task:
  out_unlock:
  	for_each_cpu_mask(i, sibling_map)
  		spin_unlock(&cpu_rq(i)->lock);
@@ -4298,12 +4165,12 @@
  	return ret;
  }
  #else
-@@ -2906,35 +2933,44 @@ static inline int dependent_sleeper(int 
+@@ -2822,35 +2849,44 @@ static inline int dependent_sleeper(int 
  }
  #endif
  
 -#if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
-+#if defined(CONFIG_LATENCY_TRACE) && defined(CONFIG_DEBUG_MUTEXES)
++#if defined(CONFIG_LATENCY_TRACE) && defined(CONFIG_DEBUG_RT_MUTEXES)
  
 -void fastcall add_preempt_count(int val)
 +static void trace_array(prio_array_t *array)
@@ -4366,15 +4233,15 @@
  
  #endif
  
-@@ -2958,6 +2994,7 @@ asmlinkage void __sched schedule(void)
- 	 * Otherwise, whine if we are scheduling when we should not be.
+@@ -2875,6 +2911,7 @@ asmlinkage void __sched schedule(void)
  	 */
  	if (likely(!current->exit_state)) {
-+		stop_trace();
  		if (unlikely(in_atomic())) {
++			stop_trace();
  			printk(KERN_ERR "scheduling while atomic: "
  				"%s/0x%08x/%d\n",
-@@ -3097,6 +3134,8 @@ switch_tasks:
+ 				current->comm, preempt_count(), current->pid);
+@@ -3013,6 +3050,8 @@ switch_tasks:
  		prev->sleep_avg = 0;
  	prev->timestamp = prev->last_ran = now;
  
@@ -4383,7 +4250,7 @@
  	sched_info_switch(prev, next);
  	if (likely(prev != next)) {
  		next->timestamp = now;
-@@ -3107,14 +3146,17 @@ switch_tasks:
+@@ -3023,14 +3062,17 @@ switch_tasks:
  		prepare_task_switch(rq, next);
  		prev = context_switch(rq, prev, next);
  		barrier();
@@ -4402,7 +4269,7 @@
  
  	prev = current;
  	if (unlikely(reacquire_kernel_lock(prev) < 0))
-@@ -5660,6 +5702,7 @@ void __might_sleep(char *file, int line)
+@@ -6075,6 +6117,7 @@ void __might_sleep(char *file, int line)
  		if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
  			return;
  		prev_jiffy = jiffies;
@@ -4414,15 +4281,15 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/kernel/sysctl.c
 +++ linux-latency-tracing.q/kernel/sysctl.c
-@@ -42,6 +42,7 @@
+@@ -44,6 +44,7 @@
  #include <linux/limits.h>
  #include <linux/dcache.h>
  #include <linux/syscalls.h>
 +#include <linux/profile.h>
+ #include <linux/nfs_fs.h>
+ #include <linux/acpi.h>
  
- #include <asm/uaccess.h>
- #include <asm/processor.h>
-@@ -278,6 +279,82 @@ static ctl_table kern_table[] = {
+@@ -283,6 +284,82 @@ static ctl_table kern_table[] = {
  		.mode		= 0644,
  		.proc_handler	= &proc_dointvec,
  	},
@@ -4509,7 +4376,7 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/kernel/time.c
 +++ linux-latency-tracing.q/kernel/time.c
-@@ -97,8 +97,23 @@ asmlinkage long sys_stime(time_t __user 
+@@ -98,8 +98,23 @@ asmlinkage long sys_stime(time_t __user 
  
  #endif /* __ARCH_WANT_SYS_TIME */
  
@@ -4533,7 +4400,7 @@
  	if (likely(tv != NULL)) {
  		struct timeval ktv;
  		do_gettimeofday(&ktv);
-@@ -184,6 +199,10 @@ asmlinkage long sys_settimeofday(struct 
+@@ -188,6 +203,10 @@ asmlinkage long sys_settimeofday(struct 
  	struct timespec	new_ts;
  	struct timezone new_tz;
  
@@ -4548,13 +4415,14 @@
 ===================================================================
 --- linux-latency-tracing.q.orig/lib/Kconfig.debug
 +++ linux-latency-tracing.q/lib/Kconfig.debug
-@@ -111,6 +111,146 @@ config DEBUG_SPINLOCK_SLEEP
+@@ -119,6 +119,149 @@ config DEBUG_SPINLOCK_SLEEP
  	  If you say Y here, various routines which may sleep will become very
  	  noisy if they are called with a spinlock held.
  
 +config WAKEUP_TIMING
 +	bool "Wakeup latency timing"
 +	default y
++	depends on !X86_32 || X86_GENERIC || X86_TSC
 +	help
 +	  This option measures the time spent from a highprio thread being
 +	  woken up to it getting scheduled on a CPU, with microsecond
@@ -4583,12 +4451,13 @@
 +config PREEMPT_TRACE
 +	bool
 +	default y
++	depends on !X86_32 || X86_GENERIC || X86_TSC
 +	depends on DEBUG_PREEMPT
 +
 +config CRITICAL_PREEMPT_TIMING
 +	bool "Non-preemptible critical section latency timing"
 +	default n
-+	depends on PREEMPT
++	depends on PREEMPT && (!X86_32 || X86_GENERIC || X86_TSC)
 +	help
 +	  This option measures the time spent in preempt-off critical
 +	  sections, with microsecond accuracy.
@@ -4622,6 +4491,7 @@
 +config CRITICAL_IRQSOFF_TIMING
 +	bool "Interrupts-off critical section latency timing"
 +	default n
++	depends on !X86_32 || X86_GENERIC || X86_TSC
 +	help
 +	  This option measures the time spent in irqs-off critical
 +	  sections, with microsecond accuracy.
@@ -4675,7 +4545,7 @@
 +config LATENCY_TRACE
 +	bool "Latency tracing"
 +	default n
-+	depends on LATENCY_TIMING
++	depends on LATENCY_TIMING && (!X86_32 || X86_GENERIC || X86_TSC)
 +	help
 +	  This option enables a kernel tracing mechanism that will track
 +	  precise function-call granularity kernel execution during
@@ -4695,7 +4565,7 @@
  config DEBUG_KOBJECT
  	bool "kobject debugging"
  	depends on DEBUG_KERNEL
-@@ -176,9 +316,9 @@ config DEBUG_VM
+@@ -185,9 +328,9 @@ config DEBUG_VM
  
  	  If unsure, say N.
  
@@ -4707,9 +4577,9 @@
  	default y if DEBUG_INFO && UML
  	help
  	  If you say Y here the resulting kernel image will be slightly larger
-@@ -186,6 +326,11 @@ config FRAME_POINTER
- 	  some architectures or if you use external debuggers.
- 	  If you don't debug the kernel, you can say N.
+@@ -209,6 +352,11 @@ config FORCED_INLINING
+ 	  become the default in the future, until then this option is there to
+ 	  test gcc for this.
  
 +config FRAME_POINTER
 +	bool
@@ -4719,72 +4589,220 @@
  config RCU_TORTURE_TEST
  	tristate "torture tests for RCU"
  	depends on DEBUG_KERNEL
- init/main.c |    9 +++++++++
- 1 files changed, 9 insertions(+)
-
-Index: linux-latency-tracing.q/init/main.c
-===================================================================
---- linux-latency-tracing.q.orig/init/main.c
-+++ linux-latency-tracing.q/init/main.c
-@@ -108,6 +108,8 @@ extern void tc_init(void);
- enum system_states system_state;
- EXPORT_SYMBOL(system_state);
+Index: linux-latency-tracing.q/lib/inflate.c
+===================================================================
+--- linux-latency-tracing.q.orig/lib/inflate.c
++++ linux-latency-tracing.q/lib/inflate.c
+@@ -141,6 +141,25 @@ struct huft {
+   } v;
+ };
  
-+extern cycles_t preempt_max_latency;
++/*
++ * turn off the inflate_lock for the bootloader code, it is
++ * single-threaded and has no need for (nor access to) the
++ * kernel's locking primitives:
++ */
++#ifdef ZLIB_INFLATE_NO_INFLATE_LOCK
++# undef DEFINE_SPINLOCK
++# undef spin_lock
++# undef spin_unlock
++# define DEFINE_SPINLOCK(x)	int x
++# define spin_lock(x)		(void)(x)
++# define spin_unlock(x)		(void)(x)
++#endif
 +
- /*
-  * Boot command-line arguments
++/*
++ * lock protecting static variables of huft_build() and other inflate
++ * functions, to reduce their insane stack footprint.
++ */
++static DEFINE_SPINLOCK(inflate_lock);
+ 
+ /* Function prototypes */
+ STATIC int INIT huft_build OF((unsigned *, unsigned, unsigned, 
+@@ -304,7 +323,7 @@ STATIC int INIT huft_build(
+   register struct huft *q;      /* points to current table */
+   struct huft r;                /* table entry for structure assignment */
+   struct huft *u[BMAX];         /* table stack */
+-  unsigned v[N_MAX];            /* values in order of bit length */
++  static unsigned v[N_MAX];     /* values in order of bit length */
+   register int w;               /* bits before this table == (l * h) */
+   unsigned x[BMAX+1];           /* bit offsets, then code stack */
+   unsigned *xp;                 /* pointer into x */
+@@ -705,7 +724,7 @@ STATIC int noinline INIT inflate_fixed(v
+   struct huft *td;      /* distance code table */
+   int bl;               /* lookup bits for tl */
+   int bd;               /* lookup bits for td */
+-  unsigned l[288];      /* length list for huft_build */
++  static unsigned l[288];      /* length list for huft_build */
+ 
+ DEBG("<fix");
+ 
+@@ -767,9 +786,9 @@ STATIC int noinline INIT inflate_dynamic
+   unsigned nl;          /* number of literal/length codes */
+   unsigned nd;          /* number of distance codes */
+ #ifdef PKZIP_BUG_WORKAROUND
+-  unsigned ll[288+32];  /* literal/length and distance code lengths */
++  static unsigned ll[288+32];  /* literal/length and distance code lengths */
+ #else
+-  unsigned ll[286+30];  /* literal/length and distance code lengths */
++  static unsigned ll[286+30];  /* literal/length and distance code lengths */
+ #endif
+   register ulg b;       /* bit buffer */
+   register unsigned k;  /* number of bits in bit buffer */
+@@ -940,6 +959,7 @@ STATIC int INIT inflate_block(
+   unsigned t;           /* block type */
+   register ulg b;       /* bit buffer */
+   register unsigned k;  /* number of bits in bit buffer */
++  unsigned ret;         /* return code */
+ 
+   DEBG("<blk");
+ 
+@@ -965,17 +985,19 @@ STATIC int INIT inflate_block(
+   bk = k;
+ 
+   /* inflate that block type */
+-  if (t == 2)
+-    return inflate_dynamic();
+-  if (t == 0)
+-    return inflate_stored();
+-  if (t == 1)
+-    return inflate_fixed();
++  ret = 2;
++  spin_lock(&inflate_lock);
++  switch (t) {
++	case 2: ret = inflate_dynamic(); break;
++	case 0: ret = inflate_stored();  break;
++	case 1: ret = inflate_fixed();   break;
++  }
++  spin_unlock(&inflate_lock);
+ 
+   DEBG(">");
+ 
+   /* bad block type */
+-  return 2;
++  return ret;
+ 
+  underrun:
+   return 4;			/* Input underrun */
+Index: linux-latency-tracing.q/lib/zlib_inflate/inftrees.c
+===================================================================
+--- linux-latency-tracing.q.orig/lib/zlib_inflate/inftrees.c
++++ linux-latency-tracing.q/lib/zlib_inflate/inftrees.c
+@@ -4,11 +4,19 @@
   */
-@@ -544,6 +546,13 @@ asmlinkage void __init start_kernel(void
  
- 	acpi_early_init(); /* before LAPIC and SMP init */
+ #include <linux/zutil.h>
++#include <linux/spinlock.h>
+ #include "inftrees.h"
+ #include "infutil.h"
  
-+#ifdef CONFIG_LATENCY_TIMING
-+	/*
-+	 * Start tracing now - the bootup traces arent too interesting:
-+	 */
-+	preempt_max_latency = 1000;
-+#endif
+ static const char inflate_copyright[] __attribute_used__ =
+    " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
 +
- 	/* Do the rest non-__init'ed, we're now alive */
- 	rest_init();
- }
- kernel/latency.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-Index: linux-latency-tracing.q/kernel/latency.c
-===================================================================
---- linux-latency-tracing.q.orig/kernel/latency.c
-+++ linux-latency-tracing.q/kernel/latency.c
-@@ -316,8 +316,8 @@ static void notrace printk_name(unsigned
- static unsigned long *worst_stack_bp;
- #endif
- static DEFINE_RAW_SPINLOCK(worst_stack_lock);
--unsigned long worst_stack_left = THREAD_SIZE;
--static unsigned long worst_stack_printed = THREAD_SIZE;
-+unsigned long worst_stack_left = THREAD_SIZE/2;
-+static unsigned long worst_stack_printed = THREAD_SIZE/2;
- static char worst_stack_comm[TASK_COMM_LEN+1];
- static int worst_stack_pid;
- static unsigned long worst_stack_sp;
---- linux-2.6.14/kernel/latency.c~	2005-12-29 21:03:11.000000000 -0500
-+++ linux-2.6.14/kernel/latency.c	2005-12-29 21:03:51.000000000 -0500
-@@ -24,6 +24,8 @@
- #include <asm/uaccess.h>
- #include <asm/unistd.h>
- #include <asm/rtc.h>
-+#include <asm/system.h>
-+#include <asm/unistd.h>
++/*
++ * lock protecting static variables of huft_build() and other inflate
++ * functions, to reduce their insane stack footprint.
++ */
++static DEFINE_SPINLOCK(inflate_lock);
++
+ /*
+   If you use the zlib library in a product, an acknowledgment is welcome
+   in the documentation of your product. If for some reason you cannot
+@@ -107,7 +115,7 @@ static int huft_build(
+ {
+ 
+   uInt a;                       /* counter for codes of length k */
+-  uInt c[BMAX+1];               /* bit length count table */
++  static uInt c[BMAX+1];        /* bit length count table */
+   uInt f;                       /* i repeats in table every f entries */
+   int g;                        /* maximum code length */
+   int h;                        /* table level */
+@@ -118,10 +126,10 @@ static int huft_build(
+   uInt mask;                    /* (1 << w) - 1, to avoid cc -O bug on HP */
+   register uInt *p;             /* pointer into c[], b[], or v[] */
+   inflate_huft *q;              /* points to current table */
+-  struct inflate_huft_s r;      /* table entry for structure assignment */
+-  inflate_huft *u[BMAX];        /* table stack */
++  static struct inflate_huft_s r; /* table entry for structure assignment */
++  static inflate_huft *u[BMAX]; /* table stack */
+   register int w;               /* bits before this table == (l * h) */
+-  uInt x[BMAX+1];               /* bit offsets, then code stack */
++  static uInt x[BMAX+1];        /* bit offsets, then code stack */
+   uInt *xp;                     /* pointer into x */
+   int y;                        /* number of dummy codes added */
+   uInt z;                       /* number of entries in current table */
+@@ -300,9 +308,13 @@ int zlib_inflate_trees_bits(
+   int r;
+   uInt hn = 0;          /* hufts used in space */
+   uInt *v;              /* work area for huft_build */
+-  
++
+   v = WS(z)->tree_work_area_1;
++
++  spin_lock(&inflate_lock);
+   r = huft_build(c, 19, 19, NULL, NULL, tb, bb, hp, &hn, v);
++  spin_unlock(&inflate_lock);
++
+   if (r == Z_DATA_ERROR)
+     z->msg = (char*)"oversubscribed dynamic bit lengths tree";
+   else if (r == Z_BUF_ERROR || *bb == 0)
+@@ -333,7 +345,10 @@ int zlib_inflate_trees_dynamic(
+   v = WS(z)->tree_work_area_2;
+ 
+   /* build literal/length tree */
++  spin_lock(&inflate_lock);
+   r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
++  spin_unlock(&inflate_lock);
++
+   if (r != Z_OK || *bl == 0)
+   {
+     if (r == Z_DATA_ERROR)
+@@ -347,7 +362,10 @@ int zlib_inflate_trees_dynamic(
+   }
+ 
+   /* build distance tree */
++  spin_lock(&inflate_lock);
+   r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
++  spin_unlock(&inflate_lock);
++
+   if (r != Z_OK || (*bd == 0 && nl > 257))
+   {
+     if (r == Z_DATA_ERROR)
+@@ -383,9 +401,11 @@ int zlib_inflate_trees_fixed(
+ 	z_streamp z              /* for memory allocation */
+ )
+ {
+-  int i;                /* temporary variable */
+-  unsigned l[288];      /* length list for huft_build */
+-  uInt *v;              /* work area for huft_build */
++  int i;                       /* temporary variable */
++  static unsigned l[288];      /* length list for huft_build */
++  uInt *v;                     /* work area for huft_build */
++
++  spin_lock(&inflate_lock);
+ 
+   /* set up literal table */
+   for (i = 0; i < 144; i++)
+@@ -398,15 +418,20 @@ int zlib_inflate_trees_fixed(
+     l[i] = 8;
+   *bl = 9;
+   v = WS(z)->tree_work_area_1;
+-  if ((i = huft_build(l, 288, 257, cplens, cplext, tl, bl, hp,  &i, v)) != 0)
++  if ((i = huft_build(l, 288, 257, cplens, cplext, tl, bl, hp,  &i, v)) != 0) {
++    spin_unlock(&inflate_lock);
+     return i;
++  }
  
- #ifndef CONFIG_PREEMPT_RT
- # define DEFINE_RAW_SPINLOCK		DEFINE_SPINLOCK
---- linux-2.6.14/include/asm-x86_64/unistd.h~	2005-12-29 21:12:32.000000000 -0500
-+++ linux-2.6.14/include/asm-x86_64/unistd.h	2005-12-29 21:13:05.000000000 -0500
-@@ -581,6 +581,7 @@ __SYSCALL(__NR_inotify_add_watch, sys_in
- __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
- 
- #define __NR_syscall_max __NR_inotify_rm_watch
-+#define NR_syscalls 256
- #ifndef __NO_STUBS
+   /* set up distance table */
+   for (i = 0; i < 30; i++)      /* make an incomplete code set */
+     l[i] = 5;
+   *bd = 5;
+-  if ((i = huft_build(l, 30, 0, cpdist, cpdext, td, bd, hp, &i, v)) > 1)
++  if ((i = huft_build(l, 30, 0, cpdist, cpdext, td, bd, hp, &i, v)) > 1) {
++    spin_unlock(&inflate_lock);
+     return i;
++  }
  
- /* user-visible error numbers are in the range -1 - -4095 */
++  spin_unlock(&inflate_lock);
+   return Z_OK;
+ }




More information about the fedora-cvs-commits mailing list