Skip to content
Snippets Groups Projects
Commit 5c6458db authored by Moe Jette's avatar Moe Jette
Browse files

make some time stamps static so we can see delta_time and run things on a more controlled basis

parent eea81d25
No related branches found
No related tags found
No related merge requests found
...@@ -73,8 +73,8 @@ ...@@ -73,8 +73,8 @@
/* Programs to be executed to place nodes or out of power saving mode. These /* Programs to be executed to place nodes or out of power saving mode. These
* are run as user SlurmUser. The hostname of the node to be modified will be * are run as user SlurmUser. The hostname of the node to be modified will be
* passed as an argument to the program. */ * passed as an argument to the program. */
#define DEFAULT_SUSPEND_PROGRAM "/home/jette/slurm.way/sbin/slurm.node.suspend" #define DEFAULT_SUSPEND_PROGRAM "/home/jette/slurm.mdev/sbin/slurm.node.suspend"
#define DEFAULT_RESUME_PROGRAM "/home/jette/slurm.way/sbin/slurm.node.resume" #define DEFAULT_RESUME_PROGRAM "/home/jette/slurm.mdev/sbin/slurm.node.resume"
/* Individual nodes or all nodes in selected partitions can be excluded from /* Individual nodes or all nodes in selected partitions can be excluded from
* being placed into power saving mode. SLURM hostlist expressions can be used. * being placed into power saving mode. SLURM hostlist expressions can be used.
...@@ -102,8 +102,9 @@ static bool _valid_prog(char *file_name); ...@@ -102,8 +102,9 @@ static bool _valid_prog(char *file_name);
/* Perform any power change work to nodes */ /* Perform any power change work to nodes */
static void _do_power_work(void) static void _do_power_work(void)
{ {
static time_t last_log = 0, last_work_scan = 0;
int i, wake_cnt = 0, sleep_cnt = 0, susp_total = 0; int i, wake_cnt = 0, sleep_cnt = 0, susp_total = 0;
time_t now = time(NULL), last_work_scan = 0, last_log = 0, delta_t; time_t now = time(NULL), delta_t;
uint16_t base_state, susp_state; uint16_t base_state, susp_state;
bitstr_t *wake_node_bitmap = NULL, *sleep_node_bitmap = NULL; bitstr_t *wake_node_bitmap = NULL, *sleep_node_bitmap = NULL;
struct node_record *node_ptr; struct node_record *node_ptr;
...@@ -136,7 +137,7 @@ static void _do_power_work(void) ...@@ -136,7 +137,7 @@ static void _do_power_work(void)
wake_node_bitmap = bit_alloc(node_record_count); wake_node_bitmap = bit_alloc(node_record_count);
wake_cnt++; wake_cnt++;
suspend_cnt++; suspend_cnt++;
node_ptr->node_state |= NODE_STATE_POWER_SAVE; node_ptr->node_state &= (~NODE_STATE_POWER_SAVE);
bit_set(wake_node_bitmap, i); bit_set(wake_node_bitmap, i);
} }
if ((susp_state == 0) if ((susp_state == 0)
...@@ -149,12 +150,14 @@ static void _do_power_work(void) ...@@ -149,12 +150,14 @@ static void _do_power_work(void)
sleep_node_bitmap = bit_alloc(node_record_count); sleep_node_bitmap = bit_alloc(node_record_count);
sleep_cnt++; sleep_cnt++;
resume_cnt++; resume_cnt++;
node_ptr->node_state &= (~NODE_STATE_POWER_SAVE); node_ptr->node_state |= NODE_STATE_POWER_SAVE;
bit_set(sleep_node_bitmap, i); bit_set(sleep_node_bitmap, i);
} }
} }
if ((now - last_log) > 600) if ((now - last_log) > 600) {
info("Power save mode %d nodes", susp_total); info("Power save mode %d nodes", susp_total);
last_log = now;
}
if ((wake_cnt == 0) && (sleep_cnt == 0)) if ((wake_cnt == 0) && (sleep_cnt == 0))
_re_wake(); /* No work to be done now */ _re_wake(); /* No work to be done now */
...@@ -168,6 +171,7 @@ static void _do_power_work(void) ...@@ -168,6 +171,7 @@ static void _do_power_work(void)
error("power_save: bitmap2nodename"); error("power_save: bitmap2nodename");
xfree(nodes); xfree(nodes);
bit_free(sleep_node_bitmap); bit_free(sleep_node_bitmap);
last_node_update = now;
} }
if (wake_node_bitmap) { if (wake_node_bitmap) {
...@@ -179,6 +183,7 @@ static void _do_power_work(void) ...@@ -179,6 +183,7 @@ static void _do_power_work(void)
error("power_save: bitmap2nodename"); error("power_save: bitmap2nodename");
xfree(nodes); xfree(nodes);
bit_free(wake_node_bitmap); bit_free(wake_node_bitmap);
last_node_update = now;
} }
} }
...@@ -187,11 +192,18 @@ static void _do_power_work(void) ...@@ -187,11 +192,18 @@ static void _do_power_work(void)
* since there should be no change in power requirements. */ * since there should be no change in power requirements. */
static void _re_wake(void) static void _re_wake(void)
{ {
static time_t last_wakeup = 0;
static int last_inx = 0; static int last_inx = 0;
time_t now = time(NULL);
struct node_record *node_ptr; struct node_record *node_ptr;
bitstr_t *wake_node_bitmap = NULL; bitstr_t *wake_node_bitmap = NULL;
int i, lim = MIN(node_record_count, 20); int i, lim = MIN(node_record_count, 20);
/* Run at most once per minute */
if ((now - last_wakeup) < 60)
return;
last_wakeup = now;
for (i=0; i<lim; i++) { for (i=0; i<lim; i++) {
node_ptr = &node_record_table_ptr[last_inx]; node_ptr = &node_record_table_ptr[last_inx];
if ((node_ptr->node_state & NODE_STATE_POWER_SAVE) == 0) { if ((node_ptr->node_state & NODE_STATE_POWER_SAVE) == 0) {
...@@ -208,7 +220,11 @@ static void _re_wake(void) ...@@ -208,7 +220,11 @@ static void _re_wake(void)
char *nodes; char *nodes;
nodes = bitmap2node_name(wake_node_bitmap); nodes = bitmap2node_name(wake_node_bitmap);
if (nodes) { if (nodes) {
#if _DEBUG
info("power_save: rewaking nodes %s", nodes);
#else
debug("power_save: rewaking nodes %s", nodes); debug("power_save: rewaking nodes %s", nodes);
#endif
_run_prog(resume_prog, nodes); _run_prog(resume_prog, nodes);
} else } else
error("power_save: bitmap2nodename"); error("power_save: bitmap2nodename");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment