Ian Rogers
d3944f0ed4
perf inject: Lazily allocate event_copy
...
The event_copy is 64kb (PERF_SAMPLE_SIZE_MAX) and stack allocated in
struct perf_inject. It is used for aux events that may not exist in a
file. Make the array allocation lazy to cut down on the stack usage.
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: Jiri Olsa <jolsa@kernel.org >
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/20230527034324.2597593-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
e590e46b54
perf script: Remove some large stack allocations
...
Some char buffers are stack allocated but in total they come to
24kb. Avoid Wstack-usage warnings by moving the arrays to being
dynamically allocated.
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: Jiri Olsa <jolsa@kernel.org >
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/20230527034324.2597593-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
232418a0b2
perf sched: Avoid large stack allocations
...
Commit 5ded57ac1b ("perf inject: Remove static variables") moved
static variables to local, however, in this case 3 MAX_CPUS (4096)
sized arrays were moved onto the stack making the stack frame quite
large. Avoid the stack usage by dynamically allocating the arrays.
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: Jiri Olsa <jolsa@kernel.org >
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/20230527034324.2597593-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
e57d739334
perf bench sched messaging: Free contexts on exit
...
Place sender and receiver contexts onto lists so that they may be
freed on exit. Add missing pthread_attr_destroy. Fixes memory leaks
reported by leak sanitizer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Darren Hart <dvhart@infradead.org >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20230611233610.953456-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
8351498d52
perf bench futex: Avoid memory leaks from pthread_attr
...
Remove code sharing the pthread_attr_t and initialize/destroy
pthread_attr_t when needed. This avoids the same attribute being set
that leak sanitizer reports as a memory leak.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Darren Hart <dvhart@infradead.org >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20230611233610.953456-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
e6deda2e5a
perf bench epoll: Fix missing frees/puts on the exit path
...
Issues detected by leak sanitizer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Darren Hart <dvhart@infradead.org >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20230611233610.953456-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
0f0d1354a5
perf help: Ensure clean_cmds is called on all paths
...
Avoid potential memory leaks.
Committer notes:
This is right before calling exit(1), so just to clean up memory leak
checker detection.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Darren Hart <dvhart@infradead.org >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20230611233610.953456-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:14 -03:00
Ian Rogers
657a3efee4
lib subcmd: Avoid memory leak in exclude_cmds
...
exclude_cmds will shorten the cmds names array, before doing so free the
removed entry.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: André Almeida <andrealmeid@igalia.com >
Cc: Darren Hart <dvhart@infradead.org >
Cc: Davidlohr Bueso <dave@stgolabs.net >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20230611233610.953456-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
James Clark
d927ef5004
perf cs-etm: Add exception level consistency check
...
Assert that our own tracking of the exception level matches what
OpenCSD provides. OpenCSD doesn't distinguish between EL0 and EL1 in the
memory access callback so the extra tracking was required. But a rough
assert can still be done.
Signed-off-by: James Clark <james.clark@arm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Will Deacon <will@kernel.org >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230612111403.100613-6-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
James Clark
8d3031d39f
perf cs-etm: Track exception level
...
Currently we assume all trace belongs to the host machine so when
the decoder should be looking at the guest kernel maps it can crash
because it looks at the host ones instead.
Avoid one scenario (guest kernel running at EL1) by assigning the
default guest machine to this trace. For userspace trace it's still not
possible to determine guest vs host, but the PIDs should help in this
case.
Committer notes:
Fixed up conflict with:
perf addr_location: Add init/exit/copy functions
That was only on tmp.perf-tools-next.
Reviewed-by: Leo Yan <leo.yan@linaro.org >
Signed-off-by: James Clark <james.clark@arm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Will Deacon <will@kernel.org >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230612111403.100613-5-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
James Clark
5414b53261
perf cs-etm: Make PID format accessible from struct cs_etm_auxtrace
...
To avoid every user of PID format having to use their own static
local variable, cache it on initialisation and change the accessor to
take struct cs_etm_auxtrace.
Reviewed-by: Leo Yan <leo.yan@linaro.org >
Signed-off-by: James Clark <james.clark@arm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Will Deacon <will@kernel.org >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230612111403.100613-4-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
James Clark
d67d8c87d0
perf cs-etm: Use previous thread for branch sample source IP
...
Branch samples currently use the IP of the previous packet as the from
IP, and the IP of the current packet as the to IP. But it incorrectly
uses the current thread. In some cases like a jump into a different
exception level this will attribute to the incorrect process.
Fix it by tracking the previous thread in the same way the previous
packet is tracked.
Committer notes:
Resolved conflicts with:
perf addr_location: Add init/exit/copy functions
perf thread: Add accessor functions for thread
Reviewed-by: Mike Leach <mike.leach@linaro.org >
Signed-off-by: James Clark <james.clark@arm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Will Deacon <will@kernel.org >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lore.kernel.org/lkml/20230612111403.100613-3-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
James Clark
951ccccdc7
perf cs-etm: Only track threads instead of PID and TIDs
...
PIDs and TIDs are already contained within the thread struct, so to
avoid inconsistencies drop the extra members on the etm queue and only
use the thread struct.
At the same time stop using the 'unknown' thread. In a later commit
we will be making samples from multiple machines so it will be better
to use the idle thread of each machine rather than overlapping unknown
threads. Using the idle thread is also better because kernel addresses
with a previously unknown thread will now be assigned to a real kernel
thread.
Committer notes:
Resolved conflicts with:
perf addr_location: Add init/exit/copy functions
perf thread: Add accessor functions for thread
perf thread: Remove notion of dead threads
That were present in tmp.perf-tools.next only.
Reviewed-by: Leo Yan <leo.yan@linaro.org >
Reviewed-by: Mike Leach <mike.leach@linaro.org >
Signed-off-by: James Clark <james.clark@arm.com >
Acked-by: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Will Deacon <will@kernel.org >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lore.kernel.org/lkml/20230612111403.100613-2-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
James Clark
0d98a7af4b
perf map: Fix double 'struct map' reference free found with -DREFCNT_CHECKING=1
...
When quitting after running a 'perf report', the refcount checker finds
some double frees. The issue is that map__put() is called on a function
argument so it removes the refcount wrapper that someone else was using.
Fix it by only calling map__put() on a reference that is owned by this
function.
Committer notes:
Narrowed the map_ref scope as suggested by Ian, removed the symbol-elf
part as it was already fixed by another patch, from Ian.
Signed-off-by: James Clark <james.clark@arm.com >
Acked-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: Jiri Olsa <jolsa@kernel.org >
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/20230612150424.198914-1-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:18:13 -03:00
Arnaldo Carvalho de Melo
922db21d7e
perf srcline: Optimize comparision against SRCLINE_UNKNOWN
...
This is a string constant that gets returned and then strcmp() around,
we can instead just do a pointer comparision.
That requires a new global variable to comply with these warnings from
some versions of clang and gcc:
41 68.95 fedora:rawhide : FAIL clang version 16.0.4 (Fedora 16.0.4-1.fc39)
result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare]
if (start_line != SRCLINE_UNKNOWN &&
^ ~~~~~~~~~~~~~~~ 41
Ack comments:
Agreed, the strcmps make me nervous as they won't distinguish heap from
a global meaning we could end up with things like pointers to freed
memory. The comparison with the global is always going to be same imo.
Acked-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Link: https://lore.kernel.org/lkml/ZIcoJytUEz4UgQYR@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 18:17:00 -03:00
Mickaël Salaün
35ca423992
selftests/landlock: Add hostfs tests
...
Add tests for the hostfs filesystems to make sure it has a consistent
inode management, which is required for Landlock's file hierarchy
identification. This adds 5 new tests for layout3_fs with the hostfs
variant.
Add hostfs to the new (architecture-specific) config.um file.
The hostfs filesystem, only available for an User-Mode Linux kernel, is
special because we cannot explicitly mount it. The layout3_fs.hostfs
variant tests are skipped if the current test directory is not backed by
this filesystem.
The layout3_fs.hostfs.tag_inode_dir_child and
layout3_fs.hostfs.tag_inode_file tests pass thanks to a previous commit
fixing hostfs inode management. Without this fix, the deny-by-default
policy would apply and all access requests would be denied.
Link: https://lore.kernel.org/r/20230612191430.339153-7-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net >
2023-06-12 21:26:23 +02:00
Mickaël Salaün
04f9070e99
selftests/landlock: Add tests for pseudo filesystems
...
Add generic and read-only tests for 6 pseudo filesystems to make sure
they have a consistent inode management, which is required for
Landlock's file hierarchy identification:
- tmpfs
- ramfs
- cgroup2
- proc
- sysfs
Update related kernel configuration to support these new filesystems,
remove useless CONFIG_SECURITY_PATH, and sort all entries. If these
filesystems are not supported by the kernel running tests, the related
tests are skipped.
Expanding variants, this adds 25 new tests for layout3_fs:
- tag_inode_dir_parent
- tag_inode_dir_mnt
- tag_inode_dir_child
- tag_inode_dir_file
- release_inodes
Test coverage for security/landlock with kernel debug code:
- 94.7% of 835 lines according to gcc/gcov-12
- 93.0% of 852 lines according to gcc/gcov-13
Test coverage for security/landlock without kernel debug code:
- 95.5% of 624 lines according to gcc/gcov-12
- 93.1% of 641 lines according to gcc/gcov-13
Link: https://lore.kernel.org/r/20230612191430.339153-6-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net >
2023-06-12 21:26:23 +02:00
Mickaël Salaün
55ab3fbe83
selftests/landlock: Make mounts configurable
...
Add a new struct mnt_opt to define a mount point with the mount_opt()
helper. This doesn't change tests but prepare for the next commit.
Link: https://lore.kernel.org/r/20230612191430.339153-5-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net >
2023-06-12 21:26:22 +02:00
Mickaël Salaün
3de64b656b
selftests/landlock: Add supports_filesystem() helper
...
Replace supports_overlayfs() with supports_filesystem() to be able to
check several filesystems. This will be useful in a following commit.
Only check for overlay filesystem once in the setup step, and then rely
on self->skip_test.
Cc: Guenter Roeck <groeck@chromium.org >
Cc: Jeff Xu <jeffxu@google.com >
Link: https://lore.kernel.org/r/20230612191430.339153-4-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net >
2023-06-12 21:26:21 +02:00
Mickaël Salaün
592efeb4a0
selftests/landlock: Don't create useless file layouts
...
Add and use a layout0 test fixture to not populate the tmpfs filesystem
if it is not required for tests: unknown_access_rights, proc_nsfs,
unpriv and max_layers.
This doesn't change these tests but it speeds up their setup and makes
them less prone to error. This prepare the ground for a next commit.
Link: https://lore.kernel.org/r/20230612191430.339153-3-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net >
2023-06-12 21:26:21 +02:00
Ian Rogers
834631ee77
perf hist: Fix srcline memory leak
...
srcline isn't freed if it is SRCLINE_UNKNOWN. Avoid strduping in this
case as such strdups are redundant and leak memory.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-27-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
625db36e6c
perf srcline: Change free_srcline to zfree_srcline
...
Make use after free more unlikely.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-26-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
8ab12a2038
perf callchain: Use pthread keys for tls callchain_cursor
...
Pthread keys are more portable than __thread and allow the association
of a destructor with the key. Use the destructor to clean up TLS
callchain cursors to aid understanding memory leaks.
Committer notes:
Had to fixup a series of unconverted places and also check for the
return of get_tls_callchain_cursor() as it may fail and return NULL.
In that unlikely case we now either print something to a file, if the
caller was expecting to print a callchain, or return an error code to
state that resolving the callchain isn't possible.
In some cases this was made easier because thread__resolve_callchain()
already can fail for other reasons, so this new one (cursor == NULL) can
be added and the callers don't have to explicitely check for this new
condition.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-25-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
d7ba60a4e5
perf header: Avoid out-of-bounds read
...
intel-pt tests were failing:
-- Test virtual LBR ---
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.126 MB /tmp/perf-test-intel-pt-sh.FW57CXnCqQ/test-perf.data ]
Failed with virtual lbr
...
```
The root cause is an out-of-bounds read in header (where maxbrstack.py
is from test_intel_pt.sh):
```
$ perf --no-pager script --itrace=L -s maxbrstack.py
=================================================================
==3907930==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000095a8 at pc 0x563c26c840bb bp 0x7fff43582710 sp 0x7fff43582708
READ of size 4 at 0x6020000095a8 thread T0
#0 0x563c26c840ba in process_group_desc util/header.c:2847
#1 0x563c26c8bc78 in perf_file_section__process util/header.c:4037
#2 0x563c26c8aa9b in perf_header__process_sections util/header.c:3813
#3 0x563c26c8d028 in perf_session__read_header util/header.c:4286
#4 0x563c26cbab29 in perf_session__open util/session.c:113
#5 0x563c26cbb3d0 in __perf_session__new util/session.c:221
#6 0x563c26aacb14 in perf_session__new util/session.h:73
#7 0x563c26acf7f1 in cmd_script tools/perf/builtin-script.c:4212
#8 0x563c26bb58ff in run_builtin tools/perf/perf.c:323
#9 0x563c26bb5e70 in handle_internal_command tools/perf/perf.c:377
#10 0x563c26bb6238 in run_argv tools/perf/perf.c:421
#11 0x563c26bb67a0 in main tools/perf/perf.c:537
#12 0x7f34bde46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#13 0x7f34bde46244 in __libc_start_main_impl ../csu/libc-start.c:381
#14 0x563c26a33390 in _start (/tmp/perf/perf+0x1eb390)
0x6020000095a8 is located 8 bytes to the right of 16-byte region [0x602000009590,0x6020000095a0)
allocated by thread T0 here:
#0 0x7f34beeb83b7 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x563c26c83df8 in process_group_desc util/header.c:2824
#2 0x563c26c8bc78 in perf_file_section__process util/header.c:4037
#3 0x563c26c8aa9b in perf_header__process_sections util/header.c:3813
#4 0x563c26c8d028 in perf_session__read_header util/header.c:4286
#5 0x563c26cbab29 in perf_session__open util/session.c:113
#6 0x563c26cbb3d0 in __perf_session__new util/session.c:221
#7 0x563c26aacb14 in perf_session__new util/session.h:73
#8 0x563c26acf7f1 in cmd_script tools/perf/builtin-script.c:4212
#9 0x563c26bb58ff in run_builtin tools/perf/perf.c:323
#10 0x563c26bb5e70 in handle_internal_command tools/perf/perf.c:377
#11 0x563c26bb6238 in run_argv tools/perf/perf.c:421
#12 0x563c26bb67a0 in main tools/perf/perf.c:537
#13 0x7f34bde46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
```
Avoid the out-of-bounds read checking for the leader. Leave the 'nr'
check intact as nr will be 0 or the counting down and evsel be a group
member.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/lkml/20230608232823.4027869-24-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
cddeeeda8f
perf top: Add exit routine for main thread
...
Add exit_process_thread that reverses init_process_thread. This avoids
leak sanitizer reporting memory leaks.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-23-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
d3d53b2e96
perf annotate: Fix parse_objdump_line memory leak
...
fileloc is used to hold a previous line, before overwriting it ensure
the previous contents is freed. Free the storage once done in
symbol__disassemble.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-22-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
bffb5b0c09
perf map/maps/thread: Changes to reference counting
...
Fix missed reference count gets and puts as detected with leak
sanitizer and reference count checking.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-21-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
1981da1fe2
perf machine: Don't leak module maps
...
machine__addnew_module_map requires a put on its result. Add this and
narrow the scope of map to make the correctness more obvious. This
leak was caught with leak sanitizer and the reference count checker.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-20-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
34b29bd61d
perf machine: Fix leak of kernel dso
...
The kernel dso may be found by searching dsos or allocating if not
found. The allocation returns with a reference count of 2, once for
the dsos list and once for the returned value. The list search has a
reference count of 1, once for the dsos list. To make the reference
counts consistent, increase the dsos list search reference count to 2
with a dso__get, and do a put when the scope ends for either the
allocated or found dso.
This issue was found with leak sanitizer and reference count checking.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-19-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
814a656870
perf maps: Fix overlapping memory leak
...
Add a missed free detected by leak sanitizer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-18-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
fe8fec1028
perf symbol-elf: Correct holding a reference
...
If a reference is held, don't put it as this will confuse reference
count checking.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-17-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
5cedd1e29d
perf jit: Fix two thread leaks
...
As reported by leak sanitizer with reference count checking.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-16-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:54 -03:00
Ian Rogers
51cfe7a3e8
perf python: Avoid 2 leak sanitizer issues
...
Leak sanitizer complains about the variable size bf allocation and
store to bf if sized 0.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-15-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
ac873ac326
perf evlist: Free stats in all evlist destruction
...
There is no evsel free stats, freeing in the evlist__delete ensures
memory leaks are avoided. Issues detected with "perf stat report" and
leak sanitizer, perf stat uses perf_session__delete to free the
evlist. Add dummy symbol for python build.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-14-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
084770f55a
perf intel-pt: Fix missed put and leak
...
Add missing put and free, detected with leak sanitizer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-13-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
2b87be183b
perf stat: Avoid evlist leak
...
Free evlist before overwriting in "perf stat report" mode. Detected
using leak sanitizer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-12-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
f8e502b9d1
perf header: Ensure bitmaps are freed
...
memory_node bitmaps need a bitmap_free to avoid memory leaks. Caught
by leak sanitizer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-11-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
2c9f7bd795
perf report: Avoid 'parent_thread' thread leak on '--tasks' processing
...
Caught with address sanitizer and reference count checking.
Committer notes:
The command leading to this leak:
# perf record -a sleep 2
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 2.516 MB perf.data (6422 samples) ]
# perf report --tasks
# pid tid ppid comm
0 0 -1 |swapper
1 1 0 | systemd
1474 1474 1 | systemd
2816 2816 1474 | gjs
2816 2825 2816 | gmain
2816 2831 2816 | gdbus
2816 2861 2816 | JS Helper
2816 2862 2816 | JS Helper
2816 2863 2816 | JS Helper
2816 2864 2816 | JS Helper
2816 2865 2816 | JS Helper
2816 2866 2816 | JS Helper
2816 2867 2816 | JS Helper
2816 2868 2816 | JS Helper
3072 3072 1474 | gsd-printer
3072 3082 3072 | gmain
3072 3083 3072 | gdbus
2600 2600 1474 | gnome-shell
15621 15621 2600 | firefox
15771 15771 15621 | WebExtensions
15771 15872 15771 | TaskCon~ller #6
15771 15873 15771 | TaskCon~ller #7
15771 15778 15771 | IPC I/O Child
15771 15779 15771 | Socket Thread
15771 15780 15771 | HTML5 Parser
15771 15781 15771 | JS Watchdog
# <SNIP>
When it is going to exit a thread__put(parent_thread) was missed, add it
to have ASAN clean.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-10-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
cf078c8381
perf machine: Make delete_threads part of machine__exit
...
The code required threads to be deleted before machine__exit was
called or the threads would be leaked. This was error prone so move
the delete_threads into machine__exit.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-9-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
f6005cafeb
perf thread: Add reference count checking
...
Modify struct declaration and accessor functions for the reference
count checkers additional layer of indirection. Make sure pid_cmp in
builtin-sched.c uses the underlying/original struct in pointer
arithmetic, and not the temporary get/put indirection.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-8-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
0dd5041c9a
perf addr_location: Add init/exit/copy functions
...
struct addr_location holds references to multiple reference counted
objects. Add init/exit functions to make maintenance of those more
consistent with the rest of the code and to try to avoid
leaks. Modification of thread reference counts isn't included in this
change.
Committer notes:
I needed to initialize result to sample->ip to make sure is set to
something, fixing a compile time error, mostly keeping the previous
logic as build_alloc_func_list() already does debugging/error prints
about what went wrong if it takes the 'goto out'.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
620be847f4
perf addr_location: Move to its own header
...
addr_location is a common abstraction, move it into its own header and
source file in preparation for wider clean up.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
46125590e0
perf maps: Make delete static, always use put
...
Address/leak sanitizer with reference count checking can identify the
location of leaks, so use put rather than delete to avoid free-ing
memory when the reference count is >1. Add maps__zput to ensure the
variable is cleared.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
ee84a3032b
perf thread: Add accessor functions for thread
...
Using accessors will make it easier to add reference count checking in
later patches.
Committer notes:
thread->nsinfo wasn't wrapped as it is used together with
nsinfo__zput(), where does a trick to set the field with a refcount
being dropped to NULL, and that doesn't work well with using
thread__nsinfo(thread), that loses the &thread->nsinfo pointer.
When refcount checking is added to 'struct thread', later in this
series, nsinfo__zput(RC_CHK_ACCESS(thread)->nsinfo) will be used to
check the thread pointer.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
7ee227f674
perf thread: Make threads rbtree non-invasive
...
Separate the rbtree out of thread and into a new struct
thread_rb_node. The refcnt is in thread and the rbtree is responsible
for a single count.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
40826c45eb
perf thread: Remove notion of dead threads
...
The dead thread list is best effort. Threads live on it until the
reference count hits zero and they are removed. With correct reference
counting this should never happen. It is, however, part of the 'perf
sched' output that is now removed. If this is an issue we should
implement tracking of dead threads in a robust not best-effort way.
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ali Saidi <alisaidi@amazon.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Brian Robbins <brianrob@linux.microsoft.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Dmitrii Dolgov <9erthalion6@gmail.com >
Cc: Fangrui Song <maskray@google.com >
Cc: German Gomez <german.gomez@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Ivan Babrou <ivan@cloudflare.com >
Cc: James Clark <james.clark@arm.com >
Cc: Jing Zhang <renyu.zj@linux.alibaba.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: K Prateek Nayak <kprateek.nayak@amd.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linaro.org >
Cc: Liam Howlett <liam.howlett@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Miguel Ojeda <ojeda@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sean Christopherson <seanjc@google.com >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Suzuki Poulouse <suzuki.poulose@arm.com >
Cc: Wenyu Liu <liuwenyu7@huawei.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yang Jihong <yangjihong1@huawei.com >
Cc: Ye Xingchen <ye.xingchen@zte.com.cn >
Cc: Yuan Can <yuancan@huawei.com >
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230608232823.4027869-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
dcf7a17714
perf test: Add test of libpfm4 events
...
$ ./perf test -v 102
102: perf all libpfm4 events test :
--- start ---
test child forked, pid 3030994
Testing ix86arch::UNHALTED_CORE_CYCLES
Testing ix86arch::INSTRUCTION_RETIRED
Testing ix86arch::UNHALTED_REFERENCE_CYCLES
Testing ix86arch::LLC_REFERENCES
Testing ix86arch::LLC_MISSES
Testing ix86arch::BRANCH_INSTRUCTIONS_RETIRED
Testing ix86arch::MISPREDICTED_BRANCH_RETIRED
Testing perf_raw::r0000
Testing icl::UNHALTED_CORE_CYCLES
Testing icl::UNHALTED_REFERENCE_CYCLES
...
test child finished with 0
---- end ----
perf all libpfm4 events test: Ok
Signed-off-by: Ian 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 >
Cc: Stephane Eranian <eranian@google.com >
Link: https://lore.kernel.org/r/20230608232400.3056312-4-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Ian Rogers
cc3d139bca
perf list: Check arguments to show libpfm4 events
...
This is particularly useful for tests.
$ perf list pfm
Signed-off-by: Ian 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 >
Cc: Stephane Eranian <eranian@google.com >
Link: https://lore.kernel.org/r/20230608232400.3056312-3-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Namhyung Kim
d1f1cecc92
perf list: Check if libpfm4 event is supported
...
Some of its event info cannot be used directly due to missing default
attributes. Let's check if the event is supported before printing like
we do for hw and cache events.
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Acked-by: Ian Rogers <irogers>@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephane Eranian <eranian@google.com >
Link: https://lore.kernel.org/r/20230608232400.3056312-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00
Adrian Hunter
f0617f526c
perf parse: Allow config terms with breakpoints
...
Add config terms to the parsing of breakpoint events. Extend "Test event
parsing" to also cover using a confg term.
This makes breakpoint events consistent with other events which already
support config terms.
Example:
$ cat dr_test.c
#include <unistd.h>
#include <stdio.h>
void func0(void)
{
}
int main()
{
printf("func0 %p\n", &func0);
while (1) {
func0();
usleep(100000);
}
return 0;
}
$ gcc -g -O0 -o dr_test dr_test.c
$ ./dr_test &
[2] 19646
func0 0x55feb98dd169
$ perf record -e mem:0x55feb98dd169:x/name=breakpoint/ -p 19646 -- sleep 0.5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (5 samples) ]
$ perf script
dr_test 19646 5632.956628: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.056866: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.157084: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.257309: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.357532: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
$ sudo perf test "Test event parsing"
6: Parse event definition strings :
6.1: Test event parsing : Ok
$ sudo perf test -v "Test event parsing" |& grep mem
running test 8 'mem:0'
running test 9 'mem:0:x'
running test 10 'mem:0:r'
running test 11 'mem:0:w'
running test 19 'mem:0:u'
running test 20 'mem:0:x:k'
running test 21 'mem:0:r:hp'
running test 22 'mem:0:w:up'
running test 26 'mem:0:rw'
running test 27 'mem:0:rw:kp'
running test 42 'mem:0/1'
running test 43 'mem:0/2:w'
running test 44 'mem:0/4:rw:u'
running test 58 'mem:0/name=breakpoint/'
running test 59 'mem:0:x/name=breakpoint/'
running test 60 'mem:0:r/name=breakpoint/'
running test 61 'mem:0:w/name=breakpoint/'
running test 62 'mem:0/name=breakpoint/u'
running test 63 'mem:0:x/name=breakpoint/k'
running test 64 'mem:0:r/name=breakpoint/hp'
running test 65 'mem:0:w/name=breakpoint/up'
running test 66 'mem:0:rw/name=breakpoint/'
running test 67 'mem:0:rw/name=breakpoint/kp'
running test 68 'mem:0/1/name=breakpoint/'
running test 69 'mem:0/2:w/name=breakpoint/'
running test 70 'mem:0/4:rw/name=breakpoint/u'
running test 71 'mem:0/1/name=breakpoint1/,mem:0/4:rw/name=breakpoint2/'
Committer notes:
Folded follow up patch (see 2nd link below) to address warnings about
unused tokens:
perf tools: Suppress bison unused value warnings
Patch "perf tools: Allow config terms with breakpoints" introduced parse
tokens for colons and slashes within breakpoint parsing to prevent mix
up with colons and slashes related to config terms.
The token values are not needed but introduce bison "unused value"
warnings.
Suppress those warnings.
Committer testing:
# cat ~acme/c/mem_breakpoint.c
#include <stdio.h>
#include <unistd.h>
void func1(void) { }
void func2(void) { }
void func3(void) { }
void func4(void) { }
void func5(void) { }
int main()
{
printf("func1 %p\n", &func1);
printf("func2 %p\n", &func2);
printf("func3 %p\n", &func3);
printf("func4 %p\n", &func4);
printf("func5 %p\n", &func5);
while (1) {
func1(); func2(); func3(); func4(); func5();
usleep(100000);
}
return 0;
}
# ~acme/c/mem_breakpoint &
[1] 3186153
func1 0x401136
func2 0x40113d
func3 0x401144
func4 0x40114b
func5 0x401152
#
Trying to watch the first 4 functions for eXecutable access:
# perf record -e mem:0x401136:x/name=breakpoint1/,mem:0x40113d:x/name=breakpoint2/,mem:0x401144:x/name=breakpoint3/,mem:0x40114b:x/name=breakpoint4/ -p 3186153 -- sleep 0.5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.026 MB perf.data (20 samples) ]
[root@five ~]# perf script
mem_breakpoint 3186153 131612.864793: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864795: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864796: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864797: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964868: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964870: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964871: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964872: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064945: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064948: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064948: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064949: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165024: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165026: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165027: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165028: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265103: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265105: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265106: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265107: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
#
Then all the 5 functions:
# perf record -e mem:0x401136:x/name=breakpoint1/,mem:0x40113d:x/name=breakpoint2/,mem:0x401144:x/name=breakpoint3/,mem:0x40114b:x/name=breakpoint4/,mem:0x401152:x/name=breakpoint5/ -p 3186153 -- sleep 0.5
Error:
The sys_perf_event_open() syscall returned with 28 (No space left on device) for event (breakpoint5).
/bin/dmesg | grep -i perf may provide additional information.
# grep -m1 'model name' /proc/cpuinfo
model name : AMD Ryzen 9 5950X 16-Core Processor
#
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Link: https://lore.kernel.org/r/20230525082902.25332-2-adrian.hunter@intel.com
Link: https://lore.kernel.org/r/f7228dc9-fe18-a8e3-7d3f-52922e0e1113@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2023-06-12 15:57:53 -03:00