[netperf-dev] netperf4 commit notice r121 -
branches/glib_migration/src
raj at netperf.org
raj at netperf.org
Fri Mar 31 11:59:25 PST 2006
Author: raj
Date: 2006-03-31 11:59:24 -0800 (Fri, 31 Mar 2006)
New Revision: 121
Modified:
branches/glib_migration/src/netlib.c
branches/glib_migration/src/netlib.h
branches/glib_migration/src/netlib_hpux.c
branches/glib_migration/src/netlib_linux.c
branches/glib_migration/src/netlib_none.c
branches/glib_migration/src/netmsg.c
branches/glib_migration/src/netperf.h
Log:
Start using the "launch_pad" to stash-away the native thread ID, and modify
the affinity setting routines accordingly. Add a set_thread_affinity to
prepare for being able to manipulate the main netserver thread's affinity
before and after launching the test thread to make sure that the test
thread has things like thread stacks allocated where we want them to be.
Namely, based on the CPU(s) on which that test thread will be running.
The launch_pad itself has been tested and is known working. The affinity
stuff, while cleanly compiling is not actually tested yet.
Modified: branches/glib_migration/src/netlib.c
===================================================================
--- branches/glib_migration/src/netlib.c 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netlib.c 2006-03-31 19:59:24 UTC (rev 121)
@@ -1594,17 +1594,19 @@
thread_launch_state_t *launch_state;
test_t *test;
+ NETPERF_DEBUG_ENTRY(debug,where);
+
launch_state = data;
test = launch_state->data_arg;
#ifdef G_THREADS_IMPL_POSIX
/* hmm, I wonder if I have to worry about alignment */
- test->native_thread_id = malloc(sizeof(pthread_t));
- if (test->native_thread_id) {
- *(pthread_t *)(test->native_thread_id) = pthread_self();
+ test->native_thread_id_ptr = malloc(sizeof(pthread_t));
+ if (test->native_thread_id_ptr) {
+ *(pthread_t *)(test->native_thread_id_ptr) = pthread_self();
}
#else
- test->native_thread_id = NULL;
+ test->native_thread_id_ptr = NULL;
#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
Modified: branches/glib_migration/src/netlib.h
===================================================================
--- branches/glib_migration/src/netlib.h 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netlib.h 2006-03-31 19:59:24 UTC (rev 121)
@@ -78,8 +78,13 @@
extern const char * netperf_error_name(int rc);
extern char * npe_to_str(int npe_error);
extern int set_test_locality(test_t *test,
- xmlChar *loc_type,
- xmlChar *loc_value);
+ char *loc_type,
+ char *loc_value);
+extern int set_thread_locality(void *thread_id,
+ char *loc_type,
+ char *loc_value,
+ int debug,
+ FILE *where);
#ifdef HAVE_GETHRTIME
extern void netperf_timestamp(hrtime_t *timestamp);
@@ -105,7 +110,6 @@
extern int32_t recv_control_message(int control_sock, xmlDocPtr *message);
extern void report_server_error(server_t *server);
extern int launch_thread(GThread **tid, void *(*start_routine)(void *), void *data);
-extern int set_thread_locality(test_t *test, char *loc_type, char *loc_value);
extern void break_args_explicit(char *s, char *arg1, char *arg2);
extern int parse_address_family(char family_string[]);
extern int establish_listen(char *hostname, char *service,
@@ -113,6 +117,7 @@
extern int netperf_complete_filename(char *name, char *full, int fulllen);
extern gboolean read_from_control_connection(GIOChannel *source, GIOCondition condition, gpointer data);
+extern void *launch_pad(void *data);
/* state machine data structure for process message */
Modified: branches/glib_migration/src/netlib_hpux.c
===================================================================
--- branches/glib_migration/src/netlib_hpux.c 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netlib_hpux.c 2006-03-31 19:59:24 UTC (rev 121)
@@ -49,9 +49,8 @@
#include "netperf.h"
#include "netlib.h"
-
int
-set_thread_locality(test_t *test, char *loc_type, char *loc_value)
+set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where)
{
int err = -1;
int value;
@@ -59,28 +58,31 @@
psetid_t pset;
pthread_ldom_t ldom;
pthread_spu_t spu;
+ pthread_t thread_id;
- NETPERF_DEBUG_ENTRY(test->debug,test->where);
+ NETPERF_DEBUG_ENTRY(debug,where);
+ thread_id = *(pthread_t *)(threadid);
+
value = atoi(loc_value);
if (strcmp(loc_type,"PROC") == 0) {
err = pthread_processor_bind_np(
PTHREAD_BIND_FORCED_NP,
&spu,
value,
- test->thread_id);
+ thread_id);
}
else if (strcmp(loc_type,"LDOM") == 0) {
err = pthread_ldom_bind_np(
&ldom,
value,
- test->thread_id);
+ thread_id);
}
else if (strcmp(loc_type,"PSET") == 0) {
err = pthread_pset_bind_np(
&pset,
value,
- test->thread_id);
+ thread_id);
}
if (err) {
if (err == EINVAL) {
@@ -95,17 +97,35 @@
if (err == -1) {
err_str = "Invalid locality type";
}
- fprintf(test->where,
+ fprintf(where,
"%s: failed to set locality %s\n",
__func__,
err_str);
- fflush(test->where);
+ fflush(where);
err = NPE_SET_THREAD_LOCALITY_FAILED;
}
else {
err = NPE_SUCCESS;
}
+ NETPERF_DEBUG_EXIT(debug,where);
+
+ 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);
+
+ 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(err);
Modified: branches/glib_migration/src/netlib_linux.c
===================================================================
--- branches/glib_migration/src/netlib_linux.c 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netlib_linux.c 2006-03-31 19:59:24 UTC (rev 121)
@@ -58,16 +58,18 @@
#ifdef HAVE_SCHED_SETAFFINITY
int
-set_thread_locality(test_t *test, char *loc_type, char *loc_value)
-{
+set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where) {
int err = -1;
int value;
char *err_str;
cpu_set_t mask;
+ pthread_t thread_id;
- NETPERF_DEBUG_ENTRY(test->debug,test->where);
+ NETPERF_DEBUG_ENTRY(debug,where);
+ thread_id = *(pthread_t *)(threadid);
+
CPU_ZERO(&mask);
/* OK, right off the bat I see we have a potential issue with > 32
@@ -83,17 +85,17 @@
grins. raj 2006-01-24 */
if (strcmp(loc_type,"PROC") == 0) {
- err = sched_setaffinity(test->thread_id,
+ err = sched_setaffinity(thread_id,
sizeof(mask),
&mask);
}
else if (strcmp(loc_type,"LDOM") == 0) {
- err = sched_setaffinity(test->thread_id,
+ err = sched_setaffinity(thread_id,
sizeof(mask),
&mask);
}
else if (strcmp(loc_type,"PSET") == 0) {
- err = sched_setaffinity(test->thread_id,
+ err = sched_setaffinity(thread_id,
sizeof(mask),
&mask);
}
@@ -113,22 +115,51 @@
if (err == -1) {
err_str = "Invalid locality type";
}
- fprintf(test->where,
+ fprintf(where,
"%s: failed to set locality %s\n",
__func__,
err_str);
- fflush(test->where);
+ fflush(where);
err = NPE_SET_THREAD_LOCALITY_FAILED;
}
else {
err = NPE_SUCCESS;
}
- NETPERF_DEBUG_EXIT(test->debug,test->where);
+ NETPERF_DEBUG_EXIT(debug,where);
return(err);
}
+
+int
+set_test_locality(test_t *test, char *loc_type, char *loc_value)
+{
+ int ret;
+
+ NETPERF_DEBUG_ENTRY(test->debug,test->where);
+
+ ret = set_thread_locality(test->native_thread_id_ptr,
+ loc_type,
+ loc_value,
+ test->debug,
+ test->where);
+
+ NETPERF_DEBUG_EXIT(test->debug,test->where);
+ return(ret);
+}
#else
int
-set_thread_locality(test_t *test, char *loc_type, char *loc_value)
+set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where) {
+ NETPERF_DEBUG_ENTRY(debug,where);
+ if (debug) {
+ fprintf(where,
+ "No call to set CPU affinity available, request ignored.\n");
+ fflush(where);
+ }
+ NETPERF_DEBUG_EXIT(debug,where);
+ return(NPE_SUCCESS);
+}
+
+int
+set_test_locality(test_t *test, char *loc_type, char *loc_value)
{
NETPERF_DEBUG_ENTRY(test->debug,test->where);
if (test->debug) {
Modified: branches/glib_migration/src/netlib_none.c
===================================================================
--- branches/glib_migration/src/netlib_none.c 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netlib_none.c 2006-03-31 19:59:24 UTC (rev 121)
@@ -39,7 +39,18 @@
#include "netperf.h"
int
-set_thread_locality(test_t *test, char *loc_type, char *loc_value)
+set_thread_locality(void *threadid, char *loc_type, char *loc_value, int debug, FILE *where) {
+ NETPERF_DEBUG_ENTRY(debug,where);
+ if (debug) {
+ fprintf(where,
+ "No call to set CPU affinity available, request ignored.\n");
+ fflush(where);
+ }
+ NETPERF_DEBUG_EXIT(debug,where);
+ return(NPE_SUCCESS);
+
+int
+set_test_locality(test_t *test, char *loc_type, char *loc_value)
{
NETPERF_DEBUG_ENTRY(test->debug,test->where);
Modified: branches/glib_migration/src/netmsg.c
===================================================================
--- branches/glib_migration/src/netmsg.c 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netmsg.c 2006-03-31 19:59:24 UTC (rev 121)
@@ -935,7 +935,7 @@
if (launch_state) {
launch_state->data_arg = new_test;
launch_state->start_routine = new_test->test_func;
- rc = launch_thread(&new_test->thread_id,new_test->test_func,new_test);
+ rc = launch_thread(&new_test->thread_id,launch_pad,launch_state);
if (debug) {
fprintf(where,
"test_message: launched thread %d for test\n",
@@ -973,7 +973,7 @@
loc_type = xmlGetProp(test_node,(const xmlChar *)"locality_type");
loc_value = xmlGetProp(test_node,(const xmlChar *)"locality_value");
if ((loc_type != NULL) && (loc_value != NULL)) {
- rc = set_thread_locality(new_test, (char *)loc_type, (char *)loc_value);
+ rc = set_test_locality(new_test, (char *)loc_type, (char *)loc_value);
}
}
Modified: branches/glib_migration/src/netperf.h
===================================================================
--- branches/glib_migration/src/netperf.h 2006-03-31 06:44:20 UTC (rev 120)
+++ branches/glib_migration/src/netperf.h 2006-03-31 19:59:24 UTC (rev 121)
@@ -262,7 +262,7 @@
} test_state_t;
-typedef int *(*TestFunc)(void *test_data);
+typedef void *(*TestFunc)(void *test_data);
typedef xmlNodePtr (*TestDecode)(xmlNodePtr statistics);
typedef int (*TestClear)(void *test_info);
typedef xmlNodePtr (*TestStats)(void *test_data);
@@ -319,7 +319,7 @@
opaque thread id should be we will
have to do some interesting
backflips to deal with them */
- void *native_thread_id; /* a pointer to the "native" thread id
+ void *native_thread_id_ptr; /* a pointer to the "native" thread id
of the test thread, used for things
like processor affinity since
GThread doesn't do that sort of
More information about the netperf-dev
mailing list