Browse Source

Partial-Merge commit '9a71654' into cg_merges_20121203 (rename rename_thr to RenameThread)

Conflicts:
	miner.c
Luke Dashjr 13 years ago
parent
commit
ffd1e4cf97
6 changed files with 38 additions and 34 deletions
  1. 2 2
      api.c
  2. 1 1
      driver-opencl.c
  3. 1 1
      findnonce.c
  4. 18 15
      miner.c
  5. 1 1
      miner.h
  6. 15 14
      util.c

+ 2 - 2
api.c

@@ -3302,7 +3302,7 @@ popipo:
 
 static void *quit_thread(__maybe_unused void *userdata)
 {
-	rename_thr("bfg-rpc-quit");
+	RenameThread("rpc_quit");
 
 	// allow thread creator to finish whatever it's doing
 	mutex_lock(&quit_restart_lock);
@@ -3318,7 +3318,7 @@ static void *quit_thread(__maybe_unused void *userdata)
 
 static void *restart_thread(__maybe_unused void *userdata)
 {
-	rename_thr("bfg-rpc-restart");
+	RenameThread("rpc_restart");
 
 	// allow thread creator to finish whatever it's doing
 	mutex_lock(&quit_restart_lock);

+ 1 - 1
driver-opencl.c

@@ -1329,7 +1329,7 @@ void *reinit_gpu(void *userdata)
 	int gpu;
 
 	pthread_detach(pthread_self());
-	rename_thr("bfg-reinit_gpu");
+	RenameThread("reinit_gpu");
 
 select_cgpu:
 	cgpu = tq_pop(mythr->q, NULL);

+ 1 - 1
findnonce.c

@@ -147,7 +147,7 @@ static void *postcalc_hash(void *userdata)
 	unsigned int entry = 0;
 
 	pthread_detach(pthread_self());
-	rename_thr("bfg-postcalchsh");
+	RenameThread("postcalchsh");
 
 	/* To prevent corrupt values in FOUND from trying to read beyond the
 	 * end of the res[] array */

+ 18 - 15
miner.c

@@ -3408,7 +3408,8 @@ static void *get_work_thread(void *userdata)
 	struct pool *pool;
 
 	pthread_detach(pthread_self());
-	rename_thr("bfg-get_work");
+
+	RenameThread("get_work");
 
 	applog(LOG_DEBUG, "Creating extra get work thread");
 
@@ -3626,7 +3627,8 @@ static void *submit_work_thread(void *userdata)
 	time_t staleexpire;
 
 	pthread_detach(pthread_self());
-	rename_thr("bfg-submit_work");
+
+	RenameThread("submit_work");
 
 	applog(LOG_DEBUG, "Creating extra submit work thread");
 
@@ -4308,7 +4310,7 @@ static void *stage_thread(void *userdata)
 	struct thr_info *mythr = userdata;
 	bool ok = true;
 
-	rename_thr("bfg-stage");
+	RenameThread("stage");
 
 	while (ok) {
 		struct work *work = NULL;
@@ -5044,7 +5046,7 @@ retry:
 
 static void *input_thread(void __maybe_unused *userdata)
 {
-	rename_thr("bfg-input");
+	RenameThread("input");
 
 	if (!curses_active)
 		return NULL;
@@ -5106,7 +5108,7 @@ static void *workio_thread(void *userdata)
 	struct thr_info *mythr = userdata;
 	bool ok = true;
 
-	rename_thr("bfg-workio");
+	RenameThread("work_io");
 
 	while (ok) {
 		struct workio_cmd *wc;
@@ -5160,9 +5162,10 @@ static void *api_thread(void *userdata)
 	struct thr_info *mythr = userdata;
 
 	pthread_detach(pthread_self());
-	rename_thr("bfg-rpc");
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
+	RenameThread("rpc");
+
 	api(api_thr_id);
 
 	PTH(mythr) = 0L;
@@ -5456,6 +5459,8 @@ static void *stratum_thread(void *userdata)
 
 	pthread_detach(pthread_self());
 
+	RenameThread("stratum");
+
 	while (42) {
 		struct timeval timeout;
 		fd_set rd;
@@ -6308,12 +6313,6 @@ void *miner_thread(void *userdata)
 	struct cgminer_stats *pool_stats;
 	struct timeval getwork_start;
 
-	{
-		char thrname[16];
-		sprintf(thrname, "bfg-miner-%s%d", api->name, cgpu->device_id);
-		rename_thr(thrname);
-	}
-
 	/* Try to cycle approximately 5 times before each log update */
 	const long cycle = opt_log_interval / 5 ? : 1;
 	struct timeval tv_start, tv_end, tv_workstart, tv_lastupdate;
@@ -6327,6 +6326,10 @@ void *miner_thread(void *userdata)
 
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
+	char threadname[20];
+	snprintf(threadname, 20, "miner_%s%d.%d", api->name, cgpu->device_id, mythr->device_thread);
+	RenameThread(threadname);
+
 	gettimeofday(&getwork_start, NULL);
 
 	if (api->thread_init && !api->thread_init(mythr)) {
@@ -6597,7 +6600,7 @@ static void *longpoll_thread(void *userdata)
 	char *lp_url;
 	int rolltime;
 
-	rename_thr("bfg-longpoll");
+	RenameThread("longpoll");
 
 	curl = curl_easy_init();
 	if (unlikely(!curl)) {
@@ -6781,7 +6784,7 @@ static void *watchpool_thread(void __maybe_unused *userdata)
 {
 	int intervals = 0;
 
-	rename_thr("bfg-watchpool");
+	RenameThread("watchpool");
 
 	while (42) {
 		struct timeval now;
@@ -6855,7 +6858,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 	const unsigned int interval = WATCHDOG_INTERVAL;
 	struct timeval zero_tv;
 
-	rename_thr("bfg-watchdog");
+	RenameThread("watchdog");
 
 	memset(&zero_tv, 0, sizeof(struct timeval));
 	gettimeofday(&rotate_tv, NULL);

+ 1 - 1
miner.h

@@ -551,7 +551,7 @@ extern void thr_info_cancel(struct thr_info *thr);
 extern void thr_info_freeze(struct thr_info *thr);
 extern void nmsleep(unsigned int msecs);
 extern double us_tdiff(struct timeval *end, struct timeval *start);
-extern void rename_thr(const char* name);
+extern void RenameThread(const char* name);
 extern double tdiff(struct timeval *end, struct timeval *start);
 
 struct string_elist {

+ 15 - 14
util.c

@@ -789,20 +789,6 @@ double us_tdiff(struct timeval *end, struct timeval *start)
 	return end->tv_sec * 1000000 + end->tv_usec - start->tv_sec * 1000000 - start->tv_usec;
 }
 
-void rename_thr(const char* name) {
-#if defined(PR_SET_NAME)
-	// Only the first 15 characters are used (16 - NUL terminator)
-	prctl(PR_SET_NAME, name, 0, 0, 0);
-#elif defined(__APPLE__)
-	pthread_setname_np(name);
-#elif defined(__FreeBSD__) || defined(__OpenBSD__)
-	pthread_set_name_np(pthread_self(), name);
-#else
-	// Prevent warnings for unused parameters...
-	(void)name;
-#endif
-}
-
 /* Returns the seconds difference between end and start times as a double */
 double tdiff(struct timeval *end, struct timeval *start)
 {
@@ -1481,3 +1467,18 @@ void *realloc_strcat(char *ptr, char *s)
 	free(ptr);
 	return ret;
 }
+
+void RenameThread(const char* name)
+{
+#if defined(PR_SET_NAME)
+	// Only the first 15 characters are used (16 - NUL terminator)
+	prctl(PR_SET_NAME, name, 0, 0, 0);
+#elif defined(__APPLE__)
+	pthread_setname_np(name);
+#elif (defined(__FreeBSD__) || defined(__OpenBSD__))
+	pthread_set_name_np(pthread_self(), name);
+#else
+	// Prevent warnings for unused parameters...
+	(void)name;
+#endif
+}