From: Oleg Nesterov <oleg@redhat.com>
To: Jarek Poplawski <jarkao2@gmail.com>
Cc: Davide Libenzi <davidel@xmailserver.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Jiri Olsa <jolsa@redhat.com>,
netdev@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
fbl@redhat.com, nhorman@redhat.com, davem@redhat.com,
Tejun Heo <htejun@gmail.com>
Subject: Re: [PATCH] net: fix race in the receive/select
Date: Sun, 28 Jun 2009 20:04:12 +0200 [thread overview]
Message-ID: <20090628180412.GA9171@redhat.com> (raw)
In-Reply-To: <4A475266.9040203@gmail.com>
On 06/28, Jarek Poplawski wrote:
>
> Jarek Poplawski wrote, On 06/28/2009 01:10 PM:
>
> > Oleg Nesterov wrote, On 06/26/2009 04:50 PM:
> >
> >> Perhaps we can add
> >>
> >> void sock_poll_wait(struct file *file, struct sock *sk, poll_table *pt)
> >> {
> >> if (pt) {
> >> poll_wait(file, sk->sk_sleep, pt);
> >> /*
> >> * fat comment
> >> */
> >> smp_mb(); // or smp_mb__after_unlock();
> >> }
> >> }
> >>
> >> Oleg.
> >
> >
> > Maybe 'a bit' further?:
> >
> > static inline void __poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
> > {
> > p->qproc(filp, wait_address, p);
> > }
> >
> > static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
> > {
> > if (p && wait_address)
> > __poll_wait(filp, wait_address, p);
> > }
> >
> > static inline void sock_poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
> > {
> > if (p && wait_address) {
> > __poll_wait(filp, wait_address, p);
> > /*
> > * fat comment
> > */
> > smp_mb(); // or smp_mb__after_unlock();
> > }
> > }
> >
>
>
> Hmm... of course:
>
> 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);
> /*
> * fat comment
> */
> smp_mb(); // or smp_mb__after_unlock();
> }
> }
Perhaps it makes sense to check ->sk_sleep != NULL in sock_poll_wait(), but
I don't think we need __poll_wait(). poll_wait() is inline, I think gcc
will optimize out "if (p && wait_address)" check if poll_wait() is called
from sock_poll_wait().
This all is up to Jiri of course. But speaking about cosmetic changes, I
think it is better to make 2 patches. The first one fixes the problem using
smp_mb(), another introduces smp_mb__xxx_lock() to optimize the code.
Oleg.
next prev parent reply other threads:[~2009-06-28 21:18 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-25 12:25 [PATCH] net: fix race in the receive/select Jiri Olsa
2009-06-25 12:24 ` Oleg Nesterov
2009-06-26 1:31 ` Davide Libenzi
2009-06-26 1:59 ` Eric Dumazet
2009-06-26 2:04 ` Davide Libenzi
2009-06-26 2:11 ` David Miller
2009-06-26 2:19 ` Eric Dumazet
2009-06-26 3:14 ` Davide Libenzi
2009-06-26 5:42 ` Jarek Poplawski
2009-06-26 8:10 ` Jarek Poplawski
2009-06-26 13:57 ` Oleg Nesterov
2009-06-26 17:32 ` Davide Libenzi
2009-06-26 14:50 ` Oleg Nesterov
2009-06-26 18:12 ` Davide Libenzi
2009-06-26 18:17 ` David Miller
2009-06-26 19:35 ` Eric Dumazet
2009-06-29 9:34 ` Jiri Olsa
2009-06-28 11:10 ` Jarek Poplawski
2009-06-28 11:22 ` Jarek Poplawski
2009-06-28 18:04 ` Oleg Nesterov [this message]
2009-06-28 21:48 ` Jarek Poplawski
2009-06-29 9:27 ` Jiri Olsa
2009-06-26 13:46 ` Oleg Nesterov
2009-06-25 23:18 ` Eric Dumazet
2009-06-26 1:50 ` Tejun Heo
2009-06-29 9:12 ` Andi Kleen
2009-06-29 9:24 ` Jiri Olsa
2009-06-29 16:59 ` Zan Lynx
2009-06-29 17:29 ` Andi Kleen
2009-07-01 3:39 ` Herbert Xu
2009-07-01 6:27 ` Andi Kleen
2009-07-01 7:03 ` Herbert Xu
2009-07-01 7:22 ` Andi Kleen
2009-07-01 8:31 ` Herbert Xu
2009-07-01 8:44 ` Jiri Olsa
2009-07-01 10:58 ` Herbert Xu
2009-07-01 13:07 ` Herbert Xu
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=20090628180412.GA9171@redhat.com \
--to=oleg@redhat.com \
--cc=davem@redhat.com \
--cc=davidel@xmailserver.org \
--cc=eric.dumazet@gmail.com \
--cc=fbl@redhat.com \
--cc=htejun@gmail.com \
--cc=jarkao2@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@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;
as well as URLs for NNTP newsgroup(s).