[netperf-dev] netperf4 commit notice r188 - trunk/src
raj at netperf.org
raj at netperf.org
Wed Jun 28 17:25:02 PDT 2006
Author: raj
Date: 2006-06-28 17:24:59 -0700 (Wed, 28 Jun 2006)
New Revision: 188
Modified:
trunk/src/netlib.c
trunk/src/netlib_kstat10.c
Log:
Processor affinity (proc and pset) for Solaris
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2006-06-28 22:36:06 UTC (rev 187)
+++ trunk/src/netlib.c 2006-06-29 00:24:59 UTC (rev 188)
@@ -1619,6 +1619,19 @@
fprintf(where,"%s my thread id is %d\n",__func__,thread_self());
fflush(where);
}
+#elif defined(__sun)
+#include <sys/lwp.h>
+ /* well, bless _its_ heart, Solaris wants something other than a
+ pthread_id for its binding calls too. isn't that special... raj
+ 2006-06-28 */
+ test->native_thread_id_ptr = malloc(sizeof(lwpid_t));
+ if (test->native_thread_id_ptr) {
+ *(lwpid_t *)(test->native_thread_id_ptr) = _lwp_self();
+ }
+ if (debug) {
+ fprintf(where,"%s my thread id is %d\n",__func__,_lwp_self());
+ fflush(where);
+ }
#else
test->native_thread_id_ptr = malloc(sizeof(pthread_t));
if (test->native_thread_id_ptr) {
@@ -1630,8 +1643,26 @@
}
#endif
#else
+#ifdef __sun
+#include <sys/lwp.h>
+ /* well, bless _its_ heart, Solaris wants something other than a
+ pthread_id for its binding calls too. isn't that special... No,
+ your eyes are not deceiving you - this code is appearing in two
+ places because it would seem that glib-2.0 on Solaris may be
+ compiled using Sun's old threads stuff rather than pthreads. raj
+ 2006-06-28 */
+ test->native_thread_id_ptr = malloc(sizeof(lwpid_t));
+ if (test->native_thread_id_ptr) {
+ *(lwpid_t *)(test->native_thread_id_ptr) = _lwp_self();
+ }
+ if (debug) {
+ fprintf(where,"%s my thread id is %d\n",__func__,_lwp_self());
+ fflush(where);
+ }
+#else
test->native_thread_id_ptr = NULL;
#endif
+#endif
/* and now, call the routine we really want to run. at some point we
should bring those values onto the stack so we can free the
thread_launch_state_t I suppose. */
Modified: trunk/src/netlib_kstat10.c
===================================================================
--- trunk/src/netlib_kstat10.c 2006-06-28 22:36:06 UTC (rev 187)
+++ trunk/src/netlib_kstat10.c 2006-06-29 00:24:59 UTC (rev 188)
@@ -1,5 +1,5 @@
static char netlib_specific_id[]="\
-@(#)(c) Copyright 2006, Hewlett-Packard Company, $Id: netlib_none.c 180 2006-05-24 20:02:03Z raj $";
+@(#)(c) Copyright 2006 Hewlett-Packard Company, $Id$";
/*
@@ -36,41 +36,112 @@
#include "config.h"
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/processor.h>
+#include <sys/procset.h>
+#include <sys/pset.h>
+#include <sys/lwp.h>
+
#include "netperf.h"
+#include "netlib.h"
int
-set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where) {
+set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where)
+{
+ int err = -1;
+ int value;
+ char *err_str;
+
+ lwpid_t thread_id;
+
NETPERF_DEBUG_ENTRY(debug,where);
- if (debug) {
+
+ thread_id = *(lwpid_t *)(threadid);
+
+ value = atoi(loc_value);
+ if (strcmp(loc_type,"PROC") == 0) {
+ err = processor_bind(P_LWPID,
+ thread_id,
+ value,
+ NULL);
+ }
+ else if (strcmp(loc_type,"LDOM") == 0) {
+ /* not quite sure what we should do here, so for now we will do
+ nothing at all. raj 2006-06-28 */
+ }
+ else if (strcmp(loc_type,"PSET") == 0) {
+ /* figures that Sun wouldn't keep the order of arguments
+ consistent with processor_bind... raj 2006-06-28 */
+ err = pset_bind(value,
+ P_LWPID,
+ thread_id,
+ NULL);
+ }
+ if (err) {
+ if (err == EINVAL) {
+ err_str = "Invalid locality value";
+ }
+ if (err == EPERM) {
+ err_str = "Netserver Permission Failure";
+ }
+ if (err == ESRCH) {
+ err_str = "Invalid thread id";
+ }
+ if (err == -1) {
+ err_str = "Invalid locality type";
+ }
fprintf(where,
- "No call to set CPU affinity available, request ignored.\n");
+ "%s: failed to set locality %s\n",
+ __func__,
+ err_str);
fflush(where);
+ err = NPE_SET_THREAD_LOCALITY_FAILED;
}
+ else {
+ err = NPE_SUCCESS;
+ }
+
NETPERF_DEBUG_EXIT(debug,where);
- return(NPE_SUCCESS);
+
+ return(err);
}
int
set_test_locality(test_t *test, char *loc_type, char *loc_value)
{
+ int err = -1;
NETPERF_DEBUG_ENTRY(test->debug,test->where);
- if (test->debug) {
- fprintf(test->where,
- "No call to set CPU affinity available, request ignored.\n");
- fflush(test->where);
- }
+ err = set_thread_locality(test->native_thread_id_ptr,
+ loc_type,
+ loc_value,
+ test->debug,
+ test->where);
NETPERF_DEBUG_EXIT(test->debug,test->where);
- return(NPE_SUCCESS);
+ return(err);
}
int
set_own_locality(char *loc_type, char *loc_value, int debug, FILE *where) {
- int my_id = 0;
+ lwpid_t my_id;
+ my_id = _lwp_self();
+
return(set_thread_locality((void *)&my_id,
loc_type,
loc_value,
@@ -81,6 +152,32 @@
int
clear_own_locality(char *loc_type, int debug, FILE *where){
+ int err = -1;
+
+ NETPERF_DEBUG_ENTRY(debug,where);
+
+ if (strcmp(loc_type,"PROC") == 0) {
+ err = processor_bind(P_LWPID,
+ P_MYID,
+ PBIND_NONE,
+ NULL);
+ }
+ else if (strcmp(loc_type,"LDOM") == 0) {
+ /* as I know not what to do for a locality domain under solairs, I
+ will do nothing. */
+ }
+ else if (strcmp(loc_type,"PSET") == 0) {
+ /* well, it seems as there is no "FLOAT" pset identifier, which
+ means we could only go back to where we were before, assuming
+ of course, we actually knew where that happened to be. at the
+ moment, we have no clue, so we will do nothing. raj
+ 2006-04-11 */
+ err = pset_bind(PS_NONE,
+ P_LWPID,
+ P_MYID,
+ NULL);
+ }
+
return(NPE_SUCCESS);
}
More information about the netperf-dev
mailing list