All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
	Bill Wendling <morbo@google.com>,
	Chaitanya S Prakash <chaitanyas.prakash@arm.com>,
	Fei Lang <langfei@huawei.com>, Howard Chu <howardchu95@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	James Clark <james.clark@linaro.org>,
	Jiri Olsa <jolsa@kernel.org>,
	Justin Stitt <justinstitt@google.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephen Brennan <stephen.s.brennan@oracle.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/1] Revert "perf thread: Ensure comm_lock held for comm_list"
Date: Wed, 28 May 2025 12:58:54 -0300	[thread overview]
Message-ID: <aDcyvvOKZkRYbjul@x1> (raw)
In-Reply-To: <aDcyVLVpZRui1ole@x1>

Hi Ian,

	This one had hit perf-tools-next, so I'm reverting it till we
figure out, since I'm trying to finish processing patches real soon now
for this window, to give it some time to soak in linux-next.

	I noticed that sometimes when trying to exit 'perf top' it just
sat there, so doing a bisect I ended up on this one, had no time to
properly investigate it.

- Arnaldo

On Wed, May 28, 2025 at 12:57:11PM -0300, Arnaldo Carvalho de Melo wrote:
> 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>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/util/comm.c   |  2 --
>  tools/perf/util/thread.c | 17 ++++-------------
>  tools/perf/util/thread.h |  9 ++++-----
>  3 files changed, 8 insertions(+), 20 deletions(-)
> 
> diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c
> index 9880247a2c3364cb..8aa456d7c2cd2d74 100644
> --- a/tools/perf/util/comm.c
> +++ b/tools/perf/util/comm.c
> @@ -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;
>  
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index c202b98b36c29215..415c0e5d1e751a47 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -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);
>  
> diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
> index 56e08c8ae005e82b..cd574a896418ac94 100644
> --- a/tools/perf/util/thread.h
> +++ b/tools/perf/util/thread.h
> @@ -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)
> -- 
> 2.49.0
> 

  reply	other threads:[~2025-05-28 15:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28 15:57 [PATCH 1/1] Revert "perf thread: Ensure comm_lock held for comm_list" Arnaldo Carvalho de Melo
2025-05-28 15:58 ` Arnaldo Carvalho de Melo [this message]
2025-05-28 17:55   ` 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=aDcyvvOKZkRYbjul@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=chaitanyas.prakash@arm.com \
    --cc=howardchu95@gmail.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kan.liang@linux.intel.com \
    --cc=langfei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=peterz@infradead.org \
    --cc=stephen.s.brennan@oracle.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: link
Be 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.