code changes for supporting a simple device history
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
diff --git a/adl.c b/adl.c
index 7a4707e..ed17216 100644
--- a/adl.c
+++ b/adl.c
@@ -992,6 +992,10 @@ static bool fan_autotune(int gpu, int temp, int fanpercent, int lasttemp)
if (temp > ga->overtemp && fanpercent < iMax) {
applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%", gpu);
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) {
applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
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);
*denable = DEV_RECOVER;
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) {
applog(LOG_WARNING, "Overheat detected, decreasing GPU %d clock speed", gpu);
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) {
applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
newengine = engine - ga->lpOdParameters.sEngineClock.iStep;
diff --git a/bitforce.c b/bitforce.c
index e063664..18efb0d 100644
--- a/bitforce.c
+++ b/bitforce.c
@@ -305,6 +305,10 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
if (temp > bitforce->cutofftemp) {
applog(LOG_WARNING, "Hit thermal cutoff limit on %s %d, disabling!", bitforce->api->name, bitforce->device_id);
bitforce->deven = DEV_RECOVER;
+
+ bitforce->device_last_not_well = time(NULL);
+ bitforce->device_not_well_reason = REASON_THERMAL_CUTOFF;
+ bitforce->dev_thermal_cutoff_count++;
}
}
}
diff --git a/cgminer.c b/cgminer.c
index c336f8b..29c7446 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2888,6 +2888,7 @@ void thread_reportin(struct thr_info *thr)
gettimeofday(&thr->last, NULL);
thr->cgpu->status = LIFE_WELL;
thr->getwork = false;
+ thr->cgpu->device_last_well = time(NULL);
}
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;
/* Update the last time this thread reported in */
- if (thr_id >= 0)
+ if (thr_id >= 0) {
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 */
if (opt_realquiet || !opt_log_interval)
@@ -3423,8 +3426,13 @@ void *miner_thread(void *userdata)
bool requested = false;
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;
+ }
thread_reportout(mythr);
applog(LOG_DEBUG, "Popping ping in miner thread");
@@ -3473,8 +3481,14 @@ void *miner_thread(void *userdata)
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;
+ }
+
hashes_done += hashes;
if (hashes > cgpu->max_hashes)
cgpu->max_hashes = hashes;
@@ -3494,6 +3508,11 @@ void *miner_thread(void *userdata)
thread_reportout(mythr);
if (unlikely(!queue_request(mythr, false))) {
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;
}
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) {
applog(LOG_ERR, "Device %d recovered, GPU %d declared WELL!", i, gpu);
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) {
thr->rolling = thr->cgpu->rolling = 0;
gpus[gpu].status = LIFE_SICK;
applog(LOG_ERR, "Device %d idle for more than 60 seconds, GPU %d declared SICK!", i, gpu);
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
if (adl_active && gpus[gpu].has_adl && gpu_activity(gpu) > 50) {
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;
applog(LOG_ERR, "Device %d not responding for more than 10 minutes, GPU %d declared DEAD!", i, gpu);
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 &&
(gpus[i].status == LIFE_SICK || gpus[i].status == LIFE_DEAD)) {
/* Attempt to restart a GPU that's sick or dead once every minute */
diff --git a/device-gpu.c b/device-gpu.c
index 70dea39..e14fb00 100644
--- a/device-gpu.c
+++ b/device-gpu.c
@@ -1185,6 +1185,11 @@ static bool opencl_thread_prepare(struct thr_info *thr)
}
cgpu->deven = DEV_DISABLED;
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;
}
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->device_last_well = time(NULL);
+
return true;
}
diff --git a/miner.h b/miner.h
index 5f5fd68..5c04cfa 100644
--- a/miner.h
+++ b/miner.h
@@ -221,6 +221,17 @@ enum cl_kernels {
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 {
int cgminer_id;
struct device_api *api;
@@ -272,6 +283,18 @@ struct cgpu_info {
#endif
int last_share_pool;
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 {