[netperf-dev] netperf2 commit notice r348 - in trunk: . src

raj at netperf.org raj at netperf.org
Tue Apr 27 17:19:43 PDT 2010


Author: raj
Date: 2010-04-27 17:19:42 -0700 (Tue, 27 Apr 2010)
New Revision: 348

Modified:
   trunk/config.h.in
   trunk/src/netcpu_pstatnew.c
   trunk/src/nettest_omni.c
Log:
fixup hpux cpu utilization and add some multicast stuff

Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in	2010-03-16 00:23:43 UTC (rev 347)
+++ trunk/config.h.in	2010-04-28 00:19:42 UTC (rev 348)
@@ -226,6 +226,9 @@
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
+/* Define to 1 if you have the <sys/sysinfo.h> header file. */
+#undef HAVE_SYS_SYSINFO_H
+
 /* Define to 1 if you have the <sys/time.h> header file. */
 #undef HAVE_SYS_TIME_H
 
@@ -274,6 +277,9 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
@@ -382,5 +388,3 @@
 
 /* Define as `fork' if `vfork' does not work. */
 #undef vfork
-
-#undef HAVE_SYS_SYSINFO_H

Modified: trunk/src/netcpu_pstatnew.c
===================================================================
--- trunk/src/netcpu_pstatnew.c	2010-03-16 00:23:43 UTC (rev 347)
+++ trunk/src/netcpu_pstatnew.c	2010-04-28 00:19:42 UTC (rev 348)
@@ -60,9 +60,31 @@
 static cpu_time_counters_t  ending_cpu_counters[MAXCPUS];
 static cpu_time_counters_t  delta_cpu_counters[MAXCPUS];
 
+/* there can be more "processors" in the system than are actually
+   online. so, we can either walk all the processors one at a time,
+   which would be slow, or we can track not just lib_num_loc_cpu,
+   which is the number of active "processors" but also the total
+   number, and retrieve all of them at one shot and walk the list
+   once, ignoring those that are offline.  we will ass-u-me there is
+   no change to the number of processors online while we are running
+   or there will be strange things happening to CPU utilization. raj
+   2010-04-27 */
+
+static long max_proc_count;
+
 void
 cpu_util_init(void) 
 {
+  struct pst_dynamic psd;
+  if (pstat_getdynamic((struct pst_dynamic *)&psd,
+                       (size_t)sizeof(psd), (size_t)1, 0) != -1) {
+    max_proc_count = psd.psd_max_proc_cnt;
+  }
+  else {
+    /* we hope this never happens */
+    max_proc_count = lib_num_loc_cpus;
+  }
+
   return;
 }
 
@@ -89,20 +111,31 @@
 	 2005/09/06 */ 
       struct pst_processor *psp;
 
-      psp = (struct pst_processor *)malloc(lib_num_loc_cpus * sizeof(*psp));
+      /* to handle the cases of "processors" present but disabled, we
+	 will have to allocate a buffer big enough for everyone and
+	 then walk the entire list, pulling data for those which are
+	 online, assuming the processors online have not changed in
+	 the middle of the run. raj 2010-04-27 */
+      psp = (struct pst_processor *)malloc(max_proc_count * sizeof(*psp));
       if (psp == NULL) {
-        printf("malloc(%d) failed!\n", lib_num_loc_cpus * sizeof(*psp));
+        printf("malloc(%d) failed!\n", max_proc_count * sizeof(*psp));
         exit(1);
-	  }
-      if (pstat_getprocessor(psp, sizeof(*psp), lib_num_loc_cpus, 0) != -1) {
-        int i;
+      }
+      if (pstat_getprocessor(psp, sizeof(*psp), max_proc_count, 0) != -1) {
+        int i,j;
 	/* we use lib_iticksperclktick in our sanity checking. we
 	   ass-u-me it is the same value for each CPU - famous last
 	   words no doubt. raj 2005/09/06 */
 	lib_iticksperclktick = psp[0].psp_iticksperclktick;
-        for (i = 0; i < lib_num_loc_cpus; i++) {
-          res[i].idle = (((uint64_t)psp[i].psp_idlecycles.psc_hi << 32) +
-			 psp[i].psp_idlecycles.psc_lo);
+	i = j = 0;
+	while ((i < lib_num_loc_cpus) && (j < max_proc_count)) {
+	  if (psp[j].psp_processor_state == PSP_SPU_DISABLED) {
+	    j++;
+	    continue;
+	  }
+	  /* we know that psp[j] is online */
+          res[i].idle = (((uint64_t)psp[j].psp_idlecycles.psc_hi << 32) +
+			 psp[j].psp_idlecycles.psc_lo);
           if(debug) {
             fprintf(where,
                     "\tidle[%d] = 0x%"PRIx64" ",
@@ -110,8 +143,8 @@
                     res[i].idle);
             fflush(where);
           }
-          res[i].user = (((uint64_t)psp[i].psp_usercycles.psc_hi << 32) +
-			 psp[i].psp_usercycles.psc_lo);
+          res[i].user = (((uint64_t)psp[j].psp_usercycles.psc_hi << 32) +
+			 psp[j].psp_usercycles.psc_lo);
           if(debug) {
             fprintf(where,
                     "user[%d] = 0x%"PRIx64" ",
@@ -119,8 +152,8 @@
                     res[i].user);
             fflush(where);
           }
-          res[i].kernel = (((uint64_t)psp[i].psp_systemcycles.psc_hi << 32) +
-			    psp[i].psp_systemcycles.psc_lo);
+          res[i].kernel = (((uint64_t)psp[j].psp_systemcycles.psc_hi << 32) +
+			    psp[j].psp_systemcycles.psc_lo);
           if(debug) {
             fprintf(where,
                     "kern[%d] = 0x%"PRIx64" ",
@@ -128,8 +161,8 @@
                     res[i].kernel);
             fflush(where);
           }
-          res[i].interrupt = (((uint64_t)psp[i].psp_interruptcycles.psc_hi << 32) +
-			      psp[i].psp_interruptcycles.psc_lo);
+          res[i].interrupt = (((uint64_t)psp[j].psp_interruptcycles.psc_hi << 32) +
+			      psp[j].psp_interruptcycles.psc_lo);
           if(debug) {
             fprintf(where,
                     "intr[%d] = 0x%"PRIx64"\n",
@@ -137,7 +170,9 @@
                     res[i].interrupt);
             fflush(where);
           }
-        }
+	  i++;
+	  j++;
+	}
         free(psp);
       }
 }

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2010-03-16 00:23:43 UTC (rev 347)
+++ trunk/src/nettest_omni.c	2010-04-28 00:19:42 UTC (rev 348)
@@ -717,6 +717,34 @@
   }
 }
 
