From: Ian Rogers <irogers@google.com> To: "John Garry" <john.g.garry@oracle.com>, "Will Deacon" <will@kernel.org>, "James Clark" <james.clark@arm.com>, "Mike Leach" <mike.leach@linaro.org>, "Leo Yan" <leo.yan@linaro.org>, "Peter Zijlstra" <peterz@infradead.org>, "Ingo Molnar" <mingo@redhat.com>, "Arnaldo Carvalho de Melo" <acme@kernel.org>, "Mark Rutland" <mark.rutland@arm.com>, "Alexander Shishkin" <alexander.shishkin@linux.intel.com>, "Jiri Olsa" <jolsa@kernel.org>, "Namhyung Kim" <namhyung@kernel.org>, "Ian Rogers" <irogers@google.com>, "Adrian Hunter" <adrian.hunter@intel.com>, "Suzuki K Poulose" <suzuki.poulose@arm.com>, "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>, "Kan Liang" <kan.liang@linux.intel.com>, "German Gomez" <german.gomez@arm.com>, "Ali Saidi" <alisaidi@amazon.com>, "Jing Zhang" <renyu.zj@linux.alibaba.com>, "Martin Liška" <mliska@suse.cz>, "Athira Rajeev" <atrajeev@linux.vnet.ibm.com>, "Miguel Ojeda" <ojeda@kernel.org>, "ye xingchen" <ye.xingchen@zte.com.cn>, "Liam Howlett" <liam.howlett@oracle.com>, "Dmitrii Dolgov" <9erthalion6@gmail.com>, "Shawn M. Chapla" <schapla@codeweavers.com>, "Yang Jihong" <yangjihong1@huawei.com>, "K Prateek Nayak" <kprateek.nayak@amd.com>, "Changbin Du" <changbin.du@huawei.com>, "Ravi Bangoria" <ravi.bangoria@amd.com>, "Sean Christopherson" <seanjc@google.com>, "Raul Silvera" <rsilvera@google.com>, "Andi Kleen" <ak@linux.intel.com>, "Steinar H. Gunderson" <sesse@google.com>, "Yuan Can" <yuancan@huawei.com>, "Brian Robbins" <brianrob@linux.microsoft.com>, liuwenyu <liuwenyu7@huawei.com>, "Ivan Babrou" <ivan@cloudflare.com>, "Fangrui Song" <maskray@google.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org Subject: [PATCH v1 00/20] Reference count checking for thread Date: Tue, 6 Jun 2023 18:43:33 -0700 [thread overview] Message-ID: <20230607014353.3172466-1-irogers@google.com> (raw) Add reference count checking to thread after first refactoring bits of the code, such as making the thread red-black tree non-invasive (so the thread it references is easier to reference count, rather than having 3 potential references). Part of this refactoring also removes the dead thread list because if we held a reference here the threads would never die and anything else has questionable correctness. addr_location is made into its own C/header file to capture the init, exit and copy code. Fix additional outstanding memory leak and reference count issues to the point that "perf test" compiled with address sanitizer but without libtraceevent passes all but one test - libtraceevent reports leaks within its own code, most likely as it isn't compiled with sanitizers. The remaining failing test is "68: Test dwarf unwind" and that has address sanitizer issues as it uses memcpy to access the stack within the process - we likely want to skip parts of the test with sanitizers enabled. Ian Rogers (20): perf thread: Remove notion of dead threads perf thread: Make threads rbtree non-invasive perf thread: Add accessor functions for thread perf maps: Make delete static, always use put perf addr_location: Move to its own header perf addr_location: Add init/exit/copy functions perf thread: Add reference count checking perf machine: Make delete_threads part of machine__exit perf report: Avoid thread leak perf header: Ensure bitmaps are freed perf stat: Avoid evlist leak perf intel-pt: Fix missed put and leak perf evlist: Free stats in all evlist destruction perf python: Avoid 2 leak sanitizer issues perf jit: Fix two thread leaks perf symbol-elf: Correct holding a reference perf maps: Fix overlapping memory leak perf machine: Fix leak of kernel dso perf machine: Don't leak module maps perf map/maps/thread: Changes to reference counting tools/perf/arch/arm/tests/dwarf-unwind.c | 2 +- tools/perf/arch/arm64/tests/dwarf-unwind.c | 2 +- tools/perf/arch/powerpc/tests/dwarf-unwind.c | 2 +- tools/perf/arch/x86/tests/dwarf-unwind.c | 2 +- tools/perf/builtin-annotate.c | 28 +- tools/perf/builtin-c2c.c | 18 +- tools/perf/builtin-diff.c | 16 +- tools/perf/builtin-inject.c | 4 +- tools/perf/builtin-kmem.c | 13 +- tools/perf/builtin-kwork.c | 15 +- tools/perf/builtin-mem.c | 4 +- tools/perf/builtin-report.c | 21 +- tools/perf/builtin-sched.c | 80 +++-- tools/perf/builtin-script.c | 97 +++--- tools/perf/builtin-stat.c | 1 + tools/perf/builtin-timechart.c | 11 +- tools/perf/builtin-top.c | 8 +- tools/perf/builtin-trace.c | 38 ++- .../scripts/python/Perf-Trace-Util/Context.c | 4 +- tools/perf/tests/code-reading.c | 6 +- tools/perf/tests/dwarf-unwind.c | 1 - tools/perf/tests/hists_common.c | 2 +- tools/perf/tests/hists_cumulate.c | 18 +- tools/perf/tests/hists_filter.c | 11 +- tools/perf/tests/hists_link.c | 20 +- tools/perf/tests/hists_output.c | 12 +- tools/perf/tests/maps.c | 2 +- tools/perf/tests/mmap-thread-lookup.c | 5 +- tools/perf/tests/perf-targz-src-pkg | 5 +- tools/perf/tests/symbols.c | 1 - tools/perf/tests/thread-maps-share.c | 13 +- tools/perf/trace/beauty/pid.c | 4 +- tools/perf/ui/browsers/hists.c | 19 +- tools/perf/ui/hist.c | 5 +- tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/Build | 1 + tools/perf/util/addr_location.c | 44 +++ tools/perf/util/addr_location.h | 31 ++ tools/perf/util/arm-spe.c | 4 +- tools/perf/util/build-id.c | 2 + tools/perf/util/callchain.c | 7 +- tools/perf/util/cs-etm.c | 28 +- tools/perf/util/data-convert-json.c | 16 +- tools/perf/util/db-export.c | 20 +- tools/perf/util/dlfilter.c | 17 +- tools/perf/util/event.c | 37 +-- tools/perf/util/evlist.c | 2 + tools/perf/util/evsel_fprintf.c | 8 +- tools/perf/util/header.c | 12 +- tools/perf/util/hist.c | 22 +- tools/perf/util/intel-bts.c | 2 +- tools/perf/util/intel-pt.c | 88 +++--- tools/perf/util/jitdump.c | 12 +- tools/perf/util/machine.c | 277 +++++++++--------- tools/perf/util/map.c | 2 +- tools/perf/util/maps.c | 5 +- tools/perf/util/maps.h | 9 +- tools/perf/util/python.c | 4 + .../scripting-engines/trace-event-python.c | 28 +- tools/perf/util/session.c | 8 +- tools/perf/util/sort.c | 12 +- tools/perf/util/symbol-elf.c | 4 +- tools/perf/util/symbol.h | 17 +- tools/perf/util/thread-stack.c | 25 +- tools/perf/util/thread.c | 218 +++++++------- tools/perf/util/thread.h | 210 +++++++++++-- tools/perf/util/unwind-libdw.c | 27 +- tools/perf/util/unwind-libunwind-local.c | 19 +- tools/perf/util/unwind-libunwind.c | 2 +- tools/perf/util/vdso.c | 2 +- 70 files changed, 1059 insertions(+), 655 deletions(-) create mode 100644 tools/perf/util/addr_location.c create mode 100644 tools/perf/util/addr_location.h -- 2.41.0.rc0.172.g3f132b7071-goog
WARNING: multiple messages have this Message-ID (diff)
From: Ian Rogers <irogers@google.com> To: "John Garry" <john.g.garry@oracle.com>, "Will Deacon" <will@kernel.org>, "James Clark" <james.clark@arm.com>, "Mike Leach" <mike.leach@linaro.org>, "Leo Yan" <leo.yan@linaro.org>, "Peter Zijlstra" <peterz@infradead.org>, "Ingo Molnar" <mingo@redhat.com>, "Arnaldo Carvalho de Melo" <acme@kernel.org>, "Mark Rutland" <mark.rutland@arm.com>, "Alexander Shishkin" <alexander.shishkin@linux.intel.com>, "Jiri Olsa" <jolsa@kernel.org>, "Namhyung Kim" <namhyung@kernel.org>, "Ian Rogers" <irogers@google.com>, "Adrian Hunter" <adrian.hunter@intel.com>, "Suzuki K Poulose" <suzuki.poulose@arm.com>, "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>, "Kan Liang" <kan.liang@linux.intel.com>, "German Gomez" <german.gomez@arm.com>, "Ali Saidi" <alisaidi@amazon.com>, "Jing Zhang" <renyu.zj@linux.alibaba.com>, "Martin Liška" <mliska@suse.cz>, "Athira Rajeev" <atrajeev@linux.vnet.ibm.com>, "Miguel Ojeda" <ojeda@kernel.org>, "ye xingchen" <ye.xingchen@zte.com.cn>, "Liam Howlett" <liam.howlett@oracle.com>, "Dmitrii Dolgov" <9erthalion6@gmail.com>, "Shawn M. Chapla" <schapla@codeweavers.com>, "Yang Jihong" <yangjihong1@huawei.com>, "K Prateek Nayak" <kprateek.nayak@amd.com>, "Changbin Du" <changbin.du@huawei.com>, "Ravi Bangoria" <ravi.bangoria@amd.com>, "Sean Christopherson" <seanjc@google.com>, "Raul Silvera" <rsilvera@google.com>, "Andi Kleen" <ak@linux.intel.com>, "Steinar H. Gunderson" <sesse@google.com>, "Yuan Can" <yuancan@huawei.com>, "Brian Robbins" <brianrob@linux.microsoft.com>, liuwenyu <liuwenyu7@huawei.com>, "Ivan Babrou" <ivan@cloudflare.com>, "Fangrui Song" <maskray@google.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org Subject: [PATCH v1 00/20] Reference count checking for thread Date: Tue, 6 Jun 2023 18:43:33 -0700 [thread overview] Message-ID: <20230607014353.3172466-1-irogers@google.com> (raw) Add reference count checking to thread after first refactoring bits of the code, such as making the thread red-black tree non-invasive (so the thread it references is easier to reference count, rather than having 3 potential references). Part of this refactoring also removes the dead thread list because if we held a reference here the threads would never die and anything else has questionable correctness. addr_location is made into its own C/header file to capture the init, exit and copy code. Fix additional outstanding memory leak and reference count issues to the point that "perf test" compiled with address sanitizer but without libtraceevent passes all but one test - libtraceevent reports leaks within its own code, most likely as it isn't compiled with sanitizers. The remaining failing test is "68: Test dwarf unwind" and that has address sanitizer issues as it uses memcpy to access the stack within the process - we likely want to skip parts of the test with sanitizers enabled. Ian Rogers (20): perf thread: Remove notion of dead threads perf thread: Make threads rbtree non-invasive perf thread: Add accessor functions for thread perf maps: Make delete static, always use put perf addr_location: Move to its own header perf addr_location: Add init/exit/copy functions perf thread: Add reference count checking perf machine: Make delete_threads part of machine__exit perf report: Avoid thread leak perf header: Ensure bitmaps are freed perf stat: Avoid evlist leak perf intel-pt: Fix missed put and leak perf evlist: Free stats in all evlist destruction perf python: Avoid 2 leak sanitizer issues perf jit: Fix two thread leaks perf symbol-elf: Correct holding a reference perf maps: Fix overlapping memory leak perf machine: Fix leak of kernel dso perf machine: Don't leak module maps perf map/maps/thread: Changes to reference counting tools/perf/arch/arm/tests/dwarf-unwind.c | 2 +- tools/perf/arch/arm64/tests/dwarf-unwind.c | 2 +- tools/perf/arch/powerpc/tests/dwarf-unwind.c | 2 +- tools/perf/arch/x86/tests/dwarf-unwind.c | 2 +- tools/perf/builtin-annotate.c | 28 +- tools/perf/builtin-c2c.c | 18 +- tools/perf/builtin-diff.c | 16 +- tools/perf/builtin-inject.c | 4 +- tools/perf/builtin-kmem.c | 13 +- tools/perf/builtin-kwork.c | 15 +- tools/perf/builtin-mem.c | 4 +- tools/perf/builtin-report.c | 21 +- tools/perf/builtin-sched.c | 80 +++-- tools/perf/builtin-script.c | 97 +++--- tools/perf/builtin-stat.c | 1 + tools/perf/builtin-timechart.c | 11 +- tools/perf/builtin-top.c | 8 +- tools/perf/builtin-trace.c | 38 ++- .../scripts/python/Perf-Trace-Util/Context.c | 4 +- tools/perf/tests/code-reading.c | 6 +- tools/perf/tests/dwarf-unwind.c | 1 - tools/perf/tests/hists_common.c | 2 +- tools/perf/tests/hists_cumulate.c | 18 +- tools/perf/tests/hists_filter.c | 11 +- tools/perf/tests/hists_link.c | 20 +- tools/perf/tests/hists_output.c | 12 +- tools/perf/tests/maps.c | 2 +- tools/perf/tests/mmap-thread-lookup.c | 5 +- tools/perf/tests/perf-targz-src-pkg | 5 +- tools/perf/tests/symbols.c | 1 - tools/perf/tests/thread-maps-share.c | 13 +- tools/perf/trace/beauty/pid.c | 4 +- tools/perf/ui/browsers/hists.c | 19 +- tools/perf/ui/hist.c | 5 +- tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/Build | 1 + tools/perf/util/addr_location.c | 44 +++ tools/perf/util/addr_location.h | 31 ++ tools/perf/util/arm-spe.c | 4 +- tools/perf/util/build-id.c | 2 + tools/perf/util/callchain.c | 7 +- tools/perf/util/cs-etm.c | 28 +- tools/perf/util/data-convert-json.c | 16 +- tools/perf/util/db-export.c | 20 +- tools/perf/util/dlfilter.c | 17 +- tools/perf/util/event.c | 37 +-- tools/perf/util/evlist.c | 2 + tools/perf/util/evsel_fprintf.c | 8 +- tools/perf/util/header.c | 12 +- tools/perf/util/hist.c | 22 +- tools/perf/util/intel-bts.c | 2 +- tools/perf/util/intel-pt.c | 88 +++--- tools/perf/util/jitdump.c | 12 +- tools/perf/util/machine.c | 277 +++++++++--------- tools/perf/util/map.c | 2 +- tools/perf/util/maps.c | 5 +- tools/perf/util/maps.h | 9 +- tools/perf/util/python.c | 4 + .../scripting-engines/trace-event-python.c | 28 +- tools/perf/util/session.c | 8 +- tools/perf/util/sort.c | 12 +- tools/perf/util/symbol-elf.c | 4 +- tools/perf/util/symbol.h | 17 +- tools/perf/util/thread-stack.c | 25 +- tools/perf/util/thread.c | 218 +++++++------- tools/perf/util/thread.h | 210 +++++++++++-- tools/perf/util/unwind-libdw.c | 27 +- tools/perf/util/unwind-libunwind-local.c | 19 +- tools/perf/util/unwind-libunwind.c | 2 +- tools/perf/util/vdso.c | 2 +- 70 files changed, 1059 insertions(+), 655 deletions(-) create mode 100644 tools/perf/util/addr_location.c create mode 100644 tools/perf/util/addr_location.h -- 2.41.0.rc0.172.g3f132b7071-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-06-07 1:44 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-07 1:43 Ian Rogers [this message] 2023-06-07 1:43 ` [PATCH v1 00/20] Reference count checking for thread Ian Rogers 2023-06-07 1:43 ` [PATCH v1 01/20] perf thread: Remove notion of dead threads Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 02/20] perf thread: Make threads rbtree non-invasive Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 03/20] perf thread: Add accessor functions for thread Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 04/20] perf maps: Make delete static, always use put Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 05/20] perf addr_location: Move to its own header Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 06/20] perf addr_location: Add init/exit/copy functions Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 07/20] perf thread: Add reference count checking Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 08/20] perf machine: Make delete_threads part of machine__exit Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 09/20] perf report: Avoid thread leak Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 10/20] perf header: Ensure bitmaps are freed Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 11/20] perf stat: Avoid evlist leak Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 12/20] perf intel-pt: Fix missed put and leak Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 13/20] perf evlist: Free stats in all evlist destruction Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 14/20] perf python: Avoid 2 leak sanitizer issues Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 15/20] perf jit: Fix two thread leaks Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 16/20] perf symbol-elf: Correct holding a reference Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 17/20] perf maps: Fix overlapping memory leak Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 18/20] perf machine: Fix leak of kernel dso Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 19/20] perf machine: Don't leak module maps Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 1:43 ` [PATCH v1 20/20] perf map/maps/thread: Changes to reference counting Ian Rogers 2023-06-07 1:43 ` Ian Rogers 2023-06-07 7:07 ` [PATCH v1 00/20] Reference count checking for thread Ian Rogers 2023-06-07 7:07 ` Ian Rogers
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230607014353.3172466-1-irogers@google.com \ --to=irogers@google.com \ --cc=9erthalion6@gmail.com \ --cc=acme@kernel.org \ --cc=adrian.hunter@intel.com \ --cc=ak@linux.intel.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=alisaidi@amazon.com \ --cc=atrajeev@linux.vnet.ibm.com \ --cc=brianrob@linux.microsoft.com \ --cc=changbin.du@huawei.com \ --cc=coresight@lists.linaro.org \ --cc=german.gomez@arm.com \ --cc=ivan@cloudflare.com \ --cc=james.clark@arm.com \ --cc=john.g.garry@oracle.com \ --cc=jolsa@kernel.org \ --cc=kan.liang@linux.intel.com \ --cc=kprateek.nayak@amd.com \ --cc=leo.yan@linaro.org \ --cc=liam.howlett@oracle.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-perf-users@vger.kernel.org \ --cc=liuwenyu7@huawei.com \ --cc=mark.rutland@arm.com \ --cc=maskray@google.com \ --cc=mike.leach@linaro.org \ --cc=mingo@redhat.com \ --cc=mliska@suse.cz \ --cc=namhyung@kernel.org \ --cc=naveen.n.rao@linux.vnet.ibm.com \ --cc=ojeda@kernel.org \ --cc=peterz@infradead.org \ --cc=ravi.bangoria@amd.com \ --cc=renyu.zj@linux.alibaba.com \ --cc=rsilvera@google.com \ --cc=schapla@codeweavers.com \ --cc=seanjc@google.com \ --cc=sesse@google.com \ --cc=suzuki.poulose@arm.com \ --cc=will@kernel.org \ --cc=yangjihong1@huawei.com \ --cc=ye.xingchen@zte.com.cn \ --cc=yuancan@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.