Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "perf thread: Ensure comm_lock held for comm_list"

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>

+9 -21
-2
tools/perf/util/comm.c
··· 24 24 static void comm_strs__remove_if_last(struct comm_str *cs); 25 25 26 26 static void comm_strs__init(void) 27 - NO_THREAD_SAFETY_ANALYSIS /* Inherently single threaded due to pthread_once. */ 28 27 { 29 28 init_rwsem(&_comm_strs.lock); 30 29 _comm_strs.capacity = 16; ··· 119 120 } 120 121 121 122 static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str) 122 - SHARED_LOCKS_REQUIRED(comm_strs->lock) 123 123 { 124 124 struct comm_str **result; 125 125
+4 -13
tools/perf/util/thread.c
··· 41 41 } 42 42 43 43 struct thread *thread__new(pid_t pid, pid_t tid) 44 - NO_THREAD_SAFETY_ANALYSIS /* Allocation/creation is inherently single threaded. */ 45 44 { 46 45 RC_STRUCT(thread) *_thread = zalloc(sizeof(*_thread)); 47 46 struct thread *thread; ··· 202 203 203 204 struct comm *thread__comm(struct thread *thread) 204 205 { 205 - struct comm *res = NULL; 206 + if (list_empty(thread__comm_list(thread))) 207 + return NULL; 206 208 207 - down_read(thread__comm_lock(thread)); 208 - if (!list_empty(thread__comm_list(thread))) 209 - res = list_first_entry(thread__comm_list(thread), struct comm, list); 210 - up_read(thread__comm_lock(thread)); 211 - return res; 209 + return list_first_entry(thread__comm_list(thread), struct comm, list); 212 210 } 213 211 214 212 struct comm *thread__exec_comm(struct thread *thread) 215 213 { 216 214 struct comm *comm, *last = NULL, *second_last = NULL; 217 215 218 - down_read(thread__comm_lock(thread)); 219 216 list_for_each_entry(comm, thread__comm_list(thread), list) { 220 - if (comm->exec) { 221 - up_read(thread__comm_lock(thread)); 217 + if (comm->exec) 222 218 return comm; 223 - } 224 219 second_last = last; 225 220 last = comm; 226 221 } 227 - up_read(thread__comm_lock(thread)); 228 222 229 223 /* 230 224 * 'last' with no start time might be the parent's comm of a synthesized ··· 233 241 234 242 static int ____thread__set_comm(struct thread *thread, const char *str, 235 243 u64 timestamp, bool exec) 236 - EXCLUSIVE_LOCKS_REQUIRED(thread__comm_lock(thread)) 237 244 { 238 245 struct comm *new, *curr = thread__comm(thread); 239 246
+5 -6
tools/perf/util/thread.h
··· 236 236 return &RC_CHK_ACCESS(thread)->namespaces_lock; 237 237 } 238 238 239 + static inline struct list_head *thread__comm_list(struct thread *thread) 240 + { 241 + return &RC_CHK_ACCESS(thread)->comm_list; 242 + } 243 + 239 244 static inline struct rw_semaphore *thread__comm_lock(struct thread *thread) 240 245 { 241 246 return &RC_CHK_ACCESS(thread)->comm_lock; 242 - } 243 - 244 - static inline struct list_head *thread__comm_list(struct thread *thread) 245 - SHARED_LOCKS_REQUIRED(thread__comm_lock(thread)) 246 - { 247 - return &RC_CHK_ACCESS(thread)->comm_list; 248 247 } 249 248 250 249 static inline u64 thread__db_id(const struct thread *thread)