public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Peng Fan <fanpeng@loongson.cn>,
	linux-kernel@vger.kernel.org,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v2] perf bench: Use condition variables in numa.
Date: Wed, 14 Oct 2020 13:45:00 +0200	[thread overview]
Message-ID: <20201014114500.GB1375972@krava> (raw)
In-Reply-To: <20201012161611.366482-1-irogers@google.com>

On Mon, Oct 12, 2020 at 09:16:11AM -0700, Ian Rogers wrote:

SNIP

> @@ -483,6 +484,18 @@ static void init_global_mutex(pthread_mutex_t *mutex)
>  	pthread_mutex_init(mutex, &attr);
>  }
>  
> +/*
> + * Return a process-shared (global) condition variable:
> + */
> +static void init_global_cond(pthread_cond_t *cond)
> +{
> +	pthread_condattr_t attr;
> +
> +	pthread_condattr_init(&attr);
> +	pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
> +	pthread_cond_init(cond, &attr);
> +}
> +
>  static int parse_cpu_list(const char *arg)
>  {
>  	p0.cpu_list_str = strdup(arg);
> @@ -1136,15 +1149,18 @@ static void *worker_thread(void *__tdata)
>  	if (g->p.serialize_startup) {
>  		pthread_mutex_lock(&g->startup_mutex);
>  		g->nr_tasks_started++;
> +		/* The last thread wakes the main process. */
> +		if (g->nr_tasks_started == g->p.nr_tasks)
> +			pthread_cond_signal(&g->startup_cond);

should you remove the condition? it's not necessary
and making this racy, no?

just single pthread_cond_signal should be enough,
because the wait code is checking the number of tasks

jirka


  reply	other threads:[~2020-10-14 11:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12 16:16 [PATCH v2] perf bench: Use condition variables in numa Ian Rogers
2020-10-14 11:45 ` Jiri Olsa [this message]
2020-10-14 15:39   ` Ian Rogers
2020-10-14 16:14     ` Jiri Olsa
2020-10-14 17:27       ` Arnaldo Carvalho de Melo

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=20201014114500.GB1375972@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=fanpeng@loongson.cn \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox