backports: add Coccinelle SmPL profiling support to gentree.py
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 2 Apr 2014 12:13:05 +0000 (12:13 +0000)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 9 Apr 2014 01:16:21 +0000 (18:16 -0700)
commit414a0d9d48df6b840aee9337255219e0d184e829
tree176ddeccd452431ff4a03a9fbd263d97ccb2eace
parent7330a6c8f83b6340041d7dcbebfaa51977d5495f
backports: add Coccinelle SmPL profiling support to gentree.py

This adds support to let you pass --profile when running Coccinelle.
This will skip all patches, rewriting Makefiles, Kconfigs, etc, and
it will also keep a copy of the original src directory prior to
applying the spatch. You pass the spatch file as an argument when
using this.

Screenshot of relevant output on 11-dev-pm-ops.cocci:

$ time ./gentree.py --clean --verbose --profile-cocci 11-dev-pm-ops.cocci \
        /home/mcgrof/linux-next/ \
        /home/mcgrof/build/backports-20140311

Copy original source files ...
Apply patches ...
Profiling Coccinelle SmPL patch: 11-dev-pm-ops.cocci
Applying SmPL patch collateral-evolutions/network/11-dev-pm-ops.cocci
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> warning: line 15: should pci be a metavariable?
> (ONCE) Expected tokens pm pci_driver driver pci SIMPLE_DEV_PM_OPS
> MODULE_DEVICE_TABLE
> Skipping:./net/mac802154/ieee802154_dev.c
> Skipping:./net/mac802154/mac_cmd.c
> Skipping:./net/mac802154/mib.c
> Skipping:./net/mac802154/monitor.c
> Skipping:./net/mac802154/rx.c
> Skipping:./net/mac802154/tx.c
> Skipping:./net/mac802154/wpan.c
> starting: Common.group_assoc_bykey_eff
> ending: Common.group_assoc_bykey_eff, 0.000114s
> ---------------------
> profiling result
> ---------------------
> Main total                               :      0.584 sec          1 count
> parse cocci                              :      0.422 sec          1 count
> pre_engine                               :      0.422 sec          1 count
> Main.infiles computation                 :      0.156 sec          1 count
> HACK                                     :      0.069 sec          1 count
> C parsing.tokens                         :      0.043 sec          1 count
> C parsing.fix_define                     :      0.022 sec          1 count
> get_glimpse_constants                    :      0.021 sec          1 count
> C parsing.lex_ident                      :      0.006 sec        673 count
> Common.full_charpos_to_pos_large         :      0.006 sec          1 count
> Main.outfiles computation                :      0.004 sec          1 count
> worth_trying                             :      0.004 sec          7 count
> Common.full_charpos_to_pos               :      0.003 sec          2 count
> Common.=~                                :      0.000 sec          4 count
> check_duplicate                          :      0.000 sec          1 count
> Main.result analysis                     :      0.000 sec          1 count
> Common.group_assoc_bykey_eff             :      0.000 sec          1 count
> asttoctl2                                :      0.000 sec          1 count
> post_engine                              :      0.000 sec          1 count
> show_xxx                                 :      0.000 sec          2 count

This goes on... and a page per thread spawned and the results will be
specific to the files tha the thread worked on. On the above results
we can see Coccinelle spent little to no time working on the above
files as it determined it had nothing to do there.

On big iron backports server:

real    0m31.226s
user    7m25.712s
sys     0m34.492s

Cc: Peter Senna <peter.senna@gmail.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Gilles Muller <Gilles.Muller@lip6.fr>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
gentree.py
lib/bpcoccinelle.py