Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712Ab3CBVSk (ORCPT ); Sat, 2 Mar 2013 16:18:40 -0500 Received: from g4t0014.houston.hp.com ([15.201.24.17]:1086 "EHLO g4t0014.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752501Ab3CBVSi (ORCPT ); Sat, 2 Mar 2013 16:18:38 -0500 Message-ID: <1362259114.3602.6.camel@buesod1.americas.hpqcorp.net> Subject: Re: [PATCH 2/2] ipc: semaphores: do not hold ipc lock more than necessary From: Davidlohr Bueso To: Linus Torvalds Cc: Rik van Riel , "Vinod, Chegu" , "Low, Jason" , linux-tip-commits@vger.kernel.org, Peter Zijlstra , "H. Peter Anvin" , Andrew Morton , aquini@redhat.com, Michel Lespinasse , Ingo Molnar , Larry Woodman , Linux Kernel Mailing List , Steven Rostedt , Thomas Gleixner Date: Sat, 02 Mar 2013 13:18:34 -0800 In-Reply-To: References: <1362183404.3420.25.camel@buesod1.americas.hpqcorp.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.4.4 (3.4.4-2.fc17) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1960 Lines: 65 On Fri, 2013-03-01 at 17:20 -0800, Linus Torvalds wrote: > On Fri, Mar 1, 2013 at 4:16 PM, Davidlohr Bueso wrote: > > +static inline struct sem_array *sem_obtain_object(struct ipc_namespace *ns, int id) > > +{ > > + struct kern_ipc_perm *ipcp = ipc_obtain_object(&sem_ids(ns), id); > > + > > + if (IS_ERR(ipcp)) > > + return (struct sem_array *)ipcp; > > This should use ERR_CAST() to make it more obvious what's going on. > > > +static inline struct sem_array *sem_obtain_object_check(struct ipc_namespace *ns, > > + int id) > > +{ > > + struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&sem_ids(ns), id); > > + > > + if (IS_ERR(ipcp)) > > + return (struct sem_array *)ipcp; > > Same here. Ok > > > +/* > > + * Call inside the rcu read section. > > + */ > > +static inline void sem_getref(struct sem_array *sma) > > +{ > > + spin_lock(&(sma)->sem_perm.lock); > > + ipc_rcu_getref(sma); > > + ipc_unlock(&(sma)->sem_perm); > > +} > > This really makes me wonder if we shouldn't just use an atomic counter > for "refcount". But I guess that would be a separate patch. > Ah, yes indeed. > But all the uses of refcount really look like the normal atomic ops > migth be the right thing. Especially if we no longer expect to hold > the lock most of the time. > > > + spin_lock(&sma->sem_perm.lock); > > I really would almost want to make these things be "ipc_lock_object()" > rather than an open-coded spinlock like this. But that's not a big > deal. Sure. > > Patch looks fine to me in general. > Thanks for taking a look! Davidlohr -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/