[ovs-dev] [PATCH 07/14] datapath: Use __read_mostly annotations where appropriate.
Jesse Gross
jesse at nicira.com
Thu Dec 2 20:36:56 UTC 2010
Variables which are changed only infrequently should be annotated
with __read_mostly, which will group them together in a special
linker section. This prevents them from sharing cache lines with
data on the hot path.
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
datapath/datapath.c | 1 -
datapath/flow.c | 2 +-
datapath/tunnel.c | 10 +++++-----
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 522d4ec..bed4803 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -54,7 +54,6 @@
#include "compat.h"
-
int (*dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
EXPORT_SYMBOL(dp_ioctl_hook);
diff --git a/datapath/flow.c b/datapath/flow.c
index 496f11c..d30fb73 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -32,7 +32,7 @@
#include "compat.h"
struct kmem_cache *flow_cache;
-static unsigned int hash_seed;
+static unsigned int hash_seed __read_mostly;
static inline bool arphdr_ok(struct sk_buff *skb)
{
diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index 0671853..2a959ae 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -68,7 +68,7 @@
#define CACHE_DATA_ALIGN 16
/* Protected by RCU. */
-static struct tbl *port_table;
+static struct tbl *port_table __read_mostly;
static void cache_cleaner(struct work_struct *work);
DECLARE_DELAYED_WORK(cache_cleaner_wq, cache_cleaner);
@@ -78,10 +78,10 @@ DECLARE_DELAYED_WORK(cache_cleaner_wq, cache_cleaner);
* synchronization because we could have just as easily read the value before
* the port change happened.
*/
-static unsigned int key_local_remote_ports;
-static unsigned int key_remote_ports;
-static unsigned int local_remote_ports;
-static unsigned int remote_ports;
+static unsigned int key_local_remote_ports __read_mostly;
+static unsigned int key_remote_ports __read_mostly;
+static unsigned int local_remote_ports __read_mostly;
+static unsigned int remote_ports __read_mostly;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
#define rt_dst(rt) (rt->dst)
--
1.7.1
More information about the dev
mailing list