Thread (44 messages) flat view 44 messages, 3 authors, 2015-10-14

Re: [RFC v2 07/18] kthread: Allow to cancel kthread work

From: Tejun Heo <tj@kernel.org>
Date: 2015-10-07 14:24:52
Also in: linux-mm, lkml

Hello, Petr.

On Wed, Oct 07, 2015 at 11:21:30AM +0200, Petr Mladek wrote:
Now, let's have one work: W, two workers: A, B, and try to queue
the same work to the two workers at the same time:
It's a debug WARN condition to catch silly mistakes.  It can have
minor race conditions.

...
Second, we still need the busy waiting for the pending timer callback.
Isn't that del_timer_sync()?
Yes, we could set some flag so that the call back does not queue
the work. But cancel_kthread_work_sync() still has to wait.
It could not return if there is still some pending operation
with the struct kthread_work. Otherwise, it never could
be freed a safe way.

Also note that we still need the WORK_PENDING flag. Otherwise, we
would not be able to detect the race when timer is removed but
the callback has not run yet.
Yeah, just use a state field as I wrote before.
Let me to repeat that using per-work and per-worker lock is not an
option either. We would need some crazy hacks to avoid ABBA deadlocks.


All in all, I would prefer to keep the original approach that is
heavily inspired by the workqueues. I think that it is actually
an advantage to reuse some working concept that reinventing wheels.
At each turn, you come up with non-issues and declare that it needs to
be full workqueue-like implementation but the issues you're raising
seem all rather irrelevant.  Can you please try to take a step back
and put some distance from the implementation details of workqueue?

Thanks.

-- 
tejun
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help