2015年6月8日 星期一

[HOW TO]: use debugfs functions in kernel module

use module [mmc_block_test] for example

because the mmc_block_test already use debugfs, you will see debugfs_create_dir and debugfs_create_file in the soucrec code. When the module be installed or be triggered, the debugfs will create a directory(default in /sys/kernel/debug/) for it.

By using debugfs, we wouldn't need to write a user application program for testing module functions.

Actual Operation on DragonBoard
Step1. See current io-scheduler
#cat /sys/block/mmcblk0/queue/schduler
Step2. Switch io-scheduler and the relative functions will be mounted in debugfs
#echo test-iosched > /sys/block/mmcblk0/queue/schduler
Step3. Move to functions folder, in there we will see /tests/ and /utils/
#cd /sys/kernel/debug/test-iosched/

Step4. Linux use echo command to trigger .write, and using cat command to trigger .read in terminal
for example,
#echo 4 > write_packing_control_test will do 4 cycle of write_packing_control_test_write
#cat write_packing_control_test will show what write_packing_control_test_write will do





ref: Documentation/filesystems/debugfs.txt