Browse Source

code changes for supporting a simple device history

Kano 14 years ago
parent
commit
eeec98098f
5 changed files with 77 additions and 3 deletions
  1. 12 0
      adl.c
  2. 4 0
      bitforce.c
  3. 31 3
      cgminer.c
  4. 7 0
      device-gpu.c
  5. 23 0
      miner.h

+ 12 - 0
adl.c

@@ -992,6 +992,10 @@ static bool fan_autotune(int gpu, int temp, int fanpercent, int lasttemp)
 	if (temp > ga->overtemp && fanpercent < iMax) {
 	if (temp > ga->overtemp && fanpercent < iMax) {
 		applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%", gpu);
 		applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%", gpu);
 		newpercent = iMax;
 		newpercent = iMax;
+
+		cgpu->device_last_not_well = time(NULL);
+		cgpu->device_not_well_reason = REASON_DEV_OVER_HEAT;
+		cgpu->dev_over_heat_count++;
 	} else if (temp > ga->targettemp && fanpercent < top && temp >= lasttemp) {
 	} else if (temp > ga->targettemp && fanpercent < top && temp >= lasttemp) {
 		applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
 		applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
 		if (temp > ga->targettemp + opt_hysteresis)
 		if (temp > ga->targettemp + opt_hysteresis)
@@ -1076,9 +1080,17 @@ void gpu_autotune(int gpu, enum dev_enable *denable)
 			applog(LOG_WARNING, "Hit thermal cutoff limit on GPU %d, disabling!", gpu);
 			applog(LOG_WARNING, "Hit thermal cutoff limit on GPU %d, disabling!", gpu);
 			*denable = DEV_RECOVER;
 			*denable = DEV_RECOVER;
 			newengine = ga->minspeed;
 			newengine = ga->minspeed;
+
+			cgpu->device_last_not_well = time(NULL);
+			cgpu->device_not_well_reason = REASON_DEV_THERMAL_CUTOFF;
+			cgpu->dev_thermal_cutoff_count++;
 		} else if (temp > ga->overtemp && engine > ga->minspeed) {
 		} else if (temp > ga->overtemp && engine > ga->minspeed) {
 			applog(LOG_WARNING, "Overheat detected, decreasing GPU %d clock speed", gpu);
 			applog(LOG_WARNING, "Overheat detected, decreasing GPU %d clock speed", gpu);
 			newengine = ga->minspeed;
 			newengine = ga->minspeed;
+
+			cgpu->device_last_not_well = time(NULL);
+			cgpu->device_not_well_reason = REASON_DEV_OVER_HEAT;
+			cgpu->dev_over_heat_count++;
 		} else if (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
 		} else if (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
 			applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
 			applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
 			newengine = engine - ga->lpOdParameters.sEngineClock.iStep;
 			newengine = engine - ga->lpOdParameters.sEngineClock.iStep;

+ 4 - 0
bitforce.c

@@ -305,6 +305,10 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 			if (temp > bitforce->cutofftemp) {
 			if (temp > bitforce->cutofftemp) {
 				applog(LOG_WARNING, "Hit thermal cutoff limit on %s %d, disabling!", bitforce->api->name, bitforce->device_id);
 				applog(LOG_WARNING, "Hit thermal cutoff limit on %s %d, disabling!", bitforce->api->name, bitforce->device_id);
 				bitforce->deven = DEV_RECOVER;
 				bitforce->deven = DEV_RECOVER;
+
+				bitforce->device_last_not_well = time(NULL);
+				bitforce->device_not_well_reason = REASON_THERMAL_CUTOFF;
+				bitforce->dev_thermal_cutoff_count++;
 			}
 			}
 		}
 		}
 	}
 	}

+ 31 - 3
cgminer.c

@@ -2888,6 +2888,7 @@ void thread_reportin(struct thr_info *thr)
 	gettimeofday(&thr->last, NULL);
 	gettimeofday(&thr->last, NULL);
 	thr->cgpu->status = LIFE_WELL;
 	thr->cgpu->status = LIFE_WELL;
 	thr->getwork = false;
 	thr->getwork = false;
+	thr->cgpu->device_last_well = time(NULL);
 }
 }
 
 
 static inline void thread_reportout(struct thr_info *thr)
 static inline void thread_reportout(struct thr_info *thr)
@@ -2908,8 +2909,10 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	bool showlog = false;
 	bool showlog = false;
 
 
 	/* Update the last time this thread reported in */
 	/* Update the last time this thread reported in */
