Ian Rogers
3ee2255c4f
libperf threadmap: Add perf_thread_map__idx()
...
Allow computation of thread map index from a PID.
Note, with a 'struct perf_cpu_map' the sorted nature allows for a binary
search to compute the index which isn't currently possible with a
'struct perf_thread_map' as they aren't guaranteed sorted.
Signed-off-by: Ian Rogers <irogers@google.com >
Acked-by: Gautam Menghani <gautam@linux.ibm.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Madhavan Srinivasan <maddy@linux.ibm.com >
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/20250519195148.1708988-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-05-21 15:07:13 -03:00
Ian Rogers
eead8a0114
libperf threadmap: Don't segv for index 0 for the NULL 'struct perf_thread_map' pointer
...
perf_thread_map__nr() returns length 1 if the perf_thread_map is NULL,
meaning index 0 is valid.
When perf_thread_map__pid() of index 0 is read then return the expected
"any" -1 value.
Assert this is only done for index 0.
Signed-off-by: Ian Rogers <irogers@google.com >
Acked-by: Gautam Menghani <gautam@linux.ibm.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Howard Chu <howardchu95@gmail.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Madhavan Srinivasan <maddy@linux.ibm.com >
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/20250519195148.1708988-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2025-05-21 15:07:13 -03:00
Tzvetomir Stoyanov (VMware)
56dce86819
libperf: Add API for allocating new thread map array
...
The existing API perf_thread_map__new_dummy() allocates new thread map
for one thread. I couldn't find a way to reallocate the map with more
threads, or to allocate a new map for more than one thread.
Having multiple threads in a thread map is essential for some use cases.
That's why a new API is proposed, which allocates a new thread map for
given number of threads: perf_thread_map__new_array()
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com >
Acked-by: Jiri Olsa <jolsa@kernel.org >
Cc: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/linux-perf-users/20220221102628.43904-1-tz.stoyanov@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-02-23 14:40:23 -03:00
Tzvetomir Stoyanov (VMware)
41415b8a97
libperf: Rename arguments of perf_thread_map APIs
...
The "int thread" input arguments of some perf_thead_map APIs are index
of the thread in the thread map.
In order to avoid confusion and to make the APIs consistent with
perf_cpu_map APIs, those arguments are renamed to "int idx".
Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org >
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com >
Acked-by: Jiri Olsa <jolsa@kernel.org >
Cc: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/20220221102612.43879-1-tz.stoyanov@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2022-02-23 14:39:29 -03:00
Jiri Olsa
3ce311afb5
libperf: Move to tools/lib/perf
...
Move libperf from its current location under tools/perf to a separate
directory under tools/lib/.
Also change various paths (mainly includes) to reflect the libperf move
to a separate directory and add a new directory under MANIFEST.
Signed-off-by: Jiri Olsa <jolsa@kernel.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Michael Petlan <mpetlan@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: http://lore.kernel.org/lkml/20191206210612.8676-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2020-01-06 11:46:09 -03:00