• James Clark's avatar
    perf map: Remove kernel map before updating start and end addresses · df12e21d
    James Clark authored
    In a debug build there is validation that mmap lists are sorted when
    taking a lock. In machine__update_kernel_mmap() the start and end
    addresses are updated resulting in an unsorted list before the map is
    removed from the list. When the map is removed, the lock is taken which
    triggers the validation and the failure:
    
      $ perf test "object code reading"
      --- start ---
      perf: util/maps.c:88: check_invariants: Assertion `map__start(prev) <= map__start(map)' failed.
      Aborted
    
    Fix it by updating the addresses after removal, but before insertion.
    The bug depends on the ordering and type of debug info on the system and
    doesn't reproduce everywhere.
    
    Fixes: 659ad349 ("perf maps: Switch from rbtree to lazily sorted array for addresses")
    Reviewed-by: default avatarIan Rogers <irogers@google.com>
    Signed-off-by: default avatarJames Clark <james.clark@arm.com>
    Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Leo Yan <leo.yan@linux.dev>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Spoorthy S <spoorts2@in.ibm.com>
    Link: https://lore.kernel.org/r/20240410103458.813656-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    df12e21d
machine.c 81.8 KB