From: Jarek Poplawski <jarkao2@gmail.com>
To: Jiri Olsa <jolsa@redhat.com>
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
Date: Mon, 29 Jun 2009 19:47:20 +0200 [thread overview]
Message-ID: <20090629174720.GD2742@ami.dom.local> (raw)
In-Reply-To: <20090629141445.GF3845@jolsa.lab.eng.brq.redhat.com>
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();
> + }
> +}
next prev parent reply other threads:[~2009-06-29 17:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-29 14:04 [PATCH 0/2] net: fix race in the receive/select Jiri Olsa
2009-06-29 14:14 ` [PATCH 1/2] net: adding memory barrier to the poll and receive callbacks Jiri Olsa
2009-06-29 15:34 ` Davide Libenzi
2009-06-29 17:32 ` Jarek Poplawski
2009-06-29 17:36 ` Davide Libenzi
2009-06-29 18:04 ` Jarek Poplawski
2009-06-29 18:14 ` Jarek Poplawski
2009-06-29 19:47 ` Jarek Poplawski
2009-06-29 20:17 ` Jiri Olsa
2009-06-29 20:20 ` Davide Libenzi
2009-06-29 17:19 ` Jarek Poplawski
2009-06-29 20:05 ` Jiri Olsa
2009-06-29 17:47 ` Jarek Poplawski [this message]
2009-06-29 14:15 ` [PATCH 2/2] memory barrier: adding smp_mb__after_lock Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090629174720.GD2742@ami.dom.local \
--to=jarkao2@gmail.com \
--cc=davem@redhat.com \
--cc=davidel@xmailserver.org \
--cc=eric.dumazet@gmail.com \
--cc=fbl@redhat.com \
--cc=htejun@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox