perf comm: Fix comm_str__put() for reference count checking
authorIan Rogers <irogers@google.com>
Wed, 8 May 2024 03:52:59 +0000 (20:52 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 9 May 2024 21:13:22 +0000 (18:13 -0300)
commitde6a908384fb1a8327ba46a2baec67d1dfe9a3e1
tree608eba1de49211bcddadc00918d3094110a0740b
parent90f01afb0dfafbc9b094bb61e61a4ac297d9d0d2
perf comm: Fix comm_str__put() for reference count checking

Searching for the entry in the array needs to avoid the intermediate
pointer with reference count checking.

Refactor the array removal to binary search for the entry.

Change the array to hold an entry with a reference count (so the
intermediate pointer can work) and remove from the array when the
reference count on a comm_str falls to 1.

Fixes: 13ca628716c6f2c3 ("perf comm: Add reference count checking to 'struct comm_str'")
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.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>
Link: https://lore.kernel.org/r/20240508035301.1554434-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/comm.c