[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170905132951.GB1774378@devbig577.frc2.facebook.com>
Date: Tue, 5 Sep 2017 06:29:51 -0700
From: Tejun Heo <tj@...nel.org>
To: David Howells <dhowells@...hat.com>
Cc: linux-afs@...ts.infradead.org, linux-fsdevel@...r.kernel.org,
Lai Jiangshan <jiangshanlai@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [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
Powered by blists - more mailing lists