perf maps: Remove check_invariants() from maps__lock()
authorNamhyung Kim <namhyung@kernel.org>
Mon, 29 Apr 2024 22:57:38 +0000 (15:57 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 May 2024 19:35:47 +0000 (16:35 -0300)
commit3cdd98b42d212160d7aae746a97960a4595cbfc2
treef1dab900e645c094567b21e735656f45abe17bf9
parente3123079b906dc2edb80466de85b2c333a56fbf2
perf maps: Remove check_invariants() from maps__lock()

I found that the debug build was a slowed down a lot by the maps lock
code since it checks the invariants whenever it gets the pointer to the
lock.  This means it checks twice the invariants before and after the
access.

Instead, let's move the checking code within the lock area but after any
modification and remove it from the read paths.  This would remove (more
than) half of the maps lock overhead.

The time for perf report with a huge data file (200k+ of MMAP2 events).

  Non-debug     Before      After
  ---------   --------   --------
     2m 43s     6m 45s     4m 21s

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240429225738.1491791-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/maps.c