[NET]: Add const markers to various variables.

the patch below marks various variables const in net/; the goal is to
move them to the .rodata section so that they can't false-share
cachelines with things that get written to, as well as potentially
helping gcc a bit with optimisations. (these were found using a gcc
patch to warn about such variables)

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Arjan van de Ven and committed by David S. Miller 9b5b5cff fb296449

+29 -29
+1 -1
net/ipv4/fib_hash.c
··· 975 976 static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi) 977 { 978 - static unsigned type2flags[RTN_MAX + 1] = { 979 [7] = RTF_REJECT, [8] = RTF_REJECT, 980 }; 981 unsigned flags = type2flags[type];
··· 975 976 static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi) 977 { 978 + static const unsigned type2flags[RTN_MAX + 1] = { 979 [7] = RTF_REJECT, [8] = RTF_REJECT, 980 }; 981 unsigned flags = type2flags[type];
+1 -1
net/ipv4/fib_semantics.c
··· 83 #define endfor_nexthops(fi) } 84 85 86 - static struct 87 { 88 int error; 89 u8 scope;
··· 83 #define endfor_nexthops(fi) } 84 85 86 + static const struct 87 { 88 int error; 89 u8 scope;
+2 -2
net/ipv4/icmp.c
··· 220 short error; /* This ICMP is classed as an error message */ 221 }; 222 223 - static struct icmp_control icmp_pointers[NR_ICMP_TYPES+1]; 224 225 /* 226 * The ICMP socket(s). This is the most convenient way to flow control ··· 994 /* 995 * This table is the definition of how we handle ICMP. 996 */ 997 - static struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = { 998 [ICMP_ECHOREPLY] = { 999 .output_entry = ICMP_MIB_OUTECHOREPS, 1000 .input_entry = ICMP_MIB_INECHOREPS,
··· 220 short error; /* This ICMP is classed as an error message */ 221 }; 222 223 + static const struct icmp_control icmp_pointers[NR_ICMP_TYPES+1]; 224 225 /* 226 * The ICMP socket(s). This is the most convenient way to flow control ··· 994 /* 995 * This table is the definition of how we handle ICMP. 996 */ 997 + static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = { 998 [ICMP_ECHOREPLY] = { 999 .output_entry = ICMP_MIB_OUTECHOREPS, 1000 .input_entry = ICMP_MIB_INECHOREPS,
+1 -1
net/ipv4/ipvs/ip_vs_conn.c
··· 771 * The drop rate array needs tuning for real environments. 772 * Called from timer bh only => no locking 773 */ 774 - static char todrop_rate[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; 775 static char todrop_counter[9] = {0}; 776 int i; 777
··· 771 * The drop rate array needs tuning for real environments. 772 * Called from timer bh only => no locking 773 */ 774 + static const char todrop_rate[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; 775 static char todrop_counter[9] = {0}; 776 int i; 777
+2 -2
net/ipv4/ipvs/ip_vs_ctl.c
··· 1909 #define DAEMON_ARG_LEN (sizeof(struct ip_vs_daemon_user)) 1910 #define MAX_ARG_LEN SVCDEST_ARG_LEN 1911 1912 - static unsigned char set_arglen[SET_CMDID(IP_VS_SO_SET_MAX)+1] = { 1913 [SET_CMDID(IP_VS_SO_SET_ADD)] = SERVICE_ARG_LEN, 1914 [SET_CMDID(IP_VS_SO_SET_EDIT)] = SERVICE_ARG_LEN, 1915 [SET_CMDID(IP_VS_SO_SET_DEL)] = SERVICE_ARG_LEN, ··· 2180 #define GET_TIMEOUT_ARG_LEN (sizeof(struct ip_vs_timeout_user)) 2181 #define GET_DAEMON_ARG_LEN (sizeof(struct ip_vs_daemon_user) * 2) 2182 2183 - static unsigned char get_arglen[GET_CMDID(IP_VS_SO_GET_MAX)+1] = { 2184 [GET_CMDID(IP_VS_SO_GET_VERSION)] = 64, 2185 [GET_CMDID(IP_VS_SO_GET_INFO)] = GET_INFO_ARG_LEN, 2186 [GET_CMDID(IP_VS_SO_GET_SERVICES)] = GET_SERVICES_ARG_LEN,
··· 1909 #define DAEMON_ARG_LEN (sizeof(struct ip_vs_daemon_user)) 1910 #define MAX_ARG_LEN SVCDEST_ARG_LEN 1911 1912 + static const unsigned char set_arglen[SET_CMDID(IP_VS_SO_SET_MAX)+1] = { 1913 [SET_CMDID(IP_VS_SO_SET_ADD)] = SERVICE_ARG_LEN, 1914 [SET_CMDID(IP_VS_SO_SET_EDIT)] = SERVICE_ARG_LEN, 1915 [SET_CMDID(IP_VS_SO_SET_DEL)] = SERVICE_ARG_LEN, ··· 2180 #define GET_TIMEOUT_ARG_LEN (sizeof(struct ip_vs_timeout_user)) 2181 #define GET_DAEMON_ARG_LEN (sizeof(struct ip_vs_daemon_user) * 2) 2182 2183 + static const unsigned char get_arglen[GET_CMDID(IP_VS_SO_GET_MAX)+1] = { 2184 [GET_CMDID(IP_VS_SO_GET_VERSION)] = 64, 2185 [GET_CMDID(IP_VS_SO_GET_INFO)] = GET_INFO_ARG_LEN, 2186 [GET_CMDID(IP_VS_SO_GET_SERVICES)] = GET_SERVICES_ARG_LEN,
+1 -1
net/ipv4/ipvs/ip_vs_proto_tcp.c
··· 251 #define TCP_DIR_OUTPUT 4 252 #define TCP_DIR_INPUT_ONLY 8 253 254 - static int tcp_state_off[IP_VS_DIR_LAST] = { 255 [IP_VS_DIR_INPUT] = TCP_DIR_INPUT, 256 [IP_VS_DIR_OUTPUT] = TCP_DIR_OUTPUT, 257 [IP_VS_DIR_INPUT_ONLY] = TCP_DIR_INPUT_ONLY,
··· 251 #define TCP_DIR_OUTPUT 4 252 #define TCP_DIR_INPUT_ONLY 8 253 254 + static const int tcp_state_off[IP_VS_DIR_LAST] = { 255 [IP_VS_DIR_INPUT] = TCP_DIR_INPUT, 256 [IP_VS_DIR_OUTPUT] = TCP_DIR_OUTPUT, 257 [IP_VS_DIR_INPUT_ONLY] = TCP_DIR_INPUT_ONLY,
+1 -1
net/ipv4/netfilter/ip_conntrack_amanda.c
··· 37 module_param(master_timeout, int, 0600); 38 MODULE_PARM_DESC(master_timeout, "timeout for the master connection"); 39 40 - static char *conns[] = { "DATA ", "MESG ", "INDEX " }; 41 42 /* This is slow, but it's simple. --RR */ 43 static char *amanda_buffer;
··· 37 module_param(master_timeout, int, 0600); 38 MODULE_PARM_DESC(master_timeout, "timeout for the master connection"); 39 40 + static const char *conns[] = { "DATA ", "MESG ", "INDEX " }; 41 42 /* This is slow, but it's simple. --RR */ 43 static char *amanda_buffer;
+1 -1
net/ipv4/netfilter/ip_conntrack_ftp.c
··· 55 static int try_eprt(const char *, size_t, u_int32_t [], char); 56 static int try_epsv_response(const char *, size_t, u_int32_t [], char); 57 58 - static struct ftp_search { 59 enum ip_conntrack_dir dir; 60 const char *pattern; 61 size_t plen;
··· 55 static int try_eprt(const char *, size_t, u_int32_t [], char); 56 static int try_epsv_response(const char *, size_t, u_int32_t [], char); 57 58 + static const struct ftp_search { 59 enum ip_conntrack_dir dir; 60 const char *pattern; 61 size_t plen;
+1 -1
net/ipv4/netfilter/ip_conntrack_irc.c
··· 59 module_param(dcc_timeout, int, 0400); 60 MODULE_PARM_DESC(dcc_timeout, "timeout on for unestablished DCC channels"); 61 62 - static char *dccprotos[] = { "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT " }; 63 #define MINMATCHLEN 5 64 65 #if 0
··· 59 module_param(dcc_timeout, int, 0400); 60 MODULE_PARM_DESC(dcc_timeout, "timeout on for unestablished DCC channels"); 61 62 + static const char *dccprotos[] = { "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT " }; 63 #define MINMATCHLEN 5 64 65 #if 0
+2 -2
net/ipv4/netfilter/ip_conntrack_proto_icmp.c
··· 51 const struct ip_conntrack_tuple *orig) 52 { 53 /* Add 1; spaces filled with 0. */ 54 - static u_int8_t invmap[] 55 = { [ICMP_ECHO] = ICMP_ECHOREPLY + 1, 56 [ICMP_ECHOREPLY] = ICMP_ECHO + 1, 57 [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1, ··· 110 return NF_ACCEPT; 111 } 112 113 - static u_int8_t valid_new[] = { 114 [ICMP_ECHO] = 1, 115 [ICMP_TIMESTAMP] = 1, 116 [ICMP_INFO_REQUEST] = 1,
··· 51 const struct ip_conntrack_tuple *orig) 52 { 53 /* Add 1; spaces filled with 0. */ 54 + static const u_int8_t invmap[] 55 = { [ICMP_ECHO] = ICMP_ECHOREPLY + 1, 56 [ICMP_ECHOREPLY] = ICMP_ECHO + 1, 57 [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1, ··· 110 return NF_ACCEPT; 111 } 112 113 + static const u_int8_t valid_new[] = { 114 [ICMP_ECHO] = 1, 115 [ICMP_TIMESTAMP] = 1, 116 [ICMP_INFO_REQUEST] = 1,
+2 -2
net/ipv4/netfilter/ip_conntrack_proto_sctp.c
··· 65 static unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; 66 static unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; 67 68 - static unsigned long * sctp_timeouts[] 69 = { NULL, /* SCTP_CONNTRACK_NONE */ 70 &ip_ct_sctp_timeout_closed, /* SCTP_CONNTRACK_CLOSED */ 71 &ip_ct_sctp_timeout_cookie_wait, /* SCTP_CONNTRACK_COOKIE_WAIT */ ··· 118 */ 119 120 /* SCTP conntrack state transitions */ 121 - static enum sctp_conntrack sctp_conntracks[2][9][SCTP_CONNTRACK_MAX] = { 122 { 123 /* ORIGINAL */ 124 /* sNO, sCL, sCW, sCE, sES, sSS, sSR, sSA */
··· 65 static unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000; 66 static unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS; 67 68 + static const unsigned long * sctp_timeouts[] 69 = { NULL, /* SCTP_CONNTRACK_NONE */ 70 &ip_ct_sctp_timeout_closed, /* SCTP_CONNTRACK_CLOSED */ 71 &ip_ct_sctp_timeout_cookie_wait, /* SCTP_CONNTRACK_COOKIE_WAIT */ ··· 118 */ 119 120 /* SCTP conntrack state transitions */ 121 + static const enum sctp_conntrack sctp_conntracks[2][9][SCTP_CONNTRACK_MAX] = { 122 { 123 /* ORIGINAL */ 124 /* sNO, sCL, sCW, sCE, sES, sSS, sSR, sSA */
+3 -3
net/ipv4/netfilter/ip_conntrack_proto_tcp.c
··· 99 to ~13-30min depending on RTO. */ 100 unsigned long ip_ct_tcp_timeout_max_retrans = 5 MINS; 101 102 - static unsigned long * tcp_timeouts[] 103 = { NULL, /* TCP_CONNTRACK_NONE */ 104 &ip_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */ 105 &ip_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */ ··· 170 * if they are invalid 171 * or we do not support the request (simultaneous open) 172 */ 173 - static enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = { 174 { 175 /* ORIGINAL */ 176 /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ ··· 817 #define TH_CWR 0x80 818 819 /* table of valid flag combinations - ECE and CWR are always valid */ 820 - static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] = 821 { 822 [TH_SYN] = 1, 823 [TH_SYN|TH_ACK] = 1,
··· 99 to ~13-30min depending on RTO. */ 100 unsigned long ip_ct_tcp_timeout_max_retrans = 5 MINS; 101 102 + static const unsigned long * tcp_timeouts[] 103 = { NULL, /* TCP_CONNTRACK_NONE */ 104 &ip_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */ 105 &ip_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */ ··· 170 * if they are invalid 171 * or we do not support the request (simultaneous open) 172 */ 173 + static const enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = { 174 { 175 /* ORIGINAL */ 176 /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ ··· 817 #define TH_CWR 0x80 818 819 /* table of valid flag combinations - ECE and CWR are always valid */ 820 + static const u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] = 821 { 822 [TH_SYN] = 1, 823 [TH_SYN|TH_ACK] = 1,
+1 -1
net/ipv4/netfilter/ip_tables.c
··· 1892 return pos; 1893 } 1894 1895 - static struct { char *name; get_info_t *get_info; } ipt_proc_entry[] = 1896 { { "ip_tables_names", ipt_get_tables }, 1897 { "ip_tables_targets", ipt_get_targets }, 1898 { "ip_tables_matches", ipt_get_matches },
··· 1892 return pos; 1893 } 1894 1895 + static const struct { char *name; get_info_t *get_info; } ipt_proc_entry[] = 1896 { { "ip_tables_names", ipt_get_tables }, 1897 { "ip_tables_targets", ipt_get_targets }, 1898 { "ip_tables_matches", ipt_get_matches },
+1 -1
net/ipv4/netfilter/ipt_LOG.c
··· 197 } 198 case IPPROTO_ICMP: { 199 struct icmphdr _icmph, *ich; 200 - static size_t required_len[NR_ICMP_TYPES+1] 201 = { [ICMP_ECHOREPLY] = 4, 202 [ICMP_DEST_UNREACH] 203 = 8 + sizeof(struct iphdr),
··· 197 } 198 case IPPROTO_ICMP: { 199 struct icmphdr _icmph, *ich; 200 + static const size_t required_len[NR_ICMP_TYPES+1] 201 = { [ICMP_ECHOREPLY] = 4, 202 [ICMP_DEST_UNREACH] 203 = 8 + sizeof(struct iphdr),
+5 -5
net/ipv4/proc.c
··· 98 } 99 100 /* snmp items */ 101 - static struct snmp_mib snmp4_ipstats_list[] = { 102 SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INRECEIVES), 103 SNMP_MIB_ITEM("InHdrErrors", IPSTATS_MIB_INHDRERRORS), 104 SNMP_MIB_ITEM("InAddrErrors", IPSTATS_MIB_INADDRERRORS), ··· 119 SNMP_MIB_SENTINEL 120 }; 121 122 - static struct snmp_mib snmp4_icmp_list[] = { 123 SNMP_MIB_ITEM("InMsgs", ICMP_MIB_INMSGS), 124 SNMP_MIB_ITEM("InErrors", ICMP_MIB_INERRORS), 125 SNMP_MIB_ITEM("InDestUnreachs", ICMP_MIB_INDESTUNREACHS), ··· 149 SNMP_MIB_SENTINEL 150 }; 151 152 - static struct snmp_mib snmp4_tcp_list[] = { 153 SNMP_MIB_ITEM("RtoAlgorithm", TCP_MIB_RTOALGORITHM), 154 SNMP_MIB_ITEM("RtoMin", TCP_MIB_RTOMIN), 155 SNMP_MIB_ITEM("RtoMax", TCP_MIB_RTOMAX), ··· 167 SNMP_MIB_SENTINEL 168 }; 169 170 - static struct snmp_mib snmp4_udp_list[] = { 171 SNMP_MIB_ITEM("InDatagrams", UDP_MIB_INDATAGRAMS), 172 SNMP_MIB_ITEM("NoPorts", UDP_MIB_NOPORTS), 173 SNMP_MIB_ITEM("InErrors", UDP_MIB_INERRORS), ··· 175 SNMP_MIB_SENTINEL 176 }; 177 178 - static struct snmp_mib snmp4_net_list[] = { 179 SNMP_MIB_ITEM("SyncookiesSent", LINUX_MIB_SYNCOOKIESSENT), 180 SNMP_MIB_ITEM("SyncookiesRecv", LINUX_MIB_SYNCOOKIESRECV), 181 SNMP_MIB_ITEM("SyncookiesFailed", LINUX_MIB_SYNCOOKIESFAILED),
··· 98 } 99 100 /* snmp items */ 101 + static const struct snmp_mib snmp4_ipstats_list[] = { 102 SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INRECEIVES), 103 SNMP_MIB_ITEM("InHdrErrors", IPSTATS_MIB_INHDRERRORS), 104 SNMP_MIB_ITEM("InAddrErrors", IPSTATS_MIB_INADDRERRORS), ··· 119 SNMP_MIB_SENTINEL 120 }; 121 122 + static const struct snmp_mib snmp4_icmp_list[] = { 123 SNMP_MIB_ITEM("InMsgs", ICMP_MIB_INMSGS), 124 SNMP_MIB_ITEM("InErrors", ICMP_MIB_INERRORS), 125 SNMP_MIB_ITEM("InDestUnreachs", ICMP_MIB_INDESTUNREACHS), ··· 149 SNMP_MIB_SENTINEL 150 }; 151 152 + static const struct snmp_mib snmp4_tcp_list[] = { 153 SNMP_MIB_ITEM("RtoAlgorithm", TCP_MIB_RTOALGORITHM), 154 SNMP_MIB_ITEM("RtoMin", TCP_MIB_RTOMIN), 155 SNMP_MIB_ITEM("RtoMax", TCP_MIB_RTOMAX), ··· 167 SNMP_MIB_SENTINEL 168 }; 169 170 + static const struct snmp_mib snmp4_udp_list[] = { 171 SNMP_MIB_ITEM("InDatagrams", UDP_MIB_INDATAGRAMS), 172 SNMP_MIB_ITEM("NoPorts", UDP_MIB_NOPORTS), 173 SNMP_MIB_ITEM("InErrors", UDP_MIB_INERRORS), ··· 175 SNMP_MIB_SENTINEL 176 }; 177 178 + static const struct snmp_mib snmp4_net_list[] = { 179 SNMP_MIB_ITEM("SyncookiesSent", LINUX_MIB_SYNCOOKIESSENT), 180 SNMP_MIB_ITEM("SyncookiesRecv", LINUX_MIB_SYNCOOKIESRECV), 181 SNMP_MIB_ITEM("SyncookiesFailed", LINUX_MIB_SYNCOOKIESFAILED),
+1 -1
net/ipv4/route.c
··· 1371 * are needed for AMPRnet AX.25 paths. 1372 */ 1373 1374 - static unsigned short mtu_plateau[] = 1375 {32000, 17914, 8166, 4352, 2002, 1492, 576, 296, 216, 128 }; 1376 1377 static __inline__ unsigned short guess_mtu(unsigned short old_mtu)
··· 1371 * are needed for AMPRnet AX.25 paths. 1372 */ 1373 1374 + static const unsigned short mtu_plateau[] = 1375 {32000, 17914, 8166, 4352, 2002, 1492, 576, 296, 216, 128 }; 1376 1377 static __inline__ unsigned short guess_mtu(unsigned short old_mtu)
+1 -1
net/ipv4/tcp.c
··· 1413 * closed. 1414 */ 1415 1416 - static unsigned char new_state[16] = { 1417 /* current state: new state: action: */ 1418 /* (Invalid) */ TCP_CLOSE, 1419 /* TCP_ESTABLISHED */ TCP_FIN_WAIT1 | TCP_ACTION_FIN,
··· 1413 * closed. 1414 */ 1415 1416 + static const unsigned char new_state[16] = { 1417 /* current state: new state: action: */ 1418 /* (Invalid) */ TCP_CLOSE, 1419 /* TCP_ESTABLISHED */ TCP_FIN_WAIT1 | TCP_ACTION_FIN,
+1 -1
net/ipv6/icmp.c
··· 751 inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); 752 } 753 754 - static struct icmp6_err { 755 int err; 756 int fatal; 757 } tab_unreach[] = {
··· 751 inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); 752 } 753 754 + static const struct icmp6_err { 755 int err; 756 int fatal; 757 } tab_unreach[] = {
+1 -1
net/ipv6/netfilter/ip6_tables.c
··· 1972 return pos; 1973 } 1974 1975 - static struct { char *name; get_info_t *get_info; } ip6t_proc_entry[] = 1976 { { "ip6_tables_names", ip6t_get_tables }, 1977 { "ip6_tables_targets", ip6t_get_targets }, 1978 { "ip6_tables_matches", ip6t_get_matches },
··· 1972 return pos; 1973 } 1974 1975 + static const struct { char *name; get_info_t *get_info; } ip6t_proc_entry[] = 1976 { { "ip6_tables_names", ip6t_get_tables }, 1977 { "ip6_tables_targets", ip6t_get_targets }, 1978 { "ip6_tables_matches", ip6t_get_matches },