linux-stable/net
Eric Dumazet 16e5726269 af_unix: dont send SCM_CREDENTIALS by default
Since commit 7361c36c52 (af_unix: Allow credentials to work across
user and pid namespaces) af_unix performance dropped a lot.

This is because we now take a reference on pid and cred in each write(),
and release them in read(), usually done from another process,
eventually from another cpu. This triggers false sharing.

# Events: 154K cycles
#
# Overhead  Command       Shared Object        Symbol
# ........  .......  ..................  .........................
#
    10.40%  hackbench  [kernel.kallsyms]   [k] put_pid
     8.60%  hackbench  [kernel.kallsyms]   [k] unix_stream_recvmsg
     7.87%  hackbench  [kernel.kallsyms]   [k] unix_stream_sendmsg
     6.11%  hackbench  [kernel.kallsyms]   [k] do_raw_spin_lock
     4.95%  hackbench  [kernel.kallsyms]   [k] unix_scm_to_skb
     4.87%  hackbench  [kernel.kallsyms]   [k] pid_nr_ns
     4.34%  hackbench  [kernel.kallsyms]   [k] cred_to_ucred
     2.39%  hackbench  [kernel.kallsyms]   [k] unix_destruct_scm
     2.24%  hackbench  [kernel.kallsyms]   [k] sub_preempt_count
     1.75%  hackbench  [kernel.kallsyms]   [k] fget_light
     1.51%  hackbench  [kernel.kallsyms]   [k]
__mutex_lock_interruptible_slowpath
     1.42%  hackbench  [kernel.kallsyms]   [k] sock_alloc_send_pskb

This patch includes SCM_CREDENTIALS information in a af_unix message/skb
only if requested by the sender, [man 7 unix for details how to include
ancillary data using sendmsg() system call]

Note: This might break buggy applications that expected SCM_CREDENTIAL
from an unaware write() system call, and receiver not using SO_PASSCRED
socket option.

If SOCK_PASSCRED is set on source or destination socket, we still
include credentials for mere write() syscalls.

Performance boost in hackbench : more than 50% gain on a 16 thread
machine (2 quad-core cpus, 2 threads per core)

hackbench 20 thread 2000

4.228 sec instead of 9.102 sec

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-09-28 13:29:50 -04:00
..
9p net/9p: Fix kernel crash with msize 512K 2011-09-06 08:17:15 -05:00
802 rcu: convert uses of rcu_assign_pointer(x, NULL) to RCU_INIT_POINTER 2011-08-02 04:29:23 -07:00
8021q net: consolidate and fix ethtool_ops->get_settings calling 2011-09-15 17:32:26 -04:00
appletalk appletalk: Reduce switch/case indent 2011-07-01 16:11:15 -07:00
atm Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
ax25 ax25: Fix set-but-unused variable. 2011-04-17 00:48:31 -07:00
batman-adv batman-adv: Remove unnecessary OOM logging messages 2011-09-08 17:52:30 +02:00
bluetooth Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
bridge Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
caif Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
can Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
ceph Merge branch 'for-linus' of git://ceph.newdream.net/git/ceph-client 2011-09-09 15:48:34 -07:00
core af_unix: dont send SCM_CREDENTIALS by default 2011-09-28 13:29:50 -04:00
dcb dcbnl: unlock on an error path in dcbnl_cee_fill() 2011-07-08 09:01:14 -07:00
dccp Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net 2011-08-07 23:20:26 -07:00
decnet rcu: convert uses of rcu_assign_pointer(x, NULL) to RCU_INIT_POINTER 2011-08-02 04:29:23 -07:00
dns_resolver KEYS: Improve /proc/keys 2011-03-17 11:59:32 +11:00
dsa net: remove use of ndo_set_multicast_list in drivers 2011-08-17 20:22:03 -07:00
econet af_econet: Use current logging styles and neatening 2011-07-03 20:05:16 -07:00
ethernet net: don't clear IFF_XMIT_DST_RELEASE in ether_setup 2011-09-15 14:49:44 -04:00
ieee802154 6LoWPAN: fix skb_copy call 2011-09-15 15:36:35 -04:00
ipv4 tcp: rename tcp_skb_cb flags 2011-09-27 13:25:05 -04:00
ipv6 tcp: unalias tcp_skb_cb flags and ip_dsfield 2011-09-27 02:20:08 -04:00
ipx ipx: fix ipx_release() 2011-03-21 18:16:39 -07:00
irda Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
iucv af_iucv: add HiperSockets transport 2011-08-13 01:10:16 -07:00
key net: Remove casts of void * 2011-06-16 23:19:27 -04:00
l2tp Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2011-07-28 05:58:19 -07:00
lapb wan: make LAPB callbacks const 2011-09-16 19:20:20 -04:00
llc llc: Fix length check in llc_fixup_skb(). 2011-04-11 18:59:05 -07:00
mac80211 Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
netfilter Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
netlabel Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net 2011-08-20 10:39:12 -07:00
netlink af_unix: dont send SCM_CREDENTIALS by default 2011-09-28 13:29:50 -04:00
netrom netrom: Reduce switch/case indent 2011-07-01 16:11:16 -07:00
nfc NFC: Reserve tx head and tail room 2011-08-24 14:41:44 -04:00
packet net: consolidate and fix ethtool_ops->get_settings calling 2011-09-15 17:32:26 -04:00
phonet rcu: convert uses of rcu_assign_pointer(x, NULL) to RCU_INIT_POINTER 2011-08-02 04:29:23 -07:00
rds net, rds, Replace xlist in net/rds/xlist.h with llist 2011-09-15 15:36:32 -04:00
rfkill rfkill: Remove unnecessary OOM logging messages 2011-09-13 15:45:02 -04:00
rose rose: Delete commented out references to ancient firewalling code. 2011-07-07 02:41:59 -07:00
rxrpc rxrpc: Fix set but unused variable 'usage' in rxrpc_get_transport() 2011-05-19 18:51:50 -04:00
sched Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
sctp Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
sunrpc rcu: convert uses of rcu_assign_pointer(x, NULL) to RCU_INIT_POINTER 2011-08-02 04:29:23 -07:00
tipc tipc: Remove unused link event tracking code 2011-09-17 22:55:15 -04:00
unix af_unix: dont send SCM_CREDENTIALS by default 2011-09-28 13:29:50 -04:00
wanrouter Fix common misspellings 2011-03-31 11:26:23 -03:00
wimax
wireless Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
x25 x25: Reduce switch/case indent 2011-07-01 16:11:16 -07:00
xfrm Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
compat.c net: Add sendmmsg socket system call 2011-05-05 11:10:14 -07:00
Kconfig NFC: add nfc subsystem core 2011-07-05 15:26:57 -04:00
Makefile NFC: add nfc subsystem core 2011-07-05 15:26:57 -04:00
nonet.c
socket.c Merge branch 'master' of github.com:davem330/net 2011-09-22 03:23:13 -04:00
sysctl_net.c