Modify thread naming to make them easier to identify
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
diff --git a/api.c b/api.c
index c62754b..546d3a6 100644
--- a/api.c
+++ b/api.c
@@ -4388,7 +4388,7 @@ static void *mcast_thread(void *userdata)
pthread_detach(pthread_self());
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("api_mcast");
+ RenameThread("APIMcast");
mcast();
diff --git a/cgminer.c b/cgminer.c
index 2aed581..9ae57f0 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3369,7 +3369,7 @@ static void *submit_work_thread(void *userdata)
pthread_detach(pthread_self());
- RenameThread("submit_work");
+ RenameThread("SubmitWork");
applog(LOG_DEBUG, "Creating extra submit work thread");
@@ -4875,7 +4875,7 @@ static void *input_thread(void __maybe_unused *userdata)
{
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("input");
+ RenameThread("Input");
if (!curses_active)
return NULL;
@@ -4910,7 +4910,7 @@ static void *api_thread(void *userdata)
pthread_detach(pthread_self());
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("api");
+ RenameThread("API");
set_lowprio();
api(api_thr_id);
@@ -5286,7 +5286,7 @@ static void *stratum_rthread(void *userdata)
pthread_detach(pthread_self());
- snprintf(threadname, 16, "StratumR/%d", pool->pool_no);
+ snprintf(threadname, sizeof(threadname), "%d/RStratum", pool->pool_no);
RenameThread(threadname);
while (42) {
@@ -5394,7 +5394,7 @@ static void *stratum_sthread(void *userdata)
pthread_detach(pthread_self());
- snprintf(threadname, 16, "StratumS/%d", pool->pool_no);
+ snprintf(threadname, sizeof(threadname), "%d/SStratum", pool->pool_no);
RenameThread(threadname);
pool->stratum_q = tq_new();
@@ -6587,9 +6587,9 @@ void *miner_thread(void *userdata)
const int thr_id = mythr->id;
struct cgpu_info *cgpu = mythr->cgpu;
struct device_drv *drv = cgpu->drv;
- char threadname[24];
+ char threadname[16];
- snprintf(threadname, 24, "miner/%d", thr_id);
+ snprintf(threadname, sizeof(threadname), "%d/Miner", thr_id);
RenameThread(threadname);
thread_reportout(mythr);
@@ -6717,7 +6717,7 @@ static void *longpoll_thread(void *userdata)
char *lp_url;
int rolltime;
- snprintf(threadname, 16, "longpoll/%d", cp->pool_no);
+ snprintf(threadname, sizeof(threadname), "%d/Longpoll", cp->pool_no);
RenameThread(threadname);
curl = curl_easy_init();
@@ -6883,7 +6883,7 @@ static void *watchpool_thread(void __maybe_unused *userdata)
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("watchpool");
+ RenameThread("Watchpool");
set_lowprio();
@@ -6968,7 +6968,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("watchdog");
+ RenameThread("Watchdog");
set_lowprio();
memset(&zero_tv, 0, sizeof(struct timeval));
@@ -7732,7 +7732,7 @@ static void *hotplug_thread(void __maybe_unused *userdata)
{
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("hotplug");
+ RenameThread("Hotplug");
set_lowprio();
@@ -7785,7 +7785,7 @@ static void *libusb_poll_thread(void __maybe_unused *arg)
{
struct timeval tv_end = {1, 0};
- RenameThread("usbpoll");
+ RenameThread("USBPoll");
while (usb_polling)
libusb_handle_events_timeout_completed(NULL, &tv_end, NULL);
diff --git a/driver-avalon.c b/driver-avalon.c
index 2727c8b..bb6121e 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -1012,9 +1012,9 @@ static void *avalon_get_results(void *userdata)
char readbuf[AVALON_READBUF_SIZE];
struct thr_info *thr = info->thr;
int offset = 0, ret = 0;
- char threadname[24];
+ char threadname[16];
- snprintf(threadname, 24, "ava_recv/%d", avalon->device_id);
+ snprintf(threadname, sizeof(threadname), "%d/AvaRecv", avalon->device_id);
RenameThread(threadname);
while (likely(!avalon->shutdown)) {
@@ -1147,9 +1147,9 @@ static void *avalon_send_tasks(void *userdata)
struct cgpu_info *avalon = (struct cgpu_info *)userdata;
struct avalon_info *info = avalon->device_data;
const int avalon_get_work_count = info->miner_count;
- char threadname[24];
+ char threadname[16];
- snprintf(threadname, 24, "ava_send/%d", avalon->device_id);
+ snprintf(threadname, sizeof(threadname), "%d/AvaSend", avalon->device_id);
RenameThread(threadname);
while (likely(!avalon->shutdown)) {
@@ -1236,9 +1236,9 @@ static void *bitburner_send_tasks(void *userdata)
struct cgpu_info *avalon = (struct cgpu_info *)userdata;
struct avalon_info *info = avalon->device_data;
const int avalon_get_work_count = info->miner_count;
- char threadname[24];
+ char threadname[16];
- snprintf(threadname, 24, "ava_send/%d", avalon->device_id);
+ snprintf(threadname, sizeof(threadname), "%d/AvaSend", avalon->device_id);
RenameThread(threadname);
while (likely(!avalon->shutdown)) {
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 98496bf..d60eae0 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -765,9 +765,9 @@ static void *hfa_read(void *arg)
struct thr_info *thr = (struct thr_info *)arg;
struct cgpu_info *hashfast = thr->cgpu;
struct hashfast_info *info = hashfast->device_data;
- char threadname[24];
+ char threadname[16];
- snprintf(threadname, 24, "hfa_read/%d", hashfast->device_id);
+ snprintf(threadname, sizeof(threadname), "%d/HfaRead", hashfast->device_id);
RenameThread(threadname);
while (likely(!hashfast->shutdown)) {
diff --git a/usbutils.c b/usbutils.c
index 4e76e13..88ebd07 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -3716,7 +3716,7 @@ void *usb_resource_thread(void __maybe_unused *userdata)
{
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- RenameThread("usbresource");
+ RenameThread("USBResource");
applog(LOG_DEBUG, "RES: thread starting");
diff --git a/util.c b/util.c
index 16aa8da..9452293 100644
--- a/util.c
+++ b/util.c
@@ -2531,16 +2531,19 @@ void *str_text(char *ptr)
void RenameThread(const char* name)
{
+ char buf[16];
+
+ snprintf(buf, sizeof(buf), "cg@%s", name);
#if defined(PR_SET_NAME)
// Only the first 15 characters are used (16 - NUL terminator)
- prctl(PR_SET_NAME, name, 0, 0, 0);
+ prctl(PR_SET_NAME, buf, 0, 0, 0);
#elif (defined(__FreeBSD__) || defined(__OpenBSD__))
- pthread_set_name_np(pthread_self(), name);
+ pthread_set_name_np(pthread_self(), buf);
#elif defined(MAC_OSX)
- pthread_setname_np(name);
+ pthread_setname_np(buf);
#else
- // Prevent warnings for unused parameters...
- (void)name;
+ // Prevent warnings
+ (void)buf;
#endif
}