+static void
+set_multicast_ttl(SOCKET sock) {
+  int optlen = sizeof(int);
+
+  /* now set/get the TTL */
+  if (multicast_ttl >= 0) {
+    if (setsockopt(sock,
+		   IPPROTO_IP,
+		   IP_TTL,
+		   &multicast_ttl,
+		   sizeof(multicast_ttl)) < 0) {
+      fprintf(where,
+	      "setsockopt(IP_TTL) failed errno %d\n",
+	      errno);
+    }
+  }
+  if (getsockopt(sock,
+		 IPPROTO_IP,
+		 IP_TTL,
+		 &multicast_ttl,
+		 &optlen) < 0) {
+    fprintf(where,
+	    "getsockopt(IP_TTL) failed errno %d\n",
+	    errno);
+    multicast_ttl = -2;
+  }
+}
+
 /* we presume we are only called with something which is actually a
    multicast address. raj 20100315 */
 static void
@@ -4252,37 +4280,43 @@
        and send buffer rings. we should only need to do this once, and
        that would be when the relevant _ring variable is NULL. raj
        2008-01-18 */
-    if ((direction & NETPERF_XMIT) && (NULL == send_ring)) {
-      if (req_size > 0) {
-	/* request/response test */
-	if (send_width == 0) send_width = 1;
-	bytes_to_send = req_size;
+    if (direction & NETPERF_XMIT) {
+      if (is_multicast_addr(remote_res)) {
+	set_multicast_ttl(data_socket);
       }
-      else {
-	/* stream test */
-	if (send_size == 0) {
-	  if (lss_size > 0) {
-	    send_size = lss_size;
+
+      if (NULL == send_ring) {
+	if (req_size > 0) {
+	  /* request/response test */
+	  if (send_width == 0) send_width = 1;
+	  bytes_to_send = req_size;
+	}
+	else {
+	  /* stream test */
+	  if (send_size == 0) {
+	    if (lss_size > 0) {
+	      send_size = lss_size;
+	    }
+	    else {
+	      send_size = 4096;
+	    }
 	  }
-	  else {
-	    send_size = 4096;
-	  }
+	  if (send_width == 0) 
+	    send_width = (lss_size/send_size) + 1;
+	  if (send_width == 1) send_width++;
+	  bytes_to_send = send_size;
 	}
-	if (send_width == 0) 
-	  send_width = (lss_size/send_size) + 1;
-	if (send_width == 1) send_width++;
-	bytes_to_send = send_size;
+	
+	send_ring = allocate_buffer_ring(send_width,
+					 bytes_to_send,
+					 local_send_align,
+					 local_send_offset);
+	if (debug) {
+	  fprintf(where,
+		  "send_omni: %d entry send_ring obtained...\n",
+		  send_width);
+	}
       }
-      
-      send_ring = allocate_buffer_ring(send_width,
-				       bytes_to_send,
-				       local_send_align,
-				       local_send_offset);
-      if (debug) {
-	fprintf(where,
-		"send_omni: %d entry send_ring obtained...\n",
-		send_width);
-      }
     }
     
     if (direction & NETPERF_RECV) {
@@ -5401,6 +5435,15 @@
   omni_response->send_size = omni_request->send_size;
   omni_response->send_width = omni_request->send_width;
   if (omni_request->direction & NETPERF_XMIT) {
+#ifdef fo
+    /* do we need to set multicast ttl? */
+    if (is_multicast_addr(remote_res)) {
+      /* yes, s_listen - for a UDP test we will be copying it to
+	 data_socket but that hasn't happened yet. raj 20100315 */
+      set_multicast_ttl(s_listen);
+    }
+#endif
+
     if (omni_request->response_size > 0) {
       /* request/response_test */
       bytes_to_send = omni_request->response_size;



More information about the netperf-dev mailing list