• Namhyung Kim's avatar
    perf lock contention: Fix msan issue in lock_contention_read() · 5d8c0f0e
    Namhyung Kim authored
    I got a report of a msan failure like below:
    
      $ sudo perf lock con -ab -- sleep 1
      ...
      ==224416==WARNING: MemorySanitizer: use-of-uninitialized-value
          #0 0x5651160d6c96 in lock_contention_read  util/bpf_lock_contention.c:290:8
          #1 0x565115f90870 in __cmd_contention  builtin-lock.c:1919:3
          #2 0x565115f90870 in cmd_lock  builtin-lock.c:2385:8
          #3 0x565115f03a83 in run_builtin  perf.c:330:11
          #4 0x565115f03756 in handle_internal_command  perf.c:384:8
          #5 0x565115f02d53 in run_argv  perf.c:428:2
          #6 0x565115f02d53 in main  perf.c:562:3
          #7 0x7f43553bc632 in __libc_start_main
          #8 0x565115e865a9 in _start
    
    It was because the 'key' variable is not initialized.  Actually it'd be set
    by bpf_map_get_next_key() but msan didn't seem to understand it.  Let's make
    msan happy by initializing the variable.
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Acked-by: default avatarIan Rogers <irogers@google.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20230324001922.937634-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    5d8c0f0e
bpf_lock_contention.c 8.91 KB