lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YREZ65Jw9J5bB68u@krava>
Date:   Mon, 9 Aug 2021 14:04:59 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Riccardo Mancini <rickyman7@...il.com>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ian Rogers <irogers@...gle.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
Subject: Re: [RFC PATCH v2 06/10] perf workqueue: introduce workqueue struct

On Fri, Jul 30, 2021 at 05:34:13PM +0200, Riccardo Mancini wrote:

SNIP

> +static void worker_thread(int tidx, struct task_struct *task)
> +{
> +
> +	pr_info("Hi from worker %d, executing task %p\n", tidx, task);
> +}
> +
> +/**
> + * attach_threadpool_to_workqueue - start @wq workers on @pool
> + */
> +static int attach_threadpool_to_workqueue(struct workqueue_struct *wq,
> +					struct threadpool *pool)
> +{
> +	if (!threadpool__is_ready(pool)) {
> +		pr_debug2("workqueue: cannot attach to pool: pool is not ready\n");
> +		return -WORKQUEUE_ERROR__NOTALLOWED;
> +	}
> +
> +	wq->pool = pool;
> +
> +	wq->pool_errno = threadpool__execute(pool, &wq->task);
> +	if (wq->pool_errno)
> +		return -WORKQUEUE_ERROR__POOLEXE;

SNIP

> +
> +/**
> + * create_workqueue - create a workqueue associated to @pool
> + *
> + * Only one workqueue can execute on a pool at a time.
> + */
> +struct workqueue_struct *create_workqueue(struct threadpool *pool)
> +{
> +	int ret, err = 0;
> +	struct workqueue_struct *wq = malloc(sizeof(struct workqueue_struct));
> +
> +	if (!wq) {
> +		err = -ENOMEM;
> +		goto out_return;
> +	}
> +
> +	ret = pthread_mutex_init(&wq->lock, NULL);
> +	if (ret) {
> +		err = -ret;
> +		goto out_free_wq;
> +	}
> +
> +	ret = pthread_cond_init(&wq->idle_cond, NULL);
> +	if (ret) {
> +		err = -ret;
> +		goto out_destroy_mutex;
> +	}
> +
> +	wq->pool = NULL;
> +	INIT_LIST_HEAD(&wq->busy_list);
> +	INIT_LIST_HEAD(&wq->idle_list);
> +
> +	INIT_LIST_HEAD(&wq->pending);
> +
> +	ret = pipe(wq->msg_pipe);
> +	if (ret) {
> +		err = -ENOMEM;
> +		goto out_destroy_cond;
> +	}
> +
> +	wq->task.fn = worker_thread;
> +
> +	ret = attach_threadpool_to_workqueue(wq, pool);
> +	if (ret) {
> +		err = ret;
> +		goto out_destroy_cond;
> +	}
> +
> +	wq->status = WORKQUEUE_STATUS__READY;
> +
> +	return wq;
> +
> +out_destroy_cond:
> +	pthread_cond_destroy(&wq->idle_cond);

leaking wq->msg_pipe?

thanks,
jirka

> +out_destroy_mutex:
> +	pthread_mutex_destroy(&wq->lock);
> +out_free_wq:
> +	free(wq);
> +out_return:
> +	return ERR_PTR(err);
> +}
> +


SNIP

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