]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Revert "perf thread: Ensure comm_lock held for comm_list"
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 28 May 2025 15:53:08 +0000 (12:53 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 28 May 2025 15:59:17 +0000 (12:59 -0300)
This reverts commit 8f454c95817d15ee529d58389612ea4b34f5ffb3.

'perf top' is freezing on exit sometimes, bisected to this one, revert.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Chaitanya S Prakash <chaitanyas.prakash@arm.com>
Cc: Fei Lang <langfei@huawei.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Link: https://lore.kernel.org/r/aDcyvvOKZkRYbjul@x1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/comm.c
tools/perf/util/thread.c
tools/perf/util/thread.h

index 9880247a2c3364cbefef3fc3e99d40885eb3c9f1..8aa456d7c2cd2d74f575e61594098cb571199370 100644 (file)
@@ -24,7 +24,6 @@ static struct comm_strs {
 static void comm_strs__remove_if_last(struct comm_str *cs);
 
 static void comm_strs__init(void)
-       NO_THREAD_SAFETY_ANALYSIS /* Inherently single threaded due to pthread_once. */
 {
        init_rwsem(&_comm_strs.lock);
        _comm_strs.capacity = 16;
@@ -120,7 +119,6 @@ static void comm_strs__remove_if_last(struct comm_str *cs)
 }
 
 static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str)
-       SHARED_LOCKS_REQUIRED(comm_strs->lock)
 {
        struct comm_str **result;
 
index c202b98b36c292157b47e79136d66ef6d17f9467..415c0e5d1e751a47b16ae0b622aae2e0bac1f362 100644 (file)
@@ -41,7 +41,6 @@ int thread__init_maps(struct thread *thread, struct machine *machine)
 }
 
 struct thread *thread__new(pid_t pid, pid_t tid)
-       NO_THREAD_SAFETY_ANALYSIS /* Allocation/creation is inherently single threaded. */
 {
        RC_STRUCT(thread) *_thread = zalloc(sizeof(*_thread));
        struct thread *thread;
@@ -203,29 +202,22 @@ int thread__set_namespaces(struct thread *thread, u64 timestamp,
 
 struct comm *thread__comm(struct thread *thread)
 {
-       struct comm *res = NULL;
+       if (list_empty(thread__comm_list(thread)))
+               return NULL;
 
-       down_read(thread__comm_lock(thread));
-       if (!list_empty(thread__comm_list(thread)))
-               res = list_first_entry(thread__comm_list(thread), struct comm, list);
-       up_read(thread__comm_lock(thread));
-       return res;
+       return list_first_entry(thread__comm_list(thread), struct comm, list);
 }
 
 struct comm *thread__exec_comm(struct thread *thread)
 {
        struct comm *comm, *last = NULL, *second_last = NULL;
 
-       down_read(thread__comm_lock(thread));
        list_for_each_entry(comm, thread__comm_list(thread), list) {
-               if (comm->exec) {
-                       up_read(thread__comm_lock(thread));
+               if (comm->exec)
                        return comm;
-               }
                second_last = last;
                last = comm;
        }
-       up_read(thread__comm_lock(thread));
 
        /*
         * 'last' with no start time might be the parent's comm of a synthesized
@@ -241,7 +233,6 @@ struct comm *thread__exec_comm(struct thread *thread)
 
 static int ____thread__set_comm(struct thread *thread, const char *str,
                                u64 timestamp, bool exec)
-       EXCLUSIVE_LOCKS_REQUIRED(thread__comm_lock(thread))
 {
        struct comm *new, *curr = thread__comm(thread);
 
index 56e08c8ae005e82b4a934505ea25f27fab9bae67..cd574a896418ac9497a8544c8417c3aa6fa86ae6 100644 (file)
@@ -236,15 +236,14 @@ static inline struct rw_semaphore *thread__namespaces_lock(struct thread *thread
        return &RC_CHK_ACCESS(thread)->namespaces_lock;
 }
 
-static inline struct rw_semaphore *thread__comm_lock(struct thread *thread)
+static inline struct list_head *thread__comm_list(struct thread *thread)
 {
-       return &RC_CHK_ACCESS(thread)->comm_lock;
+       return &RC_CHK_ACCESS(thread)->comm_list;
 }
 
-static inline struct list_head *thread__comm_list(struct thread *thread)
-       SHARED_LOCKS_REQUIRED(thread__comm_lock(thread))
+static inline struct rw_semaphore *thread__comm_lock(struct thread *thread)
 {
-       return &RC_CHK_ACCESS(thread)->comm_list;
+       return &RC_CHK_ACCESS(thread)->comm_lock;
 }
 
 static inline u64 thread__db_id(const struct thread *thread)