diff -Naru linux-lkst-std/drivers/lkst/lkst_core.c linux-lkst-earlylog/drivers/lkst/lkst_core.c
--- linux-lkst-std/drivers/lkst/lkst_core.c	2004-11-19 20:41:39.718226160 +0900
+++ linux-lkst-earlylog/drivers/lkst/lkst_core.c	2004-11-19 20:41:45.417359760 +0900
@@ -1506,12 +1506,19 @@
 #endif /*defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)*/
 
 /*
- * function lkst_trc_init_main
- * Initialize basic part of Kernel State Tracer.
+ * function lkst_trc_init_stage0
+ * Initialize the first part of Kernel State Tracer.
+ * This function initializes data not concerned with SMP.
+ * 
+ *  Arguments
+ *    NONE
+ *  returns
+ *    NONE
+ * 
  */
-int __init lkst_trc_init_main()
+void lkst_trc_init_stage0()
 {
-	int i, ret;
+	int i;
 
 	if ( lkst_init_flag != LKST_NOT_INIT) LKST_ENCOUNTER_A_BUG; 
 
@@ -1520,7 +1527,7 @@
 	 *   maskset_rnothing[], maskset_rall[], maskset_rdefault[]
 	 */
 
-	LKST_DPRINTK("Starting initialization\n");
+	LKST_DPRINTK("Starting initialization stage0\n");
 	/* initialize global header */{
 
 		/* Initialize LKST header time stamp */
@@ -1553,13 +1560,6 @@
 			LKST_STATIC_BUFFER_BODY()[i].log_event_type = 
 				LKST_ETYPE_VOID;
 		}
-
-		/* Set architecture name */
-		strncpy(lkst.arch, system_utsname.machine, 65); 
-
-		/* Set cpu frequency */
-		lkst.cpu_freq = lkst_get_cpu_khz();
-		lkst_time_set(0);
 	}
 	
 	/* initialize percpu header */
@@ -1573,16 +1573,8 @@
 		lkst_cpu[i].write_buf = LKST_BUFFER_ID_VOID;
 	}
 
-#ifdef CONFIG_SMP
-	/* register notifier for cpu-hotplug */
-	register_cpu_notifier(&cpu_hotplug_nb);
-#endif
-	/* allocate event buffer for all CPUs */
-	for_each_cpu(i) {
-		lkst_trc_init_percpu(i);
-	}
-
 	/* registering masksets & evhandlers */{
+		lkst_maskset *ms;
 		spin_lock(&lkst_evhandler_lock);
 		spin_lock(&lkst_maskset_lock);
 		
@@ -1626,29 +1618,118 @@
 		for (i = 3; i < LKST_MASKSET_TBL_MAX; i++) {
 			lkst.maskset_table[i].masksetp = NULL;
 		}
+		/* Temporarily modify MASKSET_RALL to a maskset log to static buffer*/
+		LKST_MASKSET_TABLE_LOAD(lkst_init_maskset, ms);
+		for (i = 0; i < LKST_ETYPE_MAX; i++) {
+			if (LKST_MASKSET_QUERY_EVHANDLER_ID(ms, i) != LKST_EVHANDLER_ID_VOID)
+				maskset_rall[i] = LKST_EVHANDLER_ID_LOG_STATIC;
+			else
+				maskset_rall[i] = LKST_EVHANDLER_ID_VOID;
+		}
 
 		/* Kernelhooks initialization will invoked automatically now. */
 		/* Initialize hook table used by lkst */
 		lkst_hook_init();
 
-		/* Set specified maskset */
-		lkst_hook_maskset_xchg(lkst_init_maskset, 
-				       LKST_MASKSET_ID_RNOTHING);
-		LKST_MASKSET_SET_CURRENT(lkst_init_maskset);
+		/* Setup current maskset pointer (stage0 special maskset)*/
+		lkst_hook_maskset_xchg(LKST_MASKSET_ID_RALL,
+				       lkst.current_maskset_id);
+		LKST_MASKSET_SET_CURRENT(LKST_MASKSET_ID_RALL);
 
 		spin_unlock(&lkst_maskset_lock);
 		spin_unlock(&lkst_evhandler_lock);
 	}
