For problems or questions, please e-mail lkst-develop@lists.sourceforge.net
For bugs, please submit a bug via the project page:

http://sourceforge.net/projects/lkst/


Prerequisites
=============

1. Linux Kernel State Tracer software:
   lkst-2.2.tar.gz can be downloaded from the project page.

2. Linux kernel version 2.6.9
   linux-2.6.9.tar.bz2 can be downloaded from
     ftp://ftp.kernel.org/pub/linux/kernel/v2.6/

!ATTENTION!
   For kernel modules of Linux 2.6, you need new module-init-tools.
   The latest version of module-init-tools can be downloaded from
     ftp://ftp.kernel.org/pub/linux/utils/kernel/module-init-tools/


Installation
============

0) Prepare archives
------------------------------------------------------------
1. cd $(SOMEWHERE_LKST)

2. Untar the LKST archive
    tar -xzf  lkst-2.2.tar.gz

3. cd $(SOMEWHERE_KERNEL)

4. Untar Linux kernel source
    tar -xjf  linux-2.6.9.tar.bz2

1) Build and Install Kernel patch for kernel versions 2.6.9
-----------------------------------------------------------------
1. Login as root

2. Issue a command to apply a series of patches to the kernel source.
     cd $(SOMEWHERE_LKST)/lkst-2.2/
     make patch KPRESRC=$(SOMEWHERE_KERNEL)/linux-2.6.9
     or
     ./scripts/enpatch.sh $(SOMEWHERE_KERNEL)/linux-2.6.9
     
     After that, answer following questions.

     Apply preassigned page table patch (if not, apply vmsync patch automatically) (Y)es/(N)o? [Y]
     Apply early boot-time tracing patch(optional) (Y)es/(N)o? [Y]
     Apply extra event set patch(optional) (Y)es/(N)o? [Y]
     Apply ignore hooks placed in inline-functions patch(optional) (Y)es/(N)o? [Y]

     If you'd like fullset of LKST, answer "y" for all questions.

     (*) The order of patches and details are described in Appendix A.

3. Build kernel
    a. Kernel Configuration
       cd $(SOMEWHERE_KERNEL)/linux-2.6.9
       make menuconfig

    b. (i386 only) Under "Processor type and features"
      i. Select "64GB" for "High Memory Support"
      or
      i. Select "y" for "Assign page tables for non-contiguous mapped area on boot"
     ii. Select "n" for "Use register arguments"
    c. Under "Kernel hacking", select the following:
      i. Select "y" for "Kernel debugging".
     ii. Select "y" for "Kernel Hook Support".
    iii. Select "y" for "Magic SysRq key". (optional)
     iv. Select "m" for "Kernel State Tracing (LKST)".
      v. Configure other kernel config settings as needed.
    d. Save and Exit
    e. make modules bzImage

4. Install kernel modules and the kernel
   make modules_install
   make install

5. If you use lilo, run /sbin/lilo to read modified lilo.conf
   or If you use the Fedora Core or the Red Hat distributions,  you may fix
   grub.conf to give the new kernel a root partition as a device file path
   (ex. /dev/hda1 ) instead of a label format (ex. "LABEL=/") .

6. reboot


!ATTENTION!
You must build 2)-4) after the kernel was built.

2) Prepare to install tools
---------------------------

1. Log in as root

2. cd $(SOMEWHERE_LKST)/lkst-2.2/

3. make config
   (Or, if you have to specify kernel-source directory, do as following
    make config KSRC=$(SOMEWHERE_KERNEL)/linux-2.6.9 )

!EXPERIMENTAL!
   If you'd like to use LKST with LKCD, Specify lkcdutils' source directory as
   following.
    make config LKCDDIR=$(SOMEWHERE_LKCDUTILS)/lkcdutils

3.a) Install the userspace tools
--------------------------------

1. Log in as root

2. cd $(SOMEWHERE_LKST)/lkst-2.2/lkstutils

