we can use intel processor trace facility since cpu power on so we can try this patch to do early code analysis at basic block level.
The basic usage is as below: #./sptdump #./sptdecode --pt ptout.0 -e ../linux-test/vmlinux | less .... [+ 10] ext4_getblk+159 -> __getblk_gfp [+ 13] __getblk_gfp+30 -> __find_get_block [+ 112] __find_get_block+167 -> mark_page_accessed [+ 2] __getblk_gfp+38 -> _cond_resched [+ 7] _cond_resched+16 -> rcu_all_qs [+ 35] htree_dirblock_to_tree+324 -> __ext4_check_dir_entry [+ 8] htree_dirblock_to_tree+352 -> ext4fs_dirhash [+ 53] ext4fs_dirhash+196 -> str2hashbuf_signed [+ 18] htree_dirblock_to_tree+233 -> ext4_htree_store_dirent [+ 18] ext4_htree_store_dirent+52 -> __kmalloc [+ 10] __kmalloc+27 -> kmalloc_slab [+ 9] __kmalloc+248 -> _cond_resched [+ 7] _cond_resched+16 -> rcu_all_qs [+ 39] __kmalloc+303 -> __memset [+ 4] __kmalloc+231 -> memcg_kmem_put_cache [+ 17] ext4_htree_store_dirent+114 -> __memcpy [+ 14] ext4_htree_store_dirent+214 -> rb_insert_color [+ 26] htree_dirblock_to_tree+324 -> __ext4_check_dir_entry [+ 8] htree_dirblock_to_tree+352 -> ext4fs_dirhash [+ 53] ext4fs_dirhash+196 -> str2hashbuf_signed [+ 18] htree_dirblock_to_tree+233 -> ext4_htree_store_dirent [+ 18] ext4_htree_store_dirent+52 -> __kmalloc [+ 10] __kmalloc+27 -> kmalloc_slab [+ 9] __kmalloc+248 -> _cond_resched .... The patch borrows some idea/code and tools from Andi Kleen's simple-pt project. Luming Yu(9): Basic support for early intel processor trace features with zero deps boot option early_pt to enable early pt boot option early_pt_buf_len for early pt buffer size setup early pt basic addr pair filter support (addr0 && addr1) early pt basic addr pair filter support (addr0 && addr1) early pt enable mtc freq packet enable early pt psb packet early pt enable cyc packet start early intel processor trace in early boot arch/x86/events/Kconfig | 6 + arch/x86/events/intel/Makefile | 1 + arch/x86/events/intel/early_pt.c | 443 +++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/smpboot.c | 2 + init/main.c | 2 + kernel/trace/Kconfig | 2 +- 6 files changed, 455 insertions(+), 1 deletion(-) create mode 100644 arch/x86/events/intel/early_pt.c -- 2.7.5