Messages in this thread | | | Date | Thu, 26 Feb 2015 20:29:29 +0100 | From | Oleg Nesterov <> | Subject | Re: [RFC PATCH] ipc/sem.c: Add one more memory barrier to sem_lock(). |
| |
Sorry Manfred, I initiated this discussion and then disappeared. Currently I am buried in the ancient 2.16.18 bugs ;)
On 02/25, Manfred Spraul wrote: > Hi, > > What do you think about the following patch for sem_lock()? > > Other options: > > 1) I don't like > > #define smp_mb__after_unlock_wait() smp_rmb() > > I think it is too specific: the last block in sem_lock uses > > if (sma->complex_count == 0) { > smp_rmb(); > return; > }
See below.
> > 2) What about > > #define smp_aquire__after_control_barrier() smp_rmb()
I agree with any naming. The only point of the new helper is that we can factor out the comment, otherwise we would need to repeat it again and again.
> @@ -341,7 +359,13 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops, > * Thus: if is now 0, then it will stay 0. > */ > if (sma->complex_count == 0) { > - /* fast path successful! */ > + /* > + * Fast path successful! > + * We only need a final memory barrier. > + * (see sem_wait_array() for details). > + */ > + smp_rmb(); > +
I'll try to read this again tomorrow, but so far I am confused.
Most probably I missed something, but this looks unneeded at first glance.
We already have another smp_rmb() above this check. And it should act as a "final" barrier, or we can not trust this ->complex_count check ?
And (if I am right) this means that the comment above that rmb() should be updated. And that is why I think the helper makes sense, the comment should be almost the same as in sem_wait_array().
If not, could you please spell to explain why do we need another rmb() ?
Oleg.
| |