-	if (thr_id >= 0)
+	if (thr_id >= 0) {
 		gettimeofday(&thr_info[thr_id].last, NULL);
 		gettimeofday(&thr_info[thr_id].last, NULL);
+		thr_info[thr_id].cgpu->device_last_well = time(NULL);
+	}
 
 
 	/* Don't bother calculating anything if we're not displaying it */
 	/* Don't bother calculating anything if we're not displaying it */
 	if (opt_realquiet || !opt_log_interval)
 	if (opt_realquiet || !opt_log_interval)
@@ -3423,8 +3426,13 @@ void *miner_thread(void *userdata)
 	bool requested = false;
 	bool requested = false;
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
 
-	if (api->thread_init && !api->thread_init(mythr))
+	if (api->thread_init && !api->thread_init(mythr)) {
+		cgpu->device_last_not_well = time(NULL);
+		cgpu->device_not_well_reason = REASON_THREAD_FAIL_INIT;
+		cgpu->thread_fail_init_count++;
+
 		goto out;
 		goto out;
+	}
 
 
 	thread_reportout(mythr);
 	thread_reportout(mythr);
 	applog(LOG_DEBUG, "Popping ping in miner thread");
 	applog(LOG_DEBUG, "Popping ping in miner thread");
@@ -3473,8 +3481,14 @@ void *miner_thread(void *userdata)
 				break;
 				break;
 			}
 			}
 
 
-			if (unlikely(!hashes))
+			if (unlikely(!hashes)) {
+				cgpu->device_last_not_well = time(NULL);
+				cgpu->device_not_well_reason = REASON_THREAD_ZERO_HASH;
+				cgpu->thread_zero_hash_count++;
+
 				goto out;
 				goto out;
+			}
+
 			hashes_done += hashes;
 			hashes_done += hashes;
 			if (hashes > cgpu->max_hashes)
 			if (hashes > cgpu->max_hashes)
 				cgpu->max_hashes = hashes;
 				cgpu->max_hashes = hashes;
@@ -3494,6 +3508,11 @@ void *miner_thread(void *userdata)
 					thread_reportout(mythr);
 					thread_reportout(mythr);
 					if (unlikely(!queue_request(mythr, false))) {
 					if (unlikely(!queue_request(mythr, false))) {
 						applog(LOG_ERR, "Failed to queue_request in miner_thread %d", thr_id);
 						applog(LOG_ERR, "Failed to queue_request in miner_thread %d", thr_id);
+
+						cgpu->device_last_not_well = time(NULL);
+						cgpu->device_not_well_reason = REASON_THREAD_FAIL_QUEUE;
+						cgpu->thread_fail_queue_count++;
+
 						goto out;
 						goto out;
 					}
 					}
 					thread_reportin(mythr);
 					thread_reportin(mythr);
