Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jun 2009 01:31:59 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194935 - in head/sys: kern sys
Message-ID:  <200906250131.n5P1VxnP036297@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jeff
Date: Thu Jun 25 01:31:59 2009
New Revision: 194935
URL: http://svn.freebsd.org/changeset/base/194935

Log:
   - Add a sysctl_dpcpu_long to support long typed pcpu stats.
   - Remove the #ifndef SMP case as the SMP code works on UP as well.
  
  Reviewed by:	sam

Modified:
  head/sys/kern/subr_pcpu.c
  head/sys/sys/sysctl.h

Modified: head/sys/kern/subr_pcpu.c
==============================================================================
--- head/sys/kern/subr_pcpu.c	Thu Jun 25 00:28:43 2009	(r194934)
+++ head/sys/kern/subr_pcpu.c	Thu Jun 25 01:31:59 2009	(r194935)
@@ -264,9 +264,8 @@ pcpu_find(u_int cpuid)
 int
 sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS)
 {
-	int64_t count;
-#ifdef SMP
 	uintptr_t dpcpu;
+	int64_t count;
 	int i;
 
 	count = 0;
@@ -276,18 +275,31 @@ sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS)
 			continue;
 		count += *(int64_t *)(dpcpu + (uintptr_t)arg1);
 	}
-#else
-	count = *(int64_t *)(dpcpu_off[0] + (uintptr_t)arg1);
-#endif
+	return (SYSCTL_OUT(req, &count, sizeof(count)));
+}
+
+int
+sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS)
+{
+	uintptr_t dpcpu;
+	long count;
+	int i;
+
+	count = 0;
+	for (i = 0; i < mp_ncpus; ++i) {
+		dpcpu = dpcpu_off[i];
+		if (dpcpu == 0)
+			continue;
+		count += *(long *)(dpcpu + (uintptr_t)arg1);
+	}
 	return (SYSCTL_OUT(req, &count, sizeof(count)));
 }
 
 int
 sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS)
 {
-	int count;
-#ifdef SMP
 	uintptr_t dpcpu;
+	int count;
 	int i;
 
 	count = 0;
@@ -297,9 +309,6 @@ sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS)
 			continue;
 		count += *(int *)(dpcpu + (uintptr_t)arg1);
 	}
-#else
-	count = *(int *)(dpcpu_off[0] + (uintptr_t)arg1);
-#endif
 	return (SYSCTL_OUT(req, &count, sizeof(count)));
 }
 

Modified: head/sys/sys/sysctl.h
==============================================================================
--- head/sys/sys/sysctl.h	Thu Jun 25 00:28:43 2009	(r194934)
+++ head/sys/sys/sysctl.h	Thu Jun 25 01:31:59 2009	(r194935)
@@ -179,6 +179,7 @@ int sysctl_handle_string(SYSCTL_HANDLER_
 int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
 
 int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS);
+int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS);
 int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS);
 
 #ifdef VIMAGE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906250131.n5P1VxnP036297>