• Stephane Eranian's avatar
    perf stat: Fix case where guest/host monitoring is not supported by kernel · 5622c07b
    Stephane Eranian authored
    By default, perf stat sets exclude_guest = 1. But when you run perf on a
    kernel which does not support  host/guest filtering, then you get an
    error saying the event in unsupported. This comes from the fact that
    when the perf_event_attr struct passed by the user is larger than the
    one known to the kernel there is safety check which ensures that all
    unknown bits are zero. But here, exclude_guest is 1 (part of the unknown
    bits) and thus the perf_event_open() syscall return EINVAL.
    
    To my surprise, running perf record on the same kernel did not exhibit
    the problem. The reason is that perf record handles the problem by
    catching the error and retrying with guest/host excludes set to zero.
    For some reason, this was not done with perf stat. This patch fixes this
    problem.
    Signed-off-by: default avatarStephane Eranian <eranian@google.com>
    Cc: Gleb Natapov <gleb@redhat.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Joerg Roedel <joro@8bytes.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Robert Richter <robert.richter@amd.com>
    Link: http://lkml.kernel.org/r/20120427124538.GA7230@quadSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    5622c07b
builtin-stat.c 33.6 KB