• Wang Nan's avatar
    perf record: Apply filter to all events in a glob matching · 15bfd2cc
    Wang Nan authored
    There is an old problem in perf's filter applying which first posted at
    Sep. 2014 at https://lkml.org/lkml/2014/9/9/944 that, if passing
    multiple events in a glob matching expression in cmdline then add
    '--filter' after them, the filter will be applied on only the last one.
    
    For example:
    
     # dd if=/dev/zero of=/dev/null &
     [1] 464
     # perf record -a -e 'syscalls:sys_*_read' --filter 'common_pid != 464' sleep 0.1
     [ perf record: Woken up 1 times to write data ]
     [ perf record: Captured and wrote 0.239 MB perf.data (2094 samples) ]
     # perf report --stdio | tee
     ...
     # Samples: 2K of event 'syscalls:sys_enter_read'
     # Event count (approx.): 2092
     ...
     # Samples: 2  of event 'syscalls:sys_exit_read'
     # Event count (approx.): 2
     ...
    
    In this example, filter only applied on 'syscalls:sys_exit_read', and
    there's no way to set filter for ''syscalls:sys_enter_read'.
    
    This patch adds a 'cmdline_group_boundary' for 'struct evsel', and
    apply filter on all events between two boundary marks.
    
    After applying this patch:
    
     # perf record -a -e 'syscalls:sys_*_read' --filter 'common_pid != 464' sleep 0.1
     [ perf record: Woken up 1 times to write data ]
     [ perf record: Captured and wrote 0.031 MB perf.data (3 samples) ]
     # perf report --stdio | tee
     ...
     # Samples: 1  of event 'syscalls:sys_enter_read'
     # Event count (approx.): 1
     ...
     # Samples: 2  of event 'syscalls:sys_exit_read'
     # Event count (approx.): 2
     ...
    Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
    Reported-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Zefan Li <lizefan@huawei.com>
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1436513770-8896-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    15bfd2cc
evsel.c 52.7 KB