aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorLawrence Stewart <lstewart@FreeBSD.org>2010-06-13 02:39:55 +0000
committerLawrence Stewart <lstewart@FreeBSD.org>2010-06-13 02:39:55 +0000
commit5ad333cf624a9aa3792118cf16c3f6d5aaf8f5ee (patch)
treeac0bd3aba4ff73a8dc19df84ac99938737389f60 /sys/sys/pcpu.h
parent4c3cf697274fe222dd11c0f3c12c803dbb0310a0 (diff)
downloadsrc-5ad333cf624a9aa3792118cf16c3f6d5aaf8f5ee.tar.gz
src-5ad333cf624a9aa3792118cf16c3f6d5aaf8f5ee.zip
Add a utility macro to simplify calculating an aggregate sum from a DPCPU
counter variable. Sponsored by: FreeBSD Foundation Reviewed by: jhb, rpaulo, rwatson (previous version of patch) MFC after: 1 week
Notes
Notes: svn path=/head/; revision=209119
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 1ee7717e2fd7..472a658bfd40 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -106,6 +106,17 @@ extern uintptr_t dpcpu_off[];
#define DPCPU_ID_GET(i, n) (*DPCPU_ID_PTR(i, n))
#define DPCPU_ID_SET(i, n, v) (*DPCPU_ID_PTR(i, n) = v)
+/*
+ * Utility macros.
+ */
+#define DPCPU_SUM(n, var, sum) \
+do { \
+ (sum) = 0; \
+ u_int i; \
+ CPU_FOREACH(i) \
+ (sum) += (DPCPU_ID_PTR(i, n))->var; \
+} while (0)
+
/*
* XXXUPS remove as soon as we have per cpu variable
* linker sets and can define rm_queue in _rm_lock.h