duplicate body remover

David Smith dsmith@redhat.com
Thu Oct 19 16:35:00 GMT 2006


Li Guanglei wrote:
> Hi,
>   today when I tried to shrink the size of the generate .c file from 
> stap, I met some problems. One of them is the lack of removing 
> duplicated probe bodies across different probes. Here is an example:
> 
> probe kernel.function("netif_receive_skb"),
>       kernel.function("dev_queue_xmit")
> {
> log("here")
> }
> 
> stap -p2 -v shows the output is:
> 
> # functions
> log:unknown (msg:string)
> %{
>         _stp_printf ("%s\n", THIS->msg);
> %}
> # probes
> kernel.function("netif_receive_skb@net/core/dev.c:1673")
> {
> log("here")
> }
> kernel.function("dev_queue_xmit@net/core/dev.c:1318")
> {
> log("here")
> }
> 
> But I think stap should further optimize it as:
> 
> # functions
> log:unknown (msg:string)
> %{
>         _stp_printf ("%s\n", THIS->msg);
> %}
> # probes
> kernel.function("netif_receive_skb@net/core/dev.c:1673"),
> kernel.function("dev_queue_xmit@net/core/dev.c:1318")
> {
> log("here")
> }
> 
> How about having a new class duplicate_body_remover, and a new function  
> get_bodysig() to determine the duplication of probe body? Much of the 
> logic could resemble the current duplicated function removing codes 
> called inside semantic_pass_opt5().

This actually already exists, it just happens at a later stage.  If you 
look at the generated C code, you'll see something like this:

=================
static void probe_1480 (struct context * __restrict__ c) {
... normal systemtap initialization plus code to do 'log("here")' ...
}

...

static void probe_1481 (struct context * __restrict__ c) {
   probe_1480 (c);
}
=================

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)



More information about the Systemtap mailing list