diff options
author | Ian Rogers <irogers@google.com> | 2024-03-01 06:36:42 +0100 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2024-03-04 07:51:44 +0100 |
commit | d436f90a64f3e6b47464acc7821ce2b8a515a2ae (patch) | |
tree | 7e9cf55f7ffe4d9e0ea2b8e152469b8bc6f69820 /tools/perf/util/thread.h | |
parent | perf machine: Move fprintf to for_each loop and a callback (diff) | |
download | linux-d436f90a64f3e6b47464acc7821ce2b8a515a2ae.tar.xz linux-d436f90a64f3e6b47464acc7821ce2b8a515a2ae.zip |
perf machine: Move machine's threads into its own abstraction
Move thread_rb_node into the machine.c file. This hides the
implementation of threads from the rest of the code allowing for it to
be refactored.
Locking discipline is tightened up in this change. As the lock is now
encapsulated in threads, the findnew function requires holding it (as
it already did in machine). Rather than do conditionals with locks
based on whether the thread should be created (which could potentially
be error prone with a read lock match with a write unlock), have a
separate threads__find that won't create the thread and only holds the
read lock. This effectively duplicates the findnew logic, with the
existing findnew logic only operating under a write lock assuming
creation is necessary as a previous find failed. The creation may
still fail with the write lock due to another thread. The duplication
is removed in a later next patch that delegates the implementation to
hashtable.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240301053646.1449657-5-irogers@google.com
Diffstat (limited to 'tools/perf/util/thread.h')
-rw-r--r-- | tools/perf/util/thread.h | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index df344262eaee..8b4a3c69bad1 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -3,7 +3,6 @@ #define __PERF_THREAD_H #include <linux/refcount.h> -#include <linux/rbtree.h> #include <linux/list.h> #include <stdio.h> #include <unistd.h> @@ -29,11 +28,6 @@ struct lbr_stitch { struct callchain_cursor_node *prev_lbr_cursor; }; -struct thread_rb_node { - struct rb_node rb_node; - struct thread *thread; -}; - DECLARE_RC_STRUCT(thread) { /** @maps: mmaps associated with this thread. */ struct maps *maps; |