You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[NET]: move struct proto_ops to const
I noticed that some of 'struct proto_ops' used in the kernel may share a cache line used by locks or other heavily modified data. (default linker alignement is 32 bytes, and L1_CACHE_LINE is 64 or 128 at least) This patch makes sure a 'struct proto_ops' can be declared as const, so that all cpus can share all parts of it without false sharing. This is not mandatory : a driver can still use a read/write structure if it needs to (and eventually a __read_mostly) I made a global stubstitute to change all existing occurences to make them const. This should reduce the possibility of false sharing on SMP, and speedup some socket system calls. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
77d76ea310
commit
90ddc4f047
+2
-2
@@ -107,7 +107,7 @@ enum sock_type {
|
||||
struct socket {
|
||||
socket_state state;
|
||||
unsigned long flags;
|
||||
struct proto_ops *ops;
|
||||
const struct proto_ops *ops;
|
||||
struct fasync_struct *fasync_list;
|
||||
struct file *file;
|
||||
struct sock *sk;
|
||||
@@ -260,7 +260,7 @@ SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct ms
|
||||
SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_area_struct *vma), \
|
||||
(file, sock, vma)) \
|
||||
\
|
||||
static struct proto_ops name##_ops = { \
|
||||
static const struct proto_ops name##_ops = { \
|
||||
.family = fam, \
|
||||
.owner = THIS_MODULE, \
|
||||
.release = __lock_##name##_release, \
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef _INET_COMMON_H
|
||||
#define _INET_COMMON_H
|
||||
|
||||
extern struct proto_ops inet_stream_ops;
|
||||
extern struct proto_ops inet_dgram_ops;
|
||||
extern const struct proto_ops inet_stream_ops;
|
||||
extern const struct proto_ops inet_dgram_ops;
|
||||
|
||||
/*
|
||||
* INET4 prototypes used by INET6
|
||||
|
||||
+2
-2
@@ -538,8 +538,8 @@ extern int sysctl_ip6frag_low_thresh;
|
||||
extern int sysctl_ip6frag_time;
|
||||
extern int sysctl_ip6frag_secret_interval;
|
||||
|
||||
extern struct proto_ops inet6_stream_ops;
|
||||
extern struct proto_ops inet6_dgram_ops;
|
||||
extern const struct proto_ops inet6_stream_ops;
|
||||
extern const struct proto_ops inet6_dgram_ops;
|
||||
|
||||
extern int ip6_mc_source(int add, int omode, struct sock *sk,
|
||||
struct group_source_req *pgsr);
|
||||
|
||||
@@ -65,7 +65,7 @@ struct inet_protosw {
|
||||
int protocol; /* This is the L4 protocol number. */
|
||||
|
||||
struct proto *prot;
|
||||
struct proto_ops *ops;
|
||||
const struct proto_ops *ops;
|
||||
|
||||
int capability; /* Which (if any) capability do
|
||||
* we need to use this socket
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@
|
||||
#include <linux/atalk.h>
|
||||
|
||||
struct datalink_proto *ddp_dl, *aarp_dl;
|
||||
static struct proto_ops atalk_dgram_ops;
|
||||
static const struct proto_ops atalk_dgram_ops;
|
||||
|
||||
/**************************************************************************\
|
||||
* *
|
||||
@@ -1841,7 +1841,7 @@ static struct net_proto_family atalk_family_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops) = {
|
||||
static const struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops) = {
|
||||
.family = PF_APPLETALK,
|
||||
.owner = THIS_MODULE,
|
||||
.release = atalk_release,
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,
|
||||
}
|
||||
|
||||
|
||||
static struct proto_ops pvc_proto_ops = {
|
||||
static const struct proto_ops pvc_proto_ops = {
|
||||
.family = PF_ATMPVC,
|
||||
.owner = THIS_MODULE,
|
||||
|
||||
|
||||
+1
-1
@@ -613,7 +613,7 @@ static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
return error;
|
||||
}
|
||||
|
||||
static struct proto_ops svc_proto_ops = {
|
||||
static const struct proto_ops svc_proto_ops = {
|
||||
.family = PF_ATMSVC,
|
||||
.owner = THIS_MODULE,
|
||||
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@
|
||||
HLIST_HEAD(ax25_list);
|
||||
DEFINE_SPINLOCK(ax25_list_lock);
|
||||
|
||||
static struct proto_ops ax25_proto_ops;
|
||||
static const struct proto_ops ax25_proto_ops;
|
||||
|
||||
static void ax25_free_sock(struct sock *sk)
|
||||
{
|
||||
@@ -1944,7 +1944,7 @@ static struct net_proto_family ax25_family_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct proto_ops ax25_proto_ops = {
|
||||
static const struct proto_ops ax25_proto_ops = {
|
||||
.family = PF_AX25,
|
||||
.owner = THIS_MODULE,
|
||||
.release = ax25_release,
|
||||
|
||||
@@ -146,7 +146,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct proto_ops bnep_sock_ops = {
|
||||
static const struct proto_ops bnep_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = bnep_sock_release,
|
||||
|
||||
@@ -137,7 +137,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static struct proto_ops cmtp_sock_ops = {
|
||||
static const struct proto_ops cmtp_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = cmtp_sock_release,
|
||||
|
||||
@@ -575,7 +575,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct proto_ops hci_sock_ops = {
|
||||
static const struct proto_ops hci_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = hci_sock_release,
|
||||
|
||||
@@ -143,7 +143,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static struct proto_ops hidp_sock_ops = {
|
||||
static const struct proto_ops hidp_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = hidp_sock_release,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
#define VERSION "2.8"
|
||||
|
||||
static struct proto_ops l2cap_sock_ops;
|
||||
static const struct proto_ops l2cap_sock_ops;
|
||||
|
||||
static struct bt_sock_list l2cap_sk_list = {
|
||||
.lock = RW_LOCK_UNLOCKED
|
||||
@@ -2161,7 +2161,7 @@ static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
|
||||
|
||||
static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);
|
||||
|
||||
static struct proto_ops l2cap_sock_ops = {
|
||||
static const struct proto_ops l2cap_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = l2cap_sock_release,
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#define BT_DBG(D...)
|
||||
#endif
|
||||
|
||||
static struct proto_ops rfcomm_sock_ops;
|
||||
static const struct proto_ops rfcomm_sock_ops;
|
||||
|
||||
static struct bt_sock_list rfcomm_sk_list = {
|
||||
.lock = RW_LOCK_UNLOCKED
|
||||
@@ -907,7 +907,7 @@ static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf)
|
||||
|
||||
static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL);
|
||||
|
||||
static struct proto_ops rfcomm_sock_ops = {
|
||||
static const struct proto_ops rfcomm_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = rfcomm_sock_release,
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@
|
||||
|
||||
#define VERSION "0.5"
|
||||
|
||||
static struct proto_ops sco_sock_ops;
|
||||
static const struct proto_ops sco_sock_ops;
|
||||
|
||||
static struct bt_sock_list sco_sk_list = {
|
||||
.lock = RW_LOCK_UNLOCKED
|
||||
@@ -914,7 +914,7 @@ static ssize_t sco_sysfs_show(struct class *dev, char *buf)
|
||||
|
||||
static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL);
|
||||
|
||||
static struct proto_ops sco_sock_ops = {
|
||||
static const struct proto_ops sco_sock_ops = {
|
||||
.family = PF_BLUETOOTH,
|
||||
.owner = THIS_MODULE,
|
||||
.release = sco_sock_release,
|
||||
|
||||
+1
-1
@@ -680,7 +680,7 @@ void dccp_shutdown(struct sock *sk, int how)
|
||||
|
||||
EXPORT_SYMBOL_GPL(dccp_shutdown);
|
||||
|
||||
static struct proto_ops inet_dccp_ops = {
|
||||
static const struct proto_ops inet_dccp_ops = {
|
||||
.family = PF_INET,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet_release,
|
||||
|
||||
@@ -149,7 +149,7 @@ static void dn_keepalive(struct sock *sk);
|
||||
#define DN_SK_HASH_MASK (DN_SK_HASH_SIZE - 1)
|
||||
|
||||
|
||||
static struct proto_ops dn_proto_ops;
|
||||
static const struct proto_ops dn_proto_ops;
|
||||
static DEFINE_RWLOCK(dn_hash_lock);
|
||||
static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE];
|
||||
static struct hlist_head dn_wild_sk;
|
||||
@@ -2342,7 +2342,7 @@ static struct net_proto_family dn_family_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct proto_ops dn_proto_ops = {
|
||||
static const struct proto_ops dn_proto_ops = {
|
||||
.family = AF_DECnet,
|
||||
.owner = THIS_MODULE,
|
||||
.release = dn_release,
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/system.h>
|
||||
|
||||
static struct proto_ops econet_ops;
|
||||
static const struct proto_ops econet_ops;
|
||||
static struct hlist_head econet_sklist;
|
||||
static DEFINE_RWLOCK(econet_lock);
|
||||
|
||||
@@ -698,7 +698,7 @@ static struct net_proto_family econet_family_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct proto_ops SOCKOPS_WRAPPED(econet_ops) = {
|
||||
static const struct proto_ops SOCKOPS_WRAPPED(econet_ops) = {
|
||||
.family = PF_ECONET,
|
||||
.owner = THIS_MODULE,
|
||||
.release = econet_release,
|
||||
|
||||
+3
-3
@@ -785,7 +785,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
return err;
|
||||
}
|
||||
|
||||
struct proto_ops inet_stream_ops = {
|
||||
const struct proto_ops inet_stream_ops = {
|
||||
.family = PF_INET,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet_release,
|
||||
@@ -806,7 +806,7 @@ struct proto_ops inet_stream_ops = {
|
||||
.sendpage = tcp_sendpage
|
||||
};
|
||||
|
||||
struct proto_ops inet_dgram_ops = {
|
||||
const struct proto_ops inet_dgram_ops = {
|
||||
.family = PF_INET,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet_release,
|
||||
@@ -831,7 +831,7 @@ struct proto_ops inet_dgram_ops = {
|
||||
* For SOCK_RAW sockets; should be the same as inet_dgram_ops but without
|
||||
* udp_poll
|
||||
*/
|
||||
static struct proto_ops inet_sockraw_ops = {
|
||||
static const struct proto_ops inet_sockraw_ops = {
|
||||
.family = PF_INET,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet_release,
|
||||
|
||||
+3
-3
@@ -462,7 +462,7 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
return(0);
|
||||
}
|
||||
|
||||
struct proto_ops inet6_stream_ops = {
|
||||
const struct proto_ops inet6_stream_ops = {
|
||||
.family = PF_INET6,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet6_release,
|
||||
@@ -483,7 +483,7 @@ struct proto_ops inet6_stream_ops = {
|
||||
.sendpage = tcp_sendpage
|
||||
};
|
||||
|
||||
struct proto_ops inet6_dgram_ops = {
|
||||
const struct proto_ops inet6_dgram_ops = {
|
||||
.family = PF_INET6,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet6_release,
|
||||
@@ -511,7 +511,7 @@ static struct net_proto_family inet6_family_ops = {
|
||||
};
|
||||
|
||||
/* Same as inet6_dgram_ops, sans udp_poll. */
|
||||
static struct proto_ops inet6_sockraw_ops = {
|
||||
static const struct proto_ops inet6_sockraw_ops = {
|
||||
.family = PF_INET6,
|
||||
.owner = THIS_MODULE,
|
||||
.release = inet6_release,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user