On Fri, Oct 28, 2005 at 10:15:17AM -0500, Erik Jacobson wrote:
> I guess the other thing missing, from my perspective, is the ability for
> any process to be able to add to the watcher list of any task.
> In Linux Job, this is when you say "I would like that certain process to be
> part of a certain job container".
> This might involve locking on the watcher list. As stated previously, Jack
> Steiner doesn't agree with me here but it really is a need for the current
> Job without removing functionality which may be in use.
> It seems like (unless I'm reading wrong, which may be the case :) the watcher
> list in Matt's example is only added too. When a module decides it
> doesn't want to watch a task any more, it ignores it. That doesn't take
> anything out of the watcher list, it just makes it so an entry in the list
> points to NULL, right?
> Is there a safe way to add to the end of the watcher list without locks?
Adding is easy. It is removing that is difficult, since you have to
wait until readers are done before freeing the removed element.
To add, something like the following will work:
/* acquire some mutex to serialize updaters */
/* fill out structure. */
/* release the mutex. */
Traversal could be something like the following:
list_for_each_entry(p, &list, member)
This does constitute minor abuse of these RCU interfaces, but it does
work as long as one -never- deletes anything from the list.
Is this what you had in mind?
> Would locks be an option if we could show they don't cost much? Like I
> said earlier in the discussions, I'm certainly not interested in making
> Linux perform poorly and that issue takes precedent over anything else.
If locks work well in a given situation, use locks! ;-)