Messages in this thread | | | Date | Wed, 29 Aug 2012 17:25:55 +0200 | From | Oleg Nesterov <> | Subject | Re: lockdep trace from posix timers |
| |
On 08/28, Peter Zijlstra wrote: > > Surely we can do this locklessly.. I'll go try harder still.
I doubt...
Even ignore work->func check, somehow you need to ensure that work->next == new can't be changed durung cmpxchg(..., new).
Anyway, if this is possible, can't you do this on top of 1-4 I sent? There are simple, and solve the problems we discusssed.
Off-topic. This is really minor, bur can't we simplify llist_add()?
static inline bool llist_add(struct llist_node *new, struct llist_head *head) { struct llist_node *old;
do { old = ACCESS_ONCE(head->first); new->next = old; } while (cmpxchg(&head->first, old, new) != old);
return old == NULL; }
looks simpler and saves a couple of insns. The likely case should assume that cmpxchg() succeeds after the 1st attempt. If it fails, another LOAD from head->first should be very cheap.
And note this ACCESS_ONCE(head->first) above. I think that (in theory) the current code needs it too. But only in theory, I guess.
Oleg.
| |