about summary refs log tree commit homepage
path: root/queue_common.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-03-09 01:23:24 +0000
committerEric Wong <normalperson@yhbt.net>2012-03-08 17:23:49 -0800
commit0a66ba54d4f78cb53f438f6ec0d0adeb768bc132 (patch)
tree84bf9c98a2c262d3268acd27de3bf2fee3f5df1d /queue_common.c
parentd2e281bb9718a7a4a49fb87a1851123bbce2a2dc (diff)
downloadcmogstored-0a66ba54d4f78cb53f438f6ec0d0adeb768bc132.tar.gz
We want locks away from the actual data it protects so updates
to the lock (or data) don't unnecessarily trigger relatively
SMP memory synchronization.  This means nothing for CPUs with
128 byte cache lines, but should help CPUs with 64/32-byte
cache lines.
Diffstat (limited to 'queue_common.c')
-rw-r--r--queue_common.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/queue_common.c b/queue_common.c
index 4372dc4..9de1100 100644
--- a/queue_common.c
+++ b/queue_common.c
@@ -5,6 +5,19 @@
 #include "cmogstored.h"
 
 /*
+ * we want activeq_lock to be on a different cache line than
+ * activeq_head and active_fd so we don't end up triggering
+ * synchronization if a lock is contended.  We try to ensure
+ * 64-bit(+) CPUs get past a (common) cache line size of 64
+ * and 32-bit CPUs have a cache line size of 32.
+ *
+ * 128 byte cache lines seem to be getting rarer and (probably)
+ * aren't worth optimizing for. (struct mog_fd is 128-bytes itself)
+ */
+verify(offsetof(struct mog_fd, as.queue.activeq_lock)
+       >= (sizeof(long) >= 8 ? 64 : 32));
+
+/*
  * access to this should only be called in the main thread, this
  * is currently not thread safe as there's no need for it.
  */