@@ -3879,11 +3898,16 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			if (gpus[gpu].status != LIFE_WELL && now.tv_sec - thr->last.tv_sec < 60) {
 			if (gpus[gpu].status != LIFE_WELL && now.tv_sec - thr->last.tv_sec < 60) {
 				applog(LOG_ERR, "Device %d recovered, GPU %d declared WELL!", i, gpu);
 				applog(LOG_ERR, "Device %d recovered, GPU %d declared WELL!", i, gpu);
 				gpus[gpu].status = LIFE_WELL;
 				gpus[gpu].status = LIFE_WELL;
+				gpus[gpu].device_last_well = time(NULL);
 			} else if (now.tv_sec - thr->last.tv_sec > 60 && gpus[gpu].status == LIFE_WELL) {
 			} else if (now.tv_sec - thr->last.tv_sec > 60 && gpus[gpu].status == LIFE_WELL) {
 				thr->rolling = thr->cgpu->rolling = 0;
 				thr->rolling = thr->cgpu->rolling = 0;
 				gpus[gpu].status = LIFE_SICK;
 				gpus[gpu].status = LIFE_SICK;
 				applog(LOG_ERR, "Device %d idle for more than 60 seconds, GPU %d declared SICK!", i, gpu);
 				applog(LOG_ERR, "Device %d idle for more than 60 seconds, GPU %d declared SICK!", i, gpu);
 				gettimeofday(&thr->sick, NULL);
 				gettimeofday(&thr->sick, NULL);
+
+				gpus[gpu].device_last_not_well = time(NULL);
+				gpus[gpu].device_not_well_reason = REASON_DEV_SICK_IDLE_60;
+				gpus[gpu].dev_sick_idle_60_count++;
 #ifdef HAVE_ADL
 #ifdef HAVE_ADL
 				if (adl_active && gpus[gpu].has_adl && gpu_activity(gpu) > 50) {
 				if (adl_active && gpus[gpu].has_adl && gpu_activity(gpu) > 50) {
 					applog(LOG_ERR, "GPU still showing activity suggesting a hard hang.");
 					applog(LOG_ERR, "GPU still showing activity suggesting a hard hang.");
@@ -3898,6 +3922,10 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 				gpus[gpu].status = LIFE_DEAD;
 				gpus[gpu].status = LIFE_DEAD;
 				applog(LOG_ERR, "Device %d not responding for more than 10 minutes, GPU %d declared DEAD!", i, gpu);
 				applog(LOG_ERR, "Device %d not responding for more than 10 minutes, GPU %d declared DEAD!", i, gpu);
 				gettimeofday(&thr->sick, NULL);
 				gettimeofday(&thr->sick, NULL);
+
+				gpus[gpu].device_last_not_well = time(NULL);
+				gpus[gpu].device_not_well_reason = REASON_DEV_DEAD_IDLE_600;
+				gpus[gpu].dev_dead_idle_600_count++;
 			} else if (now.tv_sec - thr->sick.tv_sec > 60 &&
 			} else if (now.tv_sec - thr->sick.tv_sec > 60 &&
 				   (gpus[i].status == LIFE_SICK || gpus[i].status == LIFE_DEAD)) {
 				   (gpus[i].status == LIFE_SICK || gpus[i].status == LIFE_DEAD)) {
 				/* Attempt to restart a GPU that's sick or dead once every minute */
 				/* Attempt to restart a GPU that's sick or dead once every minute */

+ 7 - 0
device-gpu.c

@@ -1185,6 +1185,11 @@ static bool opencl_thread_prepare(struct thr_info *thr)
 		}
 		}
 		cgpu->deven = DEV_DISABLED;
 		cgpu->deven = DEV_DISABLED;
 		cgpu->status = LIFE_NOSTART;
 		cgpu->status = LIFE_NOSTART;
+
+		cgpu->device_last_not_well = time(NULL);
+		cgpu->device_not_well_reason = REASON_DEV_NOSTART;
+		cgpu->dev_nostart_count++;
+
 		return false;
 		return false;
 	}
 	}
 	applog(LOG_INFO, "initCl() finished. Found %s", name);
 	applog(LOG_INFO, "initCl() finished. Found %s", name);
@@ -1244,6 +1249,8 @@ static bool opencl_thread_init(struct thr_info *thr)
 
 
 	gpu->status = LIFE_WELL;
 	gpu->status = LIFE_WELL;
 
 
+	gpu->device_last_well = time(NULL);
+
 	return true;
 	return true;
 }
 }
 
 

+ 23 - 0
miner.h

@@ -221,6 +221,17 @@ enum cl_kernels {
 	KL_DIABLO,
 	KL_DIABLO,
 };
 };
 
 
+enum dev_reason {
+	REASON_THREAD_FAIL_INIT,
+	REASON_THREAD_ZERO_HASH,
+	REASON_THREAD_FAIL_QUEUE,
+	REASON_DEV_SICK_IDLE_60,
+	REASON_DEV_DEAD_IDLE_600,
+	REASON_DEV_NOSTART,
+	REASON_DEV_OVER_HEAT,
+	REASON_DEV_THERMAL_CUTOFF,
+};
+
 struct cgpu_info {
 struct cgpu_info {
 	int cgminer_id;
 	int cgminer_id;
 	struct device_api *api;
 	struct device_api *api;
@@ -272,6 +283,18 @@ struct cgpu_info {
 #endif
 #endif
 	int last_share_pool;
 	int last_share_pool;
 	time_t last_share_pool_time;
 	time_t last_share_pool_time;
+
+	time_t device_last_well;
+	time_t device_last_not_well;
+	enum dev_reason device_not_well_reason;
+	int thread_fail_init_count;
+	int thread_zero_hash_count;
+	int thread_fail_queue_count;
+	int dev_sick_idle_60_count;
+	int dev_dead_idle_600_count;
+	int dev_nostart_count;
+	int dev_over_heat_count;	// It's a warning but worth knowing
+	int dev_thermal_cutoff_count;
 };
 };
 
 
 struct thread_q {
 struct thread_q {