net: mark some potential candidates __read_mostly
Subsystems (4)
PATCH 1/1 net: mark some potential candidates __read_mostly
They are all either written once or extremly rarely (e.g. from init code), so we can move them to the .data..read_mostly section.
--- drivers/net/ipvlan/ipvlan_core.c | 2 +- net/bridge/br_netlink.c | 2 +- net/ipv4/devinet.c | 2 +- net/ipv6/addrconf.c | 2 +- net/mpls/mpls_gso.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ipvlan/ipvlan_core.c +1 -1
@@ -9,7 +9,7 @@#include "ipvlan.h" -static u32 ipvlan_jhash_secret; +static u32 ipvlan_jhash_secret__read_mostly ;void ipvlan_init_secret (void ) {
net/bridge/br_netlink.c +1 -1
@@ -701,7 +701,7 @@ static size_t br_get_link_af_size(const struct net_device *dev)return pv->num_vlans *nla_total_size (sizeof (struct bridge_vlan_info )); } -static struct rtnl_af_ops br_af_ops = { +static struct rtnl_af_ops br_af_ops__read_mostly = { .family =AF_BRIDGE , .get_link_af_size = br_get_link_af_size, };
net/ipv4/devinet.c +1 -1
@@ -2322,7 +2322,7 @@ static __net_initdata struct pernet_operations devinet_ops = { .exit = devinet_exit_net, }; -static struct rtnl_af_ops inet_af_ops = { +static struct rtnl_af_ops inet_af_ops__read_mostly = { .family =AF_INET , .fill_link_af = inet_fill_link_af, .get_link_af_size = inet_get_link_af_size,
net/ipv6/addrconf.c +1 -1
@@ -5405,7 +5405,7 @@ static struct pernet_operations addrconf_ops = { .exit = addrconf_exit_net, }; -static struct rtnl_af_ops inet6_ops = { +static struct rtnl_af_ops inet6_ops__read_mostly = { .family =AF_INET6 , .fill_link_af = inet6_fill_link_af, .get_link_af_size = inet6_get_link_af_size,
net/mpls/mpls_gso.c +2 -2
@@ -60,14 +60,14 @@ out:return segs; } -static struct packet_offload mpls_mc_offload = { +static struct packet_offload mpls_mc_offload__read_mostly = { .type =cpu_to_be16 (ETH_P_MPLS_MC ), .callbacks = { .gso_segment = mpls_gso_segment, }, }; -static struct packet_offload mpls_uc_offload = { +static struct packet_offload mpls_uc_offload__read_mostly = { .type =cpu_to_be16 (ETH_P_MPLS_UC ), .callbacks = { .gso_segment = mpls_gso_segment,
Signature · 1 line
1.7.11.7
Quoted 30 lines · Daniel Borkmann
They are all either written once or extremly rarely (e.g. from init code), so we can move them to the .data..read_mostly section.
Signed-off-by Daniel Borkmann <[email protected]>--- drivers/net/ipvlan/ipvlan_core.c | 2 +- net/bridge/br_netlink.c | 2 +- net/ipv4/devinet.c | 2 +- net/ipv6/addrconf.c | 2 +- net/mpls/mpls_gso.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-)drivers/net/ipvlan/ipvlan_core.c +1
-1@@ -9,7 +9,7 @@#include "ipvlan.h" -static u32 ipvlan_jhash_secret; +static u32 ipvlan_jhash_secret__read_mostly ;void ipvlan_init_secret (void ) {net/bridge/br_netlink.c +0
-0
net/bridge/br_netlink.c static size_t br_get_link_af_size(const struct net_device *dev) · line 707
Quoted 8 lines
net/bridge/br_netlink.c +1
-1@@ -701,7 +701,7 @@ static size_t br_get_link_af_size(const struct net_device *dev)return pv->num_vlans *nla_total_size (sizeof (struct bridge_vlan_info )); } -static struct rtnl_af_ops br_af_ops = { +static struct rtnl_af_ops br_af_ops__read_mostly = { .family =AF_BRIDGE , .get_link_af_size = br_get_link_af_size, };
Why not const?
net/ipv4/devinet.c static __net_initdata struct pernet_operations devinet_ops = { · line 2328
Quoted 13 lines
net/ipv4/devinet.c +1
-1@@ -2322,7 +2322,7 @@ static __net_initdata struct pernet_operations devinet_ops = { .exit = devinet_exit_net, }; -static struct rtnl_af_ops inet_af_ops = { +static struct rtnl_af_ops inet_af_ops__read_mostly = { .family =AF_INET , .fill_link_af = inet_fill_link_af, .get_link_af_size = inet_get_link_af_size,
Const?
net/ipv6/addrconf.c static struct pernet_operations addrconf_ops = { · line 5411
Quoted 13 lines
net/ipv6/addrconf.c +1
-1@@ -5405,7 +5405,7 @@ static struct pernet_operations addrconf_ops = { .exit = addrconf_exit_net, }; -static struct rtnl_af_ops inet6_ops = { +static struct rtnl_af_ops inet6_ops__read_mostly = { .family =AF_INET6 , .fill_link_af = inet6_fill_link_af, .get_link_af_size = inet6_get_link_af_size,
Const?
Quoted 21 lines
net/mpls/mpls_gso.c +2
-2@@ -60,14 +60,14 @@ out:return segs; } -static struct packet_offload mpls_mc_offload = { +static struct packet_offload mpls_mc_offload__read_mostly = { .type =cpu_to_be16 (ETH_P_MPLS_MC ), .callbacks = { .gso_segment = mpls_gso_segment, }, }; -static struct packet_offload mpls_uc_offload = { +static struct packet_offload mpls_uc_offload__read_mostly = { .type =cpu_to_be16 (ETH_P_MPLS_UC ), .callbacks = { .gso_segment = mpls_gso_segment,
On 01/29/2015 04:40 PM, Hannes Frederic Sowa wrote:
...
Quoted 1 line
Why not const?
Because all these candidates have a list member and are being registered at respective places during __init/__exit. Similar structs in other places already have __read_mostly, but these ones can still be converted to it.
Cheers,
Daniel
From: Daniel Borkmann <[email protected]>
Date: Thu, 29 Jan 2015 12:15:03 +0100
Quoted 4 lines
They are all either written once or extremly rarely (e.g. from init code), so we can move them to the .data..read_mostly section.
Signed-off-by Daniel Borkmann <[email protected]>
Applied, thanks Daniel.