From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754152AbbBZTcD (ORCPT ); Thu, 26 Feb 2015 14:32:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53223 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753643AbbBZTcA (ORCPT ); Thu, 26 Feb 2015 14:32:00 -0500 Date: Thu, 26 Feb 2015 20:29:29 +0100 From: Oleg Nesterov To: Manfred Spraul Cc: "Paul E. McKenney" , LKML , 1vier1@web.de, Peter Zijlstra , Kirill Tkhai , Ingo Molnar , Josh Poimboeuf Subject: Re: [RFC PATCH] ipc/sem.c: Add one more memory barrier to sem_lock(). Message-ID: <20150226192929.GA975@redhat.com> References: <1424893009-27191-1-git-send-email-manfred@colorfullife.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424893009-27191-1-git-send-email-manfred@colorfullife.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.