lkml.org 
[lkml]   [2017]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 01/11] workqueue: Add a decrement-after-return and wake if 0 facility
Hello, David.

On Fri, Sep 01, 2017 at 04:40:53PM +0100, David Howells wrote:
> Add a facility to the workqueue subsystem whereby an atomic_t can be
> registered by a work function such that the work function dispatcher will
> decrement the atomic after the work function has returned and then call
> wake_up_atomic() on it if it reached 0.
>
> This is analogous to complete_and_exit() for kernel threads and is used to
> avoid a race between notifying that a work item is about to finish and the
> .text segment from a module being discarded.
>
> The way this is used is that the work function calls:
>
> dec_after_work(atomic_t *counter);
>
> to register the counter and then process_one_work() calls it, potentially
> wakes it and clears the registration.
>
> The reason I've used an atomic_t rather than a completion is that (1) it
> takes up less space and (2) it can monitor multiple objects.

Given how work items are used, I think this is too inviting to abuses
where people build complex event chains through these counters and
those chains would be completely opaque. If the goal is protecting
.text of a work item, can't we just do that? Can you please describe
your use case in more detail? Why can't it be done via the usual
"flush from exit"?

Thanks.

--
tejun

\
 
 \ /
  Last update: 2017-09-05 15:30    [W:0.115 / U:0.224 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site