From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf sched: Factor out destroy_tasks()
Date: Fri, 9 Sep 2022 10:22:53 -0300 [thread overview]
Message-ID: <Yxs+LbaBWrUhLBgw@kernel.org> (raw)
In-Reply-To: <20220908225448.4105056-1-namhyung@kernel.org>
Em Thu, Sep 08, 2022 at 03:54:48PM -0700, Namhyung Kim escreveu:
> Add destroy_tasks() as a counterpart of create_tasks() and put the
> thread safety notations there. After join, it destroys semaphores too.
Thanks, applied.
- Arnaldo
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/builtin-sched.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index a92610eac4bf..f93737eef07b 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -690,6 +690,27 @@ static void create_tasks(struct perf_sched *sched)
> }
> }
>
> +static void destroy_tasks(struct perf_sched *sched)
> + UNLOCK_FUNCTION(sched->start_work_mutex)
> + UNLOCK_FUNCTION(sched->work_done_wait_mutex)
> +{
> + struct task_desc *task;
> + unsigned long i;
> + int err;
> +
> + mutex_unlock(&sched->start_work_mutex);
> + mutex_unlock(&sched->work_done_wait_mutex);
> + /* Get rid of threads so they won't be upset by mutex destrunction */
> + for (i = 0; i < sched->nr_tasks; i++) {
> + task = sched->tasks[i];
> + err = pthread_join(task->thread, NULL);
> + BUG_ON(err);
> + sem_destroy(&task->sleep_sem);
> + sem_destroy(&task->ready_for_work);
> + sem_destroy(&task->work_done_sem);
> + }
> +}
> +
> static void wait_for_tasks(struct perf_sched *sched)
> EXCLUSIVE_LOCKS_REQUIRED(sched->work_done_wait_mutex)
> EXCLUSIVE_LOCKS_REQUIRED(sched->start_work_mutex)
> @@ -3324,8 +3345,7 @@ static int perf_sched__replay(struct perf_sched *sched)
> run_one_test(sched);
>
> sched->thread_funcs_exit = true;
> - mutex_unlock(&sched->start_work_mutex);
> - mutex_unlock(&sched->work_done_wait_mutex);
> + destroy_tasks(sched);
> return 0;
> }
>
> --
> 2.37.2.789.g6183377224-goog
--
- Arnaldo
prev parent reply other threads:[~2022-09-09 13:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 22:54 [PATCH] perf sched: Factor out destroy_tasks() Namhyung Kim
2022-09-09 13:22 ` Arnaldo Carvalho de Melo [this message]
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=Yxs+LbaBWrUhLBgw@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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.