OpenCloudOS-Kernel/net/atm
Jiri Olsa a57de0b433 net: adding memory barrier to the poll and receive callbacks
Adding memory barrier after the poll_wait function, paired with
receive callbacks. Adding fuctions sock_poll_wait and sk_has_sleeper
to wrap the memory barrier.

Without the memory barrier, following race can happen.
The race fires, when following code paths meet, and the tp->rcv_nxt
and __add_wait_queue updates stay in CPU caches.

CPU1                         CPU2

sys_select                   receive packet
  ...                        ...
  __add_wait_queue           update tp->rcv_nxt
  ...                        ...
  tp->rcv_nxt check          sock_def_readable
  ...                        {
  schedule                      ...
                                if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
                                        wake_up_interruptible(sk->sk_sleep)
                                ...
                             }

If there was no cache the code would work ok, since the wait_queue and
rcv_nxt are opposit to each other.

Meaning that once tp->rcv_nxt is updated by CPU2, the CPU1 either already
passed the tp->rcv_nxt check and sleeps, or will get the new value for
tp->rcv_nxt and will return with new data mask.
In both cases the process (CPU1) is being added to the wait queue, so the
waitqueue_active (CPU2) call cannot miss and will wake up CPU1.

The bad case is when the __add_wait_queue changes done by CPU1 stay in its
cache, and so does the tp->rcv_nxt update on CPU2 side.  The CPU1 will then
endup calling schedule and sleep forever if there are no more data on the
socket.

Calls to poll_wait in following modules were ommited:
	net/bluetooth/af_bluetooth.c
	net/irda/af_irda.c
	net/irda/irnet/irnet_ppp.c
	net/mac80211/rc80211_pid_debugfs.c
	net/phonet/socket.c
	net/rds/af_rds.c
	net/rfkill/core.c
	net/sunrpc/cache.c
	net/sunrpc/rpc_pipe.c
	net/tipc/socket.c

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-07-09 17:06:57 -07:00
..
Kconfig [ATM]: atm is no longer experimental 2008-01-28 15:00:11 -08:00
Makefile [ATM]: Kill ipcommon.[ch] 2006-12-02 21:32:08 -08:00
addr.c atm: use const where reasonable 2008-06-17 16:20:06 -07:00
addr.h atm: use const where reasonable 2008-06-17 16:20:06 -07:00
atm_misc.c [ATM]: atm_pcr_goal() doesn't modify its argument's contents -- mark it as const 2005-11-29 16:13:55 -08:00
atm_sysfs.c net: struct device - replace bus_id with dev_name(), dev_set_name() 2008-11-10 13:55:14 -08:00
br2684.c net: skb->dst accessors 2009-06-03 02:51:04 -07:00
clip.c net: skb->dst accessors 2009-06-03 02:51:04 -07:00
common.c net: adding memory barrier to the poll and receive callbacks 2009-07-09 17:06:57 -07:00
common.h atm: 32-bit ioctl compatibility 2008-12-03 22:12:38 -08:00
ioctl.c atm: sk_wmem_alloc initial value is one 2009-06-18 00:29:12 -07:00
lec.c net: fix network drivers ndo_start_xmit() return values (part 7) 2009-06-13 01:18:43 -07:00
lec.h lec: convert to internal network_device_stats 2009-01-21 14:02:00 -08:00
lec_arpc.h [ATM]: [lec] add reference counting to lec_arp entries 2006-09-29 17:16:48 -07:00
mpc.c atm: convert mpc device to using netdev_ops 2009-03-21 19:19:12 -07:00
mpc.h atm: convert mpc device to using netdev_ops 2009-03-21 19:19:12 -07:00
mpoa_caches.c net: replace NIPQUAD() in net/*/ 2008-10-31 00:54:56 -07:00
mpoa_caches.h [NET] ATM: Fix whitespace errors. 2007-02-10 23:19:16 -08:00
mpoa_proc.c proc 2/2: remove struct proc_dir_entry::owner 2009-03-31 01:14:44 +04:00
pppoatm.c [ATM]: Replace DPRINTK() with pr_debug(). 2007-10-10 16:48:27 -07:00
proc.c atm: sk_wmem_alloc initial value is one 2009-06-18 00:29:12 -07:00
protocols.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
pvc.c atm: 32-bit ioctl compatibility 2008-12-03 22:12:38 -08:00
raw.c atm: sk_wmem_alloc initial value is one 2009-06-18 00:29:12 -07:00
resources.c atm: 32-bit ioctl compatibility 2008-12-03 22:12:38 -08:00
resources.h atm: 32-bit ioctl compatibility 2008-12-03 22:12:38 -08:00
signaling.c [NET]: sparse warning fixes 2007-10-10 16:54:48 -07:00
signaling.h [NET] ATM: Fix whitespace errors. 2007-02-10 23:19:16 -08:00
svc.c Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2008-12-05 22:54:40 -08:00