Skip to content

Commit 24bcc31

Browse files
committed
Revert "perf thread: Ensure comm_lock held for comm_list"
This reverts commit 8f454c9. '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>
1 parent 6dd7a0f commit 24bcc31

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

tools/perf/util/comm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ static struct comm_strs {
2424
static void comm_strs__remove_if_last(struct comm_str *cs);
2525

2626
static void comm_strs__init(void)
27-
NO_THREAD_SAFETY_ANALYSIS /* Inherently single threaded due to pthread_once. */
2827
{
2928
init_rwsem(&_comm_strs.lock);
3029
_comm_strs.capacity = 16;
@@ -120,7 +119,6 @@ static void comm_strs__remove_if_last(struct comm_str *cs)
120119
}
121120

122121
static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str)
123-
SHARED_LOCKS_REQUIRED(comm_strs->lock)
124122
{
125123
struct comm_str **result;
126124

tools/perf/util/thread.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ int thread__init_maps(struct thread *thread, struct machine *machine)
4141
}
4242

4343
struct thread *thread__new(pid_t pid, pid_t tid)
44-
NO_THREAD_SAFETY_ANALYSIS /* Allocation/creation is inherently single threaded. */
4544
{
4645
RC_STRUCT(thread) *_thread = zalloc(sizeof(*_thread));
4746
struct thread *thread;
@@ -203,29 +202,22 @@ int thread__set_namespaces(struct thread *thread, u64 timestamp,
203202

204203
struct comm *thread__comm(struct thread *thread)
205204
{
206-
struct comm *res = NULL;
205+
if (list_empty(thread__comm_list(thread)))
206+
return NULL;
207207

208-
down_read(thread__comm_lock(thread));
209-
if (!list_empty(thread__comm_list(thread)))
210-
res = list_first_entry(thread__comm_list(thread), struct comm, list);
211-
up_read(thread__comm_lock(thread));
212-
return res;
208+
return list_first_entry(thread__comm_list(thread), struct comm, list);
213209
}
214210

215211
struct comm *thread__exec_comm(struct thread *thread)
216212
{
217213
struct comm *comm, *last = NULL, *second_last = NULL;
218214

219-
down_read(thread__comm_lock(thread));
220215
list_for_each_entry(comm, thread__comm_list(thread), list) {
221-
if (comm->exec) {
222-
up_read(thread__comm_lock(thread));
216+
if (comm->exec)
223217
return comm;
224-
}
225218
second_last = last;
226219
last = comm;
227220
}
228-
up_read(thread__comm_lock(thread));
229221

230222
/*
231223
* '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)
241233

242234
static int ____thread__set_comm(struct thread *thread, const char *str,
243235
u64 timestamp, bool exec)
244-
EXCLUSIVE_LOCKS_REQUIRED(thread__comm_lock(thread))
245236
{
246237
struct comm *new, *curr = thread__comm(thread);
247238

tools/perf/util/thread.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,14 @@ static inline struct rw_semaphore *thread__namespaces_lock(struct thread *thread
236236
return &RC_CHK_ACCESS(thread)->namespaces_lock;
237237
}
238238

239-
static inline struct rw_semaphore *thread__comm_lock(struct thread *thread)
239+
static inline struct list_head *thread__comm_list(struct thread *thread)
240240
{
241-
return &RC_CHK_ACCESS(thread)->comm_lock;
241+
return &RC_CHK_ACCESS(thread)->comm_list;
242242
}
243243

244-
static inline struct list_head *thread__comm_list(struct thread *thread)
245-
SHARED_LOCKS_REQUIRED(thread__comm_lock(thread))
244+
static inline struct rw_semaphore *thread__comm_lock(struct thread *thread)
246245
{
247-
return &RC_CHK_ACCESS(thread)->comm_list;
246+
return &RC_CHK_ACCESS(thread)->comm_lock;
248247
}
249248

250249
static inline u64 thread__db_id(const struct thread *thread)

0 commit comments

Comments
 (0)