minion - always generate history ghs data for reset code
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 210 211 212 213 214 215 216 217 218 219 220 221
diff --git a/driver-minion.c b/driver-minion.c
index 2342cd8..cf890ab 100644
--- a/driver-minion.c
+++ b/driver-minion.c
@@ -471,6 +471,9 @@ typedef struct ritem {
// How much history to keep (5min)
#define MINION_HISTORY_s 300
+// History must be always generated for the reset check
+#define MINION_MAX_RESET_CHECK 2
+
typedef struct hitem {
struct timeval when;
} HITEM;
@@ -674,6 +677,8 @@ struct minion_info {
K_LIST *hfree_list;
K_STORE *hchip_list[MINION_CHIPS];
+ int history_gen;
+ struct timeval chip_chk;
struct timeval chip_rpt;
double history_ghs[MINION_CHIPS];
// Gets reset to zero each time it is used in reporting
@@ -1754,11 +1759,10 @@ static void minion_detect(bool hotplug)
minioninfo->rfree_list = k_new_list("Reply", sizeof(RITEM), ALLOC_RITEMS, LIMIT_RITEMS, true);
minioninfo->rnonce_list = k_new_store(minioninfo->rfree_list);
- if (opt_minion_chipreport > 0) {
- minioninfo->hfree_list = k_new_list("History", sizeof(HITEM), ALLOC_HITEMS, LIMIT_HITEMS, true);
- for (i = 0; i < MINION_CHIPS; i++)
- minioninfo->hchip_list[i] = k_new_store(minioninfo->hfree_list);
- }
+ minioninfo->history_gen = MINION_MAX_RESET_CHECK;
+ minioninfo->hfree_list = k_new_list("History", sizeof(HITEM), ALLOC_HITEMS, LIMIT_HITEMS, true);
+ for (i = 0; i < MINION_CHIPS; i++)
+ minioninfo->hchip_list[i] = k_new_store(minioninfo->hfree_list);
cgsem_init(&(minioninfo->task_ready));
cgsem_init(&(minioninfo->nonce_ready));
@@ -2546,23 +2550,21 @@ retest:
cleanup_older(minioncgpu, chip, item, no_nonce);
- if (opt_minion_chipreport > 0) {
- int chip_tmp;
- cgtime(&now);
- K_WLOCK(minioninfo->hfree_list);
- item = k_unlink_head(minioninfo->hfree_list);
- memcpy(&(DATAH(item)->when), when, sizeof(*when));
- k_add_head(minioninfo->hchip_list[chip], item);
- for (chip_tmp = 0; chip_tmp < MINION_CHIPS; chip_tmp++) {
+ int chip_tmp;
+ cgtime(&now);
+ K_WLOCK(minioninfo->hfree_list);
+ item = k_unlink_head(minioninfo->hfree_list);
+ memcpy(&(DATAH(item)->when), when, sizeof(*when));
+ k_add_head(minioninfo->hchip_list[chip], item);
+ for (chip_tmp = 0; chip_tmp < MINION_CHIPS; chip_tmp++) {
+ tail = minioninfo->hchip_list[chip_tmp]->tail;
+ while (tail && tdiff(&(DATAH(tail)->when), &now) > MINION_HISTORY_s) {
+ tail = k_unlink_tail(minioninfo->hchip_list[chip_tmp]);
+ k_add_head(minioninfo->hfree_list, item);
tail = minioninfo->hchip_list[chip_tmp]->tail;
- while (tail && tdiff(&(DATAH(tail)->when), &now) > MINION_HISTORY_s) {
- tail = k_unlink_tail(minioninfo->hchip_list[chip_tmp]);
- k_add_head(minioninfo->hfree_list, item);
- tail = minioninfo->hchip_list[chip_tmp]->tail;
- }
}
- K_WUNLOCK(minioninfo->hfree_list);
}
+ K_WUNLOCK(minioninfo->hfree_list);
return NONCE_GOOD_NONCE;
}
@@ -3147,25 +3149,61 @@ static void chip_report(struct cgpu_info *minioncgpu)
double ghs, expect, howlong;
int msdiff;
int chip;
- bool any;
int res_err_count;
- res_err_msg[0] = '\0';
- res_err_msg[1] = '\0';
cgtime(&now);
- if (!(minioninfo->chip_rpt.tv_sec)) {
- // No report yet so don't until now + opt_minion_chipreport
+ if (!(minioninfo->chip_chk.tv_sec)) {
+ memcpy(&(minioninfo->chip_chk), &now, sizeof(now));
memcpy(&(minioninfo->chip_rpt), &now, sizeof(now));
return;
}
- msdiff = ms_tdiff(&now, &(minioninfo->chip_rpt));
- if (msdiff >= (opt_minion_chipreport * 1000)) {
- buf[0] = '\0';
- any = false;
+
+ if (opt_minion_chipreport > 0) {
+ msdiff = ms_tdiff(&now, &(minioninfo->chip_rpt));
+ if (msdiff >= (opt_minion_chipreport * 1000)) {
+ buf[0] = '\0';
+ res_err_msg[0] = '\0';
+ res_err_msg[1] = '\0';
+ K_RLOCK(minioninfo->hfree_list);
+ for (chip = 0; chip < MINION_CHIPS; chip++) {
+ if (minioninfo->chip[chip]) {
+ len = strlen(buf);
+ if (minioninfo->hchip_list[chip]->count < 2)
+ ghs = 0.0;
+ else {
+ ghs = 0xffffffffull * (minioninfo->hchip_list[chip]->count - 1);
+ ghs /= 1000000000.0;
+ ghs /= tdiff(&now, &(DATAH(minioninfo->hchip_list[chip]->tail)->when));
+ }
+ res_err_count = minioninfo->res_err_count[chip];
+ minioninfo->res_err_count[chip] = 0;
+ if (res_err_count > 100)
+ res_err_msg[0] = '!';
+ else if (res_err_count > 50)
+ res_err_msg[0] = '*';
+ else if (res_err_count > 0)
+ res_err_msg[0] = '\'';
+ else
+ res_err_msg[0] = '\0';
+ snprintf(buf + len, sizeof(buf) - len,
+ " %d=%s%.2f", chip, res_err_msg, ghs);
+ minioninfo->history_ghs[chip] = ghs;
+ }
+ }
+ K_RUNLOCK(minioninfo->hfree_list);
+ memcpy(&(minioninfo->chip_chk), &now, sizeof(now));
+ applogsiz(LOG_WARNING, 512,
+ "%s%d: Chip GHs%s",
+ minioncgpu->drv->name, minioncgpu->device_id, buf);
+ memcpy(&(minioninfo->chip_rpt), &now, sizeof(now));
+ }
+ }
+
+ msdiff = ms_tdiff(&now, &(minioninfo->chip_chk));
+ if (total_secs >= MINION_HISTORY_s && msdiff >= (minioninfo->history_gen * 1000)) {
K_RLOCK(minioninfo->hfree_list);
for (chip = 0; chip < MINION_CHIPS; chip++) {
if (minioninfo->chip[chip]) {
- len = strlen(buf);
if (minioninfo->hchip_list[chip]->count < 2)
ghs = 0.0;
else {
@@ -3173,46 +3211,29 @@ static void chip_report(struct cgpu_info *minioncgpu)
ghs /= 1000000000.0;
ghs /= tdiff(&now, &(DATAH(minioninfo->hchip_list[chip]->tail)->when));
}
- res_err_count = minioninfo->res_err_count[chip];
- minioninfo->res_err_count[chip] = 0;
- if (res_err_count > 100)
- res_err_msg[0] = '!';
- else if (res_err_count > 50)
- res_err_msg[0] = '*';
- else
- res_err_msg[0] = '\'';
- snprintf(buf + len, sizeof(buf) - len,
- "%s%d=%s%.2f", any ? " " : "", chip,
- (res_err_count > 0) ? res_err_msg : "", ghs);
+ expect = (double)(minioninfo->init_freq[chip]) *
+ MINION_RESET_PERCENT / 1000.0;
+ howlong = tdiff(&now, &(minioninfo->last_reset[chip]));
+ if (ghs <= expect && howlong >= MINION_HISTORY_s)
+ minioninfo->do_reset[chip] = expect;
minioninfo->history_ghs[chip] = ghs;
- any = true;
- if (total_secs >= MINION_HISTORY_s) {
- expect = (double)(minioninfo->init_freq[chip]) *
- MINION_RESET_PERCENT / 1000.0;
- howlong = tdiff(&now, &(minioninfo->last_reset[chip]));
- if (ghs <= expect && howlong >= MINION_HISTORY_s)
- minioninfo->do_reset[chip] = expect;
- }
}
}
K_RUNLOCK(minioninfo->hfree_list);
- applogsiz(LOG_WARNING, 512,
- "%s%d: Chip GHs %s",
- minioncgpu->drv->name, minioncgpu->device_id, buf);
- memcpy(&(minioninfo->chip_rpt), &now, sizeof(now));
- }
- for (chip = 0; chip < MINION_CHIPS; chip++) {
- if (minioninfo->chip[chip]) {
- if (minioninfo->do_reset[chip] > 1.0) {
- applog(LOG_WARNING, "%s%d: Chip %d down to threshold %.2fGHs - resetting ...",
- minioncgpu->drv->name, minioncgpu->device_id,
- chip, minioninfo->do_reset[chip]);
- minioninfo->do_reset[chip] = 0.0;
- memcpy(&(minioninfo->last_reset[chip]), &now, sizeof(now));
- init_chip(minioncgpu, minioninfo, chip);
+ for (chip = 0; chip < MINION_CHIPS; chip++) {
+ if (minioninfo->chip[chip]) {
+ if (minioninfo->do_reset[chip] > 1.0) {
+ applog(LOG_WARNING, "%s%d: Chip %d down to threshold %.2fGHs - resetting ...",
+ minioncgpu->drv->name, minioncgpu->device_id,
+ chip, minioninfo->do_reset[chip]);
+ minioninfo->do_reset[chip] = 0.0;
+ memcpy(&(minioninfo->last_reset[chip]), &now, sizeof(now));
+ init_chip(minioncgpu, minioninfo, chip);
+ }
}
}
+ memcpy(&(minioninfo->chip_chk), &now, sizeof(now));
}
}
@@ -3234,8 +3255,8 @@ static int64_t minion_scanwork(__maybe_unused struct thr_info *thr)
if (opt_minion_idlecount)
idle_report(minioncgpu);
- if (opt_minion_chipreport > 0)
- chip_report(minioncgpu);
+ // Must always generate data to check/allow for chip reset
+ chip_report(minioncgpu);
/*
* To avoid wasting CPU, wait until we get an interrupt