3. Build userspace tools

   a. make
   b. make install


3.b) Or, install the userspace tools from the rpm package
---------------------------------------------------------

1. Download lkstutils-2.2-1.i386.rpm from the project page.

2. Log in as root

3. Issue the following command:

   rpm -Uvh lkstutils-2.2-1.i386.rpm



4) Install addon tools [Optional]
---------------------------------

1. Log in as root

2. cd $(SOMEWHERE_LKST)/lkst-2.2/lkstaddons

3. Build and install

   a. make
   b. make install


Configure your system
======================

5) Load lkst module
-------------------
To load lkst module, issue following command:

       modprobe lkst

6) Kernel parameter
-------------------
The following kernel parameter can be passed:

      lkst_maxvm=

Use integer value for LKST available memory size.
Users can limit the amount of memory size for LKST.

If LKST is embedded in kernel, you can pass following parameter:

      lkst_init_maskset=

Use integer value for maskset id. You can choose between 0, 1, or 2.
Default value is 2. If you choose any value except values described above,
the value is set as default value.


7) Module parameter
---------------------
The following module parameter can be passed:

      lkst_init_buffer_size=

Use integer value for logging buffer size(in byte). You can use the value
larger than 8192. Default value is 65536. If amount of buffer size is larger
than LKST available memory described above, the size is set as default value.

     example: modprobe lkst lkst_init_buffer_size=1048576

NOTE!!!
If you specify a value, kernel memory will be used by the value.
So you may avoid specifying large value.

Also you can pass following module parameter:

      lkst_init_maskset=

This parameter is the same meaning as kernel parameter's one.
This available if you make LKST as module.

     example: modprobe lkst lkst_init_maskset=0

If you want to configure lkst module, you will need to add the following lines
to /etc/modprobe.conf:

       alias lkst lkst
       options lkst lkst_init_buffer_size=65536


--------------------------------------------------------------------------
Appendix A

Details of patching the kernel manually
---------------------------------------
1.a. Issue command to patch kernel for preassigned-pagetable
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/preassign-2.6.9.patch

1.b. (OPTIONAL) Or if you would like to use vmsync(*) instead of
     preassigned-pagetable, do following.
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/vmsync-2.6.9.patch

     (*) vmsync() is an API to synchronize the pagetable entries of a region
     of non-contiguous memory area between all processes. It avoids page-fault
     exception on that region. If you choose 1.b., you must do 8.b.
     If unsure, do step 1.a.

2. Issue command to patch kernel for KernelHooks (as following order)
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/kernelhooks-v1.8-269-base.patch
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/kernelhooks-v1.8-fix_kconfig.patch
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/kernelhooks-v1.8-fix_kmakefile.patch
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/kernelhooks-v1.8-resolve_dependency.patch
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/kernelhooks-v1.8-support_ia64.patch
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/kernelhooks-v1.8-support_x86_64.patch

3. Issue command to patch kernel for LKST core patch
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/lkst-core.patch

4. Issue command to patch kernel for LKST standerd event-set patch
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/lkst-events-std.patch

5. (OPTIONAL) Issue command to patch kernel for LKST early boot-time 
   tracing patch
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/lkst-earlylog.patch

6. (OPTIONAL) Issue command to patch kernel for LKST extra event set patch
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/lkst-events-ext.patch

7. (OPTIONAL) Issue command to patch kernel for LKST ignore hooks placed in
   inline-functions patch
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/lkst-ign-inline.patch

8.b. (OPTIONAL) If you choose using vmsync, you should patch an additional
     patch after step 3.
     cd $(SOMEWHERE_KERNEL)/linux-2.6.9
     patch -p 1 < $(SOMEWHERE_LKST)/lkst-2.2/patches/lkst_use_vmsync.patch



==============================================================
COPYRIGHT (C) HITACHI,LTD. 2001-2004
COPYRIGHT (C) FUJITSU,LTD. 2001-2004
==============================================================
