Page History
...
- Build a Lustre patched kernel with ggov enabled. This document assumes a Lustre patched kernel version: 2.6.32-279.19.1.el6_lustre_gcov.x86_64.
To enable gcov set
CONFIG_GCOV_KERNEL=y
. It is not necessary to setCONFIG_GCOV_PROFILE_ALL
. With the first option set, profiling can be enable on a per-module basis during the Lustre build.Build the kernel as usual (i.e. using GCC). Trying to build it with Clang is unlikely to succeed.
- Build SPL and ZFS if necessary.
Build Lustre software using a script included in lustre-static-analysis for assistance:
Code Block language none # cd lustre-release # git clean -fxd # sh autogen.sh && ./configure # ~/lustre-static-analysis/DeclUse/decl_use_make GCOV_PROFILE=y
For each
.c
to.o
compilation performed by GCC,decl_use_make
will also run Clang with the lustre-static-analysis plugin. When compilingfile.c
the outputfile.o
is produced by GCC and should be identical to a normal Lustre build. Simultaneouslydecl_use_make
instructs Clang to read file.c and produce correspondingfile.o._Ref
andfile.o._Err
. Note: Clang does not compile file.c to an object file. Clang parses file.c and produces an AST in memory. Thefile.o._Err
file records the errors Clang discovered during processingfile.c
.Info In practice,
file.o
is first build as.tmp_file.o
then renamed tofile.o
. This happens in the Makefile so GCC and Clang are unaware of thefile.o
.
...
Useful products from Clang static analysis
For the purposes of static analysis provided by the Clang plugin, the file.o._Ref
are intermediate file is and not of primary general interest. For example:
Code Block |
---|
# find lustre/llite -name '*._Ref'
./lustre/llite/.tmp_rw.o._Ref
./lustre/llite/.tmp_dir.o._Ref
./lustre/llite/.tmp_vvp_lock.o._Ref
./lustre/llite/.tmp_remote_perm.o._Ref
...
#
# ls -lh ./lustre/llite/.tmp_file.o._Ref
-rw-r--r-- 1 root root 7.9M May 16 10:47 ./lustre/llite/.tmp_file.o._Ref
# grep ll_file_read ./lustre/llite/.tmp_file.o._Ref
Decl Function lustre/llite/file.c:1062:16:ll_file_read lustre/llite/file.c:1062:16
Def Function lustre/llite/file.c:1062:16:ll_file_read lustre/llite/file.c:1062:16
Use Function lustre/llite/file.c:1062:16:ll_file_read lustre/llite/file.c:3026:27
Use Function lustre/llite/file.c:1062:16:ll_file_read lustre/llite/file.c:3046:27
Use Function lustre/llite/file.c:1062:16:ll_file_read lustre/llite/file.c:3069:27
#
# grep lu_fid ./lustre/llite/.tmp_file.o._Ref
Decl Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:118:8
Def Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:118:8
Decl Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_user.h:125:8
Decl Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_oid lustre/include/lustre/lustre_user.h:127:8
Decl Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_ver lustre/include/lustre/lustre_user.h:133:8
Use Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:137:16
Use Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:142:16
Use Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:170:17
Use Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:189:17
Use Record lustre/include/lustre/lustre_user.h:118:8:lu_fid lustre/include/lustre/lustre_user.h:379:16
#
# grep lu_fid:f_seq ./lustre/llite/.tmp_file.o._Ref
Decl Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_user.h:125:8
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:395:21
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:548:7
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:650:14
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:747:8
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:771:6
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:772:3
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:820:7
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:835:7
Use Field lustre/include/lustre/lustre_user.h:118:8:lu_fid:f_seq lustre/include/lustre/lustre_idl.h:846:7
#
|
In each ._Ref
files, the columns from left to right are:
Column 1 | Column 2 | Column 3 | Column 4 |
---|---|---|---|
The type of operation declared on the symbol. Either: Decl = declared Def = defined Method Use = used | The type of the symbol. Either: Record Field Function
| Canonical declaration of the symbol referenced | Location of the reference |
Automatic processing of analysis output
Executing the script useage-post.sh
will create a directory called Unused-2.4.50
(or more generally: Unused-$(git describe)
)
...
THe files of interest include:
Err
GetOnly
MacroUnused
SetOnly
Undefined
Automatic processing of analysis output
Executing the script useage-post.sh
will create a directory called Unused-2.4.50
(or more generally: Unused-$(git describe)
)
The file Ref
is the sorted and uniqed concatenation of the ._Ref files produced by usage-make.sh
. The remaining files are produced by filtering and comparing various parts of Ref. For example, there are the unused declarations in lustre/llite
:
Code Block |
---|
# grep /llite/ UnusedDeclUse-2.4.50/Unused EnumConstant lustre/llite/llite_internal.h:121:9:LLIF_CONTENDED EnumConstant lustre/llite/llite_internal.h:123:9:LLIF_SRVLOCK EnumConstant lustre/llite/llite_internal.h:379:9:STATS_TRACK_LAST Field lustre/llite/llite_internal.h:1020:8:vvp_thread_info:vti_lvb Field lustre/llite/llite_internal.h:1020:8:vvp_thread_info:vti_queue Field lustre/llite/llite_internal.h:1078:8:ll_lock_tree:lt_fd Field lustre/llite/llite_internal.h:1078:8:ll_lock_tree:lt_locked_list Field lustre/llite/llite_internal.h:1078:8:ll_lock_tree:lt_root Field lustre/llite/llite_internal.h:1611:8:if_quotactl_18:obd_type Field lustre/llite/llite_internal.h:638:8:it_cb_data:hash Field lustre/llite/llite_internal.h:71:8:ll_dentry_data:lld_cwd_och Field lustre/llite/llite_internal.h:71:8:ll_dentry_data:lld_mnt_och Field lustre/llite/llite_internal.h:920:8:vvp_io:cui_partpage Function lustre/llite/llite_internal.h:1086:28:ll_node_from_inode Function lustre/llite/llite_internal.h:1154:19:ll_mds_max_easize Function lustre/llite/llite_internal.h:1216:5:ll_is_file_contended Function lustre/llite/llite_internal.h:663:20:ll_ra_read_get Function lustre/llite/llite_internal.h:713:6:ll_removepage Function lustre/llite/llite_internal.h:716:5:ll_file_punch Function lustre/llite/llite_internal.h:717:9:ll_file_lockless_io Function lustre/llite/llite_internal.h:718:6:ll_clear_file_contended Function lustre/llite/llite_internal.h:719:5:ll_sync_page_range Function lustre/llite/llite_internal.h:830:7:ll_read_opt Function lustre/llite/llite_internal.h:836:15:ll_inode_from_lock Function lustre/llite/llite_internal.h:864:6:lustre_dump_inode Function lustre/llite/llite_lib.c:1085:6:lu_context_keys_dump Function lustre/llite/llite_mmap.c:577:29:file_to_user Function lustre/llite/llite_mmap.c:58:14:ll_nopage Function lustre/llite/lloop.c:901:1:__inittest Function lustre/llite/lloop.c:902:1:__exittest Function lustre/llite/lloop.c:904:1:__check_max_loop Function lustre/llite/namei.c:78:5:ll_unlock Function lustre/llite/super25.c:232:1:__inittest Function lustre/llite/super25.c:233:1:__exittest Function lustre/llite/vvp_dev.c:172:5:vvp_global_init Function lustre/llite/vvp_dev.c:185:6:vvp_global_fini Record lustre/llite/llite_internal.h:1078:8:ll_lock_tree Typedef lustre/llite/llite_internal.h:1075:25:rb_node_t Var lustre/llite/llite_internal.h:658:25:ll_async_page_slab Var lustre/llite/llite_internal.h:659:15:ll_async_page_slab_size Var lustre/llite/llite_internal.h:84:31:ll_pgcache_seq_fops Var lustre/llite/llite_internal.h:884:31:ll_special_chr_inode_fops Var lustre/llite/llite_internal.h:885:31:ll_special_chr_file_fops Var lustre/llite/llite_internal.h:886:31:ll_special_blk_inode_fops Var lustre/llite/llite_internal.h:887:31:ll_special_fifo_inode_fops Var lustre/llite/llite_internal.h:888:31:ll_special_fifo_file_fops Var lustre/llite/llite_internal.h:889:31:ll_special_sock_inode_fops Var lustre/llite/rw26.c:559:33:ll_aops Var lustre/llite/vvp_dev.c:544:24:vvp_dump_pgcache_file_ops |
...