From: Mikael Pettersson <mikpe@csd.uu.se>

This set of patches changes perfctr's low-level drivers to indicate changes to
the mmap:ed counter state via a unified seqlock mechanism.  This cleans up
user-space, enables user-space fast sampling in some previously impossible
cases (x86 w/o TSC), and eliminates a highly unlikely but not impossible
failure case on x86 SMP.

This is a rewrite of a patch originally from David Gibson.

perfctr seqlocks 1/4: common changes
- define write_perfseq_begin/end in <linux/perfctr.h>
- bump version and sync it with current user-space package

Signed-off-by: Mikael Pettersson <mikpe@csd.uu.se>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/perfctr/version.h |    2 +-
 include/linux/perfctr.h   |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff -puN drivers/perfctr/version.h~perfctr-seqlocks-for-mmaped-state-common drivers/perfctr/version.h
--- 25/drivers/perfctr/version.h~perfctr-seqlocks-for-mmaped-state-common	2005-05-26 22:57:36.000000000 -0700
+++ 25-akpm/drivers/perfctr/version.h	2005-05-26 22:57:36.000000000 -0700
@@ -1 +1 @@
-#define VERSION "2.7.15"
+#define VERSION "2.7.17"
diff -puN include/linux/perfctr.h~perfctr-seqlocks-for-mmaped-state-common include/linux/perfctr.h
--- 25/include/linux/perfctr.h~perfctr-seqlocks-for-mmaped-state-common	2005-05-26 22:57:36.000000000 -0700
+++ 25-akpm/include/linux/perfctr.h	2005-05-26 22:57:36.000000000 -0700
@@ -154,6 +154,23 @@ static inline void perfctr_set_cpus_allo
 
 #endif	/* CONFIG_PERFCTR_VIRTUAL */
 
+/* These routines are identical to write_seqcount_begin() and
+ * write_seqcount_end(), except they take an explicit __u32 rather
+ * than a seqcount_t.  That's because this sequence lock is user from
+ * userspace, so we have to pin down the counter's type explicitly to
+ * have a clear ABI.  They also omit the SMP write barriers since we
+ * only support mmap() based sampling for self-monitoring tasks.
+ */
+static inline void write_perfseq_begin(__u32 *seq)
+{
+	++*seq;
+}
+
+static inline void write_perfseq_end(__u32 *seq)
+{
+	++*seq;
+}
+
 #endif	/* __KERNEL__ */
 
 #endif	/* _LINUX_PERFCTR_H */
_