[lkml]   [2021]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] workqueue: doc: Call out the non-reentrance conditions
On Mon, Oct 18, 2021 at 09:31:17AM +0800, Boqun Feng wrote:
> @@ -391,6 +387,23 @@ the stack trace of the offending worker thread. ::
> The work item's function should be trivially visible in the stack
> trace.
> +Non-reentrance Conditions
> +=========================
> +
> +Workqueue guarantees that a work item cannot be re-entrant if the following
> +conditions hold after a work item gets queued:
> +
> + 1. The work function hasn't been changed.
> + 2. No one queues the work item to another workqueue.
> + 3. The work item hasn't been reinitiated.
> +
> +In other words, if the above conditions hold, the work item is guaranteed to be
> +executed by at most one worker system-wide at any given time.
> +
> +Note that requeuing the work item (to the same queue) in the self function
> +doesn't break these conditions, so it's safe to do. Otherwise, caution is
> +required when breaking the conditions inside a work function.
> +

I'd like to suggest that this be added to the Guidelines section

* A work item will not normally be processed on multiple CPUs at the
same time. It can happen if the work function is changed, the work
item is queued to multiple queues or the work function is
reinitialised after being queued.

 \ /
  Last update: 2021-10-18 04:22    [W:0.083 / U:0.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site