• Ian Rogers's avatar
    perf record: Don't clear event's period if set by a term · 3b0a18c1
    Ian Rogers authored
    If events in a group explicitly set a frequency or period with leader
    sampling, don't disable the samples on those events.
    
    Prior to 5.8:
    
      perf record -e '{cycles/period=12345000/,instructions/period=6789000/}:S'
    
    would clear the attributes then apply the config terms. In commit
    5f342788 leader sampling configuration was moved to after applying the
    config terms, in the example, making the instructions' event have its period
    cleared.
    
    This change makes it so that sampling is only disabled if configuration
    terms aren't present.
    
    Committer testing:
    
    Before:
    
      # perf record -e '{cycles/period=1/,instructions/period=2/}:S' sleep 1
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.051 MB perf.data (6 samples) ]
      #
      # perf evlist -v
      cycles/period=1/: size: 120, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, disabled: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
      instructions/period=2/: size: 120, config: 0x1, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, sample_id_all: 1, exclude_guest: 1
      #
    
    After:
    
      # perf record -e '{cycles/period=1/,instructions/period=2/}:S' sleep 0.0001
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.052 MB perf.data (4 samples) ]
      # perf evlist -v
      cycles/period=1/: size: 120, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, disabled: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
      instructions/period=2/: size: 120, config: 0x1, { sample_period, sample_freq }: 2, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, sample_id_all: 1, exclude_guest: 1
      #
    
    Fixes: 5f342788 ("perf evlist: Move leader-sampling configuration")
    Signed-off-by: default avatarIan Rogers <irogers@google.com>
    Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Andrii Nakryiko <andriin@fb.com>
    Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: John Fastabend <john.fastabend@gmail.com>
    Cc: KP Singh <kpsingh@chromium.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Yonghong Song <yhs@fb.com>
    Link: http://lore.kernel.org/lkml/20200912025655.1337192-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    3b0a18c1
record.c 7.21 KB