svn commit: r209790 - stable/8/sys/sys

Lawrence Stewart lstewart at FreeBSD.org
Thu Jul 8 03:41:58 UTC 2010


Author: lstewart
Date: Thu Jul  8 03:41:57 2010
New Revision: 209790
URL: http://svn.freebsd.org/changeset/base/209790

Log:
  MFC r209119,209325:
  
  - Add a utility macro to simplify calculating an aggregate sum from a DPCPU
    counter variable.
  
  - Rename the internal for loop iterator to "_i" to avoid potential shadowing of
    external variables named "i". The "_" prefix is reserved for infrastructure
    type code and is therefore not expected to be used by normal code likely to
    call DPCPU_SUM(). [1]
  
  - Change DPCPU_SUM to return the sum rather than calculate and assign it
    internally. Usage is now: "sum = DPCPU_SUM(dpcpu_var, member_to_sum);" [2]
  
  - Fix some style nits. [3]
  
  Sponsored by:	FreeBSD Foundation
  Suggested by:	bde [3], mdf [1], kib [1,2], pjd [1,3]
  Reviewed by:	jhb, rpaulo, rwatson (old version of r209119), kib (r209325)

Modified:
  stable/8/sys/sys/pcpu.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/sys/pcpu.h
==============================================================================
--- stable/8/sys/sys/pcpu.h	Thu Jul  8 03:35:00 2010	(r209789)
+++ stable/8/sys/sys/pcpu.h	Thu Jul  8 03:41:57 2010	(r209790)
@@ -109,6 +109,21 @@ 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) __extension__					\
+({									\
+	u_int _i;							\
+	__typeof((DPCPU_PTR(n))->var) sum;				\
+									\
+	sum = 0;							\
+	CPU_FOREACH(_i) {						\
+		sum += (DPCPU_ID_PTR(_i, n))->var;			\
+	}								\
+	sum;								\
+})
+
 /* 
  * XXXUPS remove as soon as we have per cpu variable
  * linker sets and  can define rm_queue in _rm_lock.h


More information about the svn-src-all mailing list