Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757212AbZF2Rrj (ORCPT ); Mon, 29 Jun 2009 13:47:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754003AbZF2Rr2 (ORCPT ); Mon, 29 Jun 2009 13:47:28 -0400 Received: from mail-bw0-f213.google.com ([209.85.218.213]:42480 "EHLO mail-bw0-f213.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752771AbZF2Rr1 (ORCPT ); Mon, 29 Jun 2009 13:47:27 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=MIJcvDKj1nwLRIdW4UXCainJ8P01Wu81aU0ZqFDMP1QhNbdeCI2zO4a71uOkOF4/lg IcUefABEGlu4MXbisiM4BUu6LWo1Tc+6oGgA72EycBfOXePOFUJ8uW6cllw40DkWIb9C M/NNRbbIZAztk3AKVLLGld6kifO5m/RSoJMHs= Date: Mon, 29 Jun 2009 19:47:20 +0200 From: Jarek Poplawski To: Jiri Olsa Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, fbl@redhat.com, nhorman@redhat.com, davem@redhat.com, htejun@gmail.com, oleg@redhat.com, davidel@xmailserver.org, eric.dumazet@gmail.com Subject: Re: [PATCH 1/2] net: adding memory barrier to the poll and receive callbacks Message-ID: <20090629174720.GD2742@ami.dom.local> References: <20090629140434.GE3845@jolsa.lab.eng.brq.redhat.com> <20090629141445.GF3845@jolsa.lab.eng.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090629141445.GF3845@jolsa.lab.eng.brq.redhat.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 Content-Length: 1539 Lines: 53 On Mon, Jun 29, 2009 at 04:14:45PM +0200, Jiri Olsa wrote: ... > +/** > + * sk_has_sleeper - check if there are any waiting processes > + * @sk: socket > + * > + * Returns true if socket has waiting processes > + */ > +static inline int sk_has_sleeper(struct sock *sk) > +{ > + /* > + * We need to be sure we are in sync with the > + * add_wait_queue modifications to the wait queue. > + * > + * This memory barrier is paired in the sock_poll_wait. > + */ > + smp_mb(); > + return sk->sk_sleep && waitqueue_active(sk->sk_sleep); > +} > + Btw. I hope Jiri won't "listen" to me, but I can't stop to mention sock_waitqueue_active() looks to me quite naturally better paired with sock_poll_wait() than sk_has_sleeper(which otherwise is more conspicuous, sorry Eric.) Jarek P. > +/** > + * sock_poll_wait - place memory barrier behind the __poll_wait call. > + * @filp: file > + * @sk: socket > + * @p: poll_table > + */ > +static inline void sock_poll_wait(struct file *filp, struct sock *sk, > + poll_table *p) > +{ > + if (p && sk->sk_sleep) { > + __poll_wait(filp, sk->sk_sleep, p); > + /* > + * We need to be sure we are in sync with the > + * socket flags modification. > + * > + * This memory barrier is paired in the sk_has_sleeper. > + */ > + smp_mb(); > + } > +} -- 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/