static void *_node_update(void *args) { char *node_name = (char *) args; char *argv[10], nid_str[32], *resp_msg; int i, nid = -1, status = 0; bool node_state_ok, node_off_sent = false; time_t poll_start; for (i = 0; node_name[i]; i++) { if ((node_name[i] >= '0') && (node_name[i] <= '9')) { nid = strtol(node_name + i, NULL, 10); break; } } if (nid < 0) { error("%s: No valid NID: %s", prog_name, node_name); return NULL; } snprintf(nid_str, sizeof(nid_str), "%d", nid); /* Request node power down. * Example: "capmc node_off –n 43" */ argv[0] = "capmc"; argv[1] = "node_off"; argv[2] = "-n"; argv[3] = nid_str; argv[4] = NULL; for (i = 0; ((i < NODE_OFF_RETRIES) && !node_off_sent); i++) { resp_msg = _run_script(argv, &status); if ((status != 0) || (resp_msg && (strcasestr(resp_msg, "Success") == NULL))) { error("%s: capmc(%s,%s,%s): %d %s", prog_name, argv[1], argv[2], argv[3], status, resp_msg); sleep(1); } else { debug("%s: node_off sent to %s", prog_name, nid_str); node_off_sent = true; } xfree(resp_msg); } /* Wait for node in "off" state */ poll_start = time(NULL); while (!node_state_ok && (difftime(time(NULL), poll_start) < NODE_OFF_STATE_WAIT)) { sleep(capmc_poll_freq); node_state_ok = _check_node_state(nid, nid_str, "off"); } slurm_mutex_lock(&thread_cnt_mutex); thread_cnt--; pthread_cond_signal(&thread_cnt_cond); slurm_mutex_unlock(&thread_cnt_mutex); return NULL; }
static void *_node_update(void *args) { char *node_name = (char *) args; char *argv[10], nid_str[32], *resp_msg; int i, nid = -1, status = 0; bool node_state_ok; for (i = 0; node_name[i]; i++) { if ((node_name[i] >= '0') && (node_name[i] <= '9')) { nid = strtol(node_name + i, NULL, 10); break; } } if (nid < 0) { error("%s: No valid NID: %s", log_file, node_name); goto fini; } snprintf(nid_str, sizeof(nid_str), "%d", nid); if (mcdram_mode) { /* Update MCDRAM mode. * Example: "capmc set_mcdram_cfg –n 43 –m cache" */ argv[0] = "capmc"; argv[1] = "set_mcdram_cfg"; argv[2] = "-n"; argv[3] = nid_str; argv[4] = "-m"; argv[5] = mcdram_mode; argv[6] = NULL; resp_msg = _run_script(argv, &status); if (status != 0) { error("%s: capmc(%s,%s,%s,%s,%s): %d %s", log_file, argv[1], argv[2], argv[3], argv[4], argv[5], status, resp_msg); } xfree(resp_msg); } if (numa_mode) { /* Update NUMA mode. * Example: "capmc set_numa_cfg –n 43 –m a2a" */ argv[0] = "capmc"; argv[1] = "set_numa_cfg"; argv[2] = "-n"; argv[3] = nid_str; argv[4] = "-m"; argv[5] = numa_mode; argv[6] = NULL; resp_msg = _run_script(argv, &status); if (status != 0) { error("%s: capmc(%s,%s,%s,%s,%s): %d %s", log_file, argv[1], argv[2], argv[3], argv[4], argv[5], status, resp_msg); } xfree(resp_msg); } /* Test if already in "off" state */ node_state_ok = _check_node_state(nid, nid_str, "off"); /* Request node power down. * Example: "capmc node_off –n 43" */ if (!node_state_ok) { argv[0] = "capmc"; argv[1] = "node_off"; argv[2] = "-n"; argv[3] = nid_str; argv[4] = NULL; resp_msg = _run_script(argv, &status); if (status != 0) { error("%s: capmc(%s,%s,%s): %d %s", log_file, argv[1], argv[2], argv[3], status, resp_msg); } xfree(resp_msg); } /* Wait for node in "off" state */ while (!node_state_ok) { sleep(2); node_state_ok = _check_node_state(nid, nid_str, "off"); } /* Request node power up. * Example: "capmc node_up –n 43" */ argv[0] = "capmc"; argv[1] = "node_up"; argv[2] = "-n"; argv[3] = nid_str; argv[4] = NULL; resp_msg = _run_script(argv, &status); if (status != 0) { error("%s: capmc(%s,%s,%s): %d %s", log_file, argv[1], argv[2], argv[3], status, resp_msg); } xfree(resp_msg); fini: slurm_mutex_lock(&thread_cnt_mutex); thread_cnt--; pthread_cond_signal(&thread_cnt_cond); slurm_mutex_unlock(&thread_cnt_mutex); return NULL; }