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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080613144605.GB9147@tv-sign.ru>
Date:	Fri, 13 Jun 2008 18:46:05 +0400
From:	Oleg Nesterov <oleg@...sign.ru>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Jarek Poplawski <jarkao2@...pl>,
	Max Krasnyansky <maxk@...lcomm.com>,
	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] workqueues: implement flush_work()

On 06/13, Oleg Nesterov wrote:
>
> Add the new helper, flush_work(work), which waits for the completion of the
> specific work_struct.
>
> By its nature it requires that this work must not be re-queued, and thus its
> usage is limited. For example, this code
>
> 	queue_work(wq, work);
> 	/* WINDOW */
> 	queue_work(wq, work);
>
> 	flush_work(work);
>
> is not right. What can happen in the WINDOW above is
>
> 	- wq starts the execution of work->func()
>
> 	- the caller migrates to another CPU
>
> now, after the 2nd queue_work() this work is active on the previous CPU, and
> at the same time it is queued on another.

To clarify, in the scenario above, flush_work() behaves correctly. It "flushes"
the result of the last queue_work() which is visible to the caller. We can add
another simple helper,

	int flush_work_sync(work)
	{
		return flush_work(work) || wait_on_work(work);
	}

but I think it is not needed.

In short: flush_work() should be use with care when it is really needed.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