Archive for the ‘Kernel’ Category

15
Oct

Human Readable Kernel Oops Messages

You can configure the kernel with the “CONFIG_KALLSYMS” option for more useful output when a kernel oops is encountered. The description is “Load all symbols for debugging/ksymoops”. You can find more information about the option here: http://cateee.net/lkddb/web-lkddb/KALLSYMS.html. Below, you’ll find “before and after” results:

Before

[    1.120000] Backtrace: 
[    1.120000] Function entered at [<c0026a68>] from [<c0026b60>]
[    1.120000] Function entered at [<c0026afc>] from [<c00afdcc>]
[    1.120000]  r6:00000004 r5:00000004 r4:00000000
[    1.120000] Function entered at [<c00af964>] from [<c00b0110>]
[    1.120000] Function entered at [<c00b0058>] from [<c00de8f0>]
[    1.120000] Function entered at [<c00de8d0>] from [<c006ad9c>]
[    1.120000] Function entered at [<c006ac5c>] from [<c006ae7c>]
[    1.120000] Function entered at [<c006ae4c>] from [<c0064de0>]
[    1.120000] Function entered at [<c0064c1c>] from [<c00755e4>]
[    1.120000] Function entered at [<c0075590>] from [<c0076fa4>]
[    1.120000] Function entered at [<c0076d4c>] from [<c002617c>]
[    1.120000] Function entered at [<c00260a4>] from [<c002028c>]
[    1.120000] Function entered at [<c002024c>] from [<c0020d44>]

After

[    1.110000] Backtrace: 
[    1.110000] [<c0026a80>] (__flush_dcache_page+0x0/0x34) from [<c0026bc0>] (flush_dcache_page+0x64/0x138)
[    1.110000] [<c0026b5c>] (flush_dcache_page+0x0/0x138) from [<c00b17a8>] (do_mpage_readpage+0x468/0x684)
[    1.110000]  r6:00000004 r5:00000004 r4:00000000
[    1.110000] [<c00b1340>] (do_mpage_readpage+0x0/0x684) from [<c00b1aec>] (mpage_readpages+0xb8/0x10c)
[    1.110000] [<c00b1a34>] (mpage_readpages+0x0/0x10c) from [<c00e035c>] (ext2_readpages+0x20/0x28)
[    1.110000] [<c00e033c>] (ext2_readpages+0x0/0x28) from [<c006c734>] (__do_page_cache_readahead+0x140/0x1f0)
[    1.110000] [<c006c5f4>] (__do_page_cache_readahead+0x0/0x1f0) from [<c006c814>] (ra_submit+0x30/0x34)
[    1.110000] [<c006c7e4>] (ra_submit+0x0/0x34) from [<c0066778>] (filemap_fault+0x1c4/0x3a4)
[    1.110000] [<c00665b4>] (filemap_fault+0x0/0x3a4) from [<c0076f7c>] (__do_fault+0x54/0x3d0)
[    1.110000] [<c0076f28>] (__do_fault+0x0/0x3d0) from [<c0078978>] (handle_mm_fault+0x258/0x364)
[    1.110000] [<c0078720>] (handle_mm_fault+0x0/0x364) from [<c00261dc>] (do_page_fault+0xd8/0x1c0)
[    1.110000] [<c0026104>] (do_page_fault+0x0/0x1c0) from [<c002028c>] (do_DataAbort+0x40/0xa4)
[    1.110000] [<c002024c>] (do_DataAbort+0x0/0xa4) from [<c0020d44>] (ret_from_exception+0x0/0x10)
15
Jul

View Configuration File Used to Build Currently Running Kernel

If enabled as an option in the pre-compiled kernel configuration, the file /proc/config.gz can inform you of what options your currently running kernel was compiled with. The writers over at Linux Insight have gone into a bit more detail about doing this. You can read up on it here:
http://www.linuxinsight.com/proc_config.gz.html

28
Apr

Command to Reduce File Size of Installed Kernel Modules

I mentioned the objcopy command earlier, but I had recently put it into effect myself by shaving off quite a bit of bulk from Linux kernel modules targeted towards an embedded system and I wanted to share my steps and commands with you.

  1. Step 1: Compile your kernel and install the modules
  2. make; make modules_install
  3. Step 2: Change to the directory in which you installed your kernel modules
  4. cd /lib/modules/2.6.24.4/kernel/drivers
  5. Step 3: Run the following command which will find all files ending in .ko and pipe it to run the objcopy command (note, the following shows an example of using cross compile tools targeted towards ARM)
  6. find . -type f -name '*.ko' | xargs -n 1 /myfiles/tscrosstool/crosstool-linux-arm-uclibc-3.4.6/arm-uclibc-3.4.6/bin/arm-linux-objcopy --strip-unneeded
    

That’s it. You’ll notice that your kernel module sizes are now very small compared to what they used to be, and this allows you to squeeze in more features in your embedded system and possibly leave even more free space for your programs or files.

6
Apr

Sharing a Variable Between Two Sources in Linux Kernel

Sharing a variable between two sources in the kernel tree is done pretty simply with the EXPORT_SYMBOL function. For example, to share the variable mac_address of source1.c with source2.c you would use the following.

source1.c

unsigned char mac_address[6];
EXPORT_SYMBOL(mac_address);

source2.c

extern unsigned char mac_address[6];