lkml.org 
[lkml]   [2020]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] perf bench: Use condition variables in numa.
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

\
 
 \ /
  Last update: 2020-10-14 13:46    [W:0.062 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site