+	LKST_DPRINTK("Initialized masksets and evhandlers\n");
+
+	LKST_HOOK_INLINE(LKST_ETYPE_LKST_INIT, LKST_ARG(0x0001),
+			 LKST_ARG(0), LKST_ARG(0), LKST_ARG(0));
 
 	/* register Dump notifier (if available)*/
 #if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)
 	register_dump_notifier(&dump_nb);
 #endif /*defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)*/
-	
-	LKST_DPRINTK("Initialized masksets and evhandlers\n");
-	LKST_HOOK_INLINE(LKST_ETYPE_LKST_INIT, LKST_ARG(0x0001), 
+
+	/* LKST initialize flag on */
+	lkst_init_flag = LKST_INIT_LEVEL_0;
+	LKST_HOOK_INLINE(LKST_ETYPE_LKST_INIT, LKST_ARG(0x00ff),
+			 LKST_ARG(0), LKST_ARG(0), LKST_ARG(0));
+	LKST_DPRINTK("Initialization stage0 finished\n");
+}
+
+/*
+ * function lkst_trc_init_stage1
+ * Initialize the second part of Kernel State Tracer.
+ * This function initializes buffers, pointers and
+ * data concernd with SMP. Therefore, this should be
+ * called after all of the CPUs are initialized.
+ * 
+ *  Arguments
+ *    NONE
+ *  returns
+ *    NONE
+ * 
+ */
+int lkst_trc_init_stage1()
+{
+	int i, ret;
+
+	if ( lkst_init_flag != LKST_INIT_LEVEL_0) {
+		LKST_DPRINTK("LKST is not initialized yet!\n");
+		return -1;
+	}
+
+	/* LKST internal event */
+	LKST_HOOK_INLINE(LKST_ETYPE_LKST_INIT, LKST_ARG(0x0101),
 			 LKST_ARG(0), LKST_ARG(0), LKST_ARG(0));
 
+	LKST_DPRINTK( "Starting initialization stage1\n");
+
+	/* Set architecture name */
+	strncpy(lkst.arch, system_utsname.machine, 65); 
+
+	/* Set cpu frequency */
+	lkst.cpu_freq = lkst_get_cpu_khz();
+	lkst_time_set(0);
+
+	/* allocate event buffer for all CPUs */
+	for_each_cpu(i) {
+		lkst_trc_init_percpu(i);
+	}
+	
+#ifdef CONFIG_SMP
+	/* register notifier for cpu-hotplug */
+	register_cpu_notifier(&cpu_hotplug_nb);
+#endif
+	/* get locks */ {
+		spin_lock(&lkst_evhandler_lock);
+		spin_lock(&lkst_maskset_lock);
+
+		/* Switch to default maskset from log-static-buffer maskset */
+		if (lkst_init_maskset != lkst.current_maskset_id) {
+			/* Reset current maskset pointer */
+			lkst_hook_maskset_xchg((lkst_maskset_id)lkst_init_maskset,
+					       lkst.current_maskset_id);
+			LKST_MASKSET_SET_CURRENT((lkst_maskset_id)lkst_init_maskset);
+		}
+
+		/* Recovery MASKSET_RALL */
+		for (i = 0; i < LKST_ETYPE_MAX; i++) {
+			maskset_rall[i] = LKST_EVHANDLER_ID_DEFAULT;
+		}
+		maskset_rall[LKST_ETYPE_LKST_BUFF_OVFLOW] = LKST_EVHANDLER_ID_BUFFER_SHIFT;
+		
+		if (lkst_init_maskset == lkst.current_maskset_id) {
+			/* reset all entries of current maskset */
+			while ( lkst_hook_maskset_xchg(LKST_MASKSET_ID_RNOTHING, 
+						       LKST_MASKSET_ID_RALL) == -EBUSY);
+			lkst_hook_maskset_xchg(lkst.current_maskset_id, 
+					       LKST_MASKSET_ID_RNOTHING);
+		}
+		
+		/*release locks*/
+		spin_unlock(&lkst_maskset_lock);
+		spin_unlock(&lkst_evhandler_lock);
+	}
 	/* lkst device */
 	if ( (ret = lkst_device_init()) ) {
 		LKST_DPRINTK("failed to initialize lkst device(%d)\n",ret);
@@ -1672,15 +1753,31 @@
 	/* LKST initialize flag on */
 	lkst_init_flag = LKST_INIT_LEVEL_1;
 
-	LKST_DPRINTK("Initialization finished\n");
+	LKST_DPRINTK("Initialization stage1 finished\n");
 
 	/* LKST internal event */
-	LKST_HOOK_INLINE(LKST_ETYPE_LKST_INIT, LKST_ARG(0x10ff), 
+	LKST_HOOK_INLINE(LKST_ETYPE_LKST_INIT, LKST_ARG(0x10ff),
 			 LKST_ARG(0), LKST_ARG(0), LKST_ARG(0));
 
 	return 0;
 }
 
+
+/*
+ * function lkst_trc_init_main
+ * Initialize basic part of Kernel State Tracer.
+ * This function is called from /init/main.c. and lkst_init_module
+ */
+int lkst_trc_init_main()
+{
+	int ret=0;
+#ifndef	CONFIG_DEBUG_KERNEL_STATE_TRACE_IN_START
+	lkst_trc_init_stage0();
+#endif /* !CONFIG_DEBUG_KERNEL_STATE_TRACE_IN_START */
+	ret = lkst_trc_init_stage1();
+	return ret;
+}
+
 #ifdef MODULE
 static int __init lkst_init_module(void)
 {
diff -Naru linux-lkst-std/drivers/lkst/Kconfig linux-lkst-earlylog/drivers/lkst/Kconfig
--- linux-lkst-std/drivers/lkst/Kconfig	2004-11-19 20:41:39.719226008 +0900
+++ linux-lkst-earlylog/drivers/lkst/Kconfig	2004-11-19 20:41:45.417359760 +0900
@@ -27,6 +27,14 @@
 	  spinlock event.
 	  If unsure, say Y.
 
+config DEBUG_KERNEL_STATE_TRACE_IN_START
+       bool "Tracing event at early boot time."
+       depends on DEBUG_KERNEL_STATE_TRACE=y
+       help
+       	 LKST records events at early boot time. These events are recorded
+	 into the static buffer.
+	 If unsure, say N.
+
 config DEBUG_LKST_DONOT_EXPAND_ARGBITS
 	bool "Do NOT expand bitwidth of arguments to 64bits"
 	depends on DEBUG_KERNEL_STATE_TRACE && X86 && !64BIT
diff -Naru linux-lkst-std/init/main.c linux-lkst-earlylog/init/main.c
--- linux-lkst-std/init/main.c	2004-10-21 21:33:01.000000000 +0900
+++ linux-lkst-earlylog/init/main.c	2004-11-19 20:41:45.415360064 +0900
@@ -50,6 +50,8 @@
 #include <asm/bugs.h>
 #include <asm/setup.h>
 
+#include <linux/lkst.h>
+
 /*
  * This is one of the first .c files built. Error out early
  * if we have compiler trouble..
@@ -485,6 +487,9 @@
  * enable them
  */
 	lock_kernel();
+#if (defined(CONFIG_DEBUG_KERNEL_STATE_TRACE)&&defined(CONFIG_DEBUG_KERNEL_STATE_TRACE_IN_START))
+	lkst_trc_init_stage0();
+#endif /* if (defined(CONFIG_DEBUG_KERNEL_STATE_TRACE)&&defined(CONFIG_DEBUG_KERNEL_STATE_TRACE_IN_START)) */
 	page_address_init();
 	printk(linux_banner);
 	setup_arch(&command_line);
