From d51b03d030de05a1a561b5f5a3da625aeeec3e5e Mon Sep 17 00:00:00 2001 From: Danny Auble <da@schedmd.com> Date: Thu, 10 Nov 2011 14:37:33 -0800 Subject: [PATCH] BLUEGENE - remove job_running var from block_info_t, was replaced by new job_list variable already added. --- slurm/slurm.h.in | 1 - src/api/block_info.c | 14 +++- src/api/init_msg.c | 1 - src/plugins/select/bluegene/select_bluegene.c | 9 +- src/smap/partition_functions.c | 84 ++++++++++++------- src/sview/block_info.c | 76 +++++++++++------ src/sview/grid.c | 2 +- 7 files changed, 122 insertions(+), 65 deletions(-) diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in index dfe29ab599e..0ed374bd17b 100644 --- a/slurm/slurm.h.in +++ b/slurm/slurm.h.in @@ -1572,7 +1572,6 @@ typedef struct { * start_range_2, .., -1 */ char *ionode_str; List job_list; /* List of running jobs on each block */ - uint32_t job_running; char *linuximage; /* LinuxImage for this block */ char *mloaderimage; /* mloaderImage for this block */ int *mp_inx; /* list index pairs into node_table for *mp_str: diff --git a/src/api/block_info.c b/src/api/block_info.c index c92cae249de..1fb1b2e8bea 100644 --- a/src/api/block_info.c +++ b/src/api/block_info.c @@ -133,10 +133,18 @@ char *slurm_sprint_block_info( line_end); /****** Line 2 ******/ - if (block_ptr->job_running > NO_JOB_RUNNING) - xstrfmtcat(out, "JobRunning=%u ", block_ptr->job_running); - else + j = 0; + if (block_ptr->job_list) + j = list_count(block_ptr->job_list); + + if (!j) xstrcat(out, "JobRunning=NONE "); + else if (j == 1) { + block_job_info_t *block_job = list_peek(block_ptr->job_list); + xstrfmtcat(out, "JobRunning=%u ", block_job->job_id); + } else + xstrcat(out, "JobRunning=Multiple "); + tmp_char = conn_type_string_full(block_ptr->conn_type); xstrfmtcat(out, "ConnType=%s", tmp_char); xfree(tmp_char); diff --git a/src/api/init_msg.c b/src/api/init_msg.c index 41b68f11be3..703355c1fad 100644 --- a/src/api/init_msg.c +++ b/src/api/init_msg.c @@ -178,7 +178,6 @@ void slurm_init_update_block_msg (update_block_msg_t *update_block_msg) { memset(update_block_msg, 0, sizeof(update_block_msg_t)); update_block_msg->conn_type[0] = (uint16_t)NO_VAL; - update_block_msg->job_running = NO_VAL; update_block_msg->cnode_cnt = NO_VAL; update_block_msg->node_use = (uint16_t)NO_VAL; update_block_msg->state = (uint16_t)NO_VAL; diff --git a/src/plugins/select/bluegene/select_bluegene.c b/src/plugins/select/bluegene/select_bluegene.c index 4e6044d5237..e43ba1810f4 100644 --- a/src/plugins/select/bluegene/select_bluegene.c +++ b/src/plugins/select/bluegene/select_bluegene.c @@ -389,20 +389,15 @@ static bg_record_t *_translate_info_2_record(block_info_t *block_info) */ bg_record->state = block_info->state; - bg_record->job_running = block_info->job_running; - if (bg_record->job_running > NO_JOB_RUNNING) - bg_record->job_ptr = find_job_record(bg_record->job_running); - bg_record->cnode_cnt = block_info->cnode_cnt; bg_record->mp_count = bit_set_count(bg_record->mp_bitmap); /* Don't copy the job_list from the block_info, we will fill it in later in the job sync. */ - if (bg_conf->sub_blocks && (bg_record->mp_count == 1)) { + bg_record->job_running = NO_JOB_RUNNING; + if (bg_conf->sub_blocks && (bg_record->mp_count == 1)) bg_record->job_list = list_create(NULL); - bg_record->job_running = NO_JOB_RUNNING; - } #ifdef HAVE_BGL bg_record->node_use = block_info->node_use; diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index bd5c7f1b09c..c3ffd28186b 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -50,7 +50,7 @@ typedef struct { uint16_t bg_conn_type[HIGHEST_DIMENSIONS]; uint16_t bg_node_use; char *ionode_str; - int job_running; + List job_list; int letter_num; List nodelist; char *mp_str; @@ -65,7 +65,6 @@ static List block_list = NULL; static void _block_list_del(void *object); static int _in_slurm_partition(List slurm_nodes, List bg_nodes); -static int _list_match_all(void *object, void *key); static int _make_nodelist(char *nodes, List nodelist); static void _marknodes(db2_block_info_t *block_ptr, int count); static void _nodelist_del(void *object); @@ -255,7 +254,7 @@ extern void get_bg_part(void) } if (block_list) { /* clear the old list */ - list_delete_all(block_list, _list_match_all, NULL); + list_flush(block_list); } else { block_list = list_create(_block_list_del); if (!block_list) { @@ -328,8 +327,21 @@ extern void get_bg_part(void) last_count++; _marknodes(block_ptr, last_count); } - block_ptr->job_running = - new_bg_ptr->block_array[i].job_running; + + block_ptr->job_list = list_create(slurm_free_block_job_info); + if (new_bg_ptr->block_array[i].job_list) { + block_job_info_t *found_job; + ListIterator itr = list_iterator_create( + new_bg_ptr->block_array[i].job_list); + while ((found_job = list_next(itr))) { + block_job_info_t *block_job = + xmalloc(sizeof(block_job_info_t)); + block_job->job_id = found_job->job_id; + list_append(block_ptr->job_list, block_job); + } + list_iterator_destroy(itr); + } + if (block_ptr->bg_conn_type[0] >= SELECT_SMALL) block_ptr->size = 0; @@ -393,6 +405,32 @@ extern void get_bg_part(void) return; } +static char *_set_running_job_str(List job_list, bool compact) +{ + int cnt = list_count(job_list); + block_job_info_t *block_job; + + if (!cnt) { + return xstrdup("-"); + } else if (cnt == 1) { + block_job = list_peek(job_list); + return xstrdup_printf("%u", block_job->job_id); + } else if (compact) + return xstrdup("multiple"); + else { + char *tmp_char = NULL; + ListIterator itr = list_iterator_create(job_list); + while ((block_job = list_next(itr))) { + if (tmp_char) + xstrcat(tmp_char, " "); + xstrfmtcat(tmp_char, "%u", block_job->job_id); + } + return tmp_char; + } + + return NULL; +} + static void _marknodes(db2_block_info_t *block_ptr, int count) { int i, j = 0; @@ -498,7 +536,6 @@ static void _print_header_part(void) printf(" BG_BLOCK "); printf("STATE "); printf(" JOBID "); - printf(" USER "); printf(" CONN "); if (params.cluster_flags & CLUSTER_FLAG_BGL) printf(" NODE_USE "); @@ -582,6 +619,8 @@ static int _print_text_part(partition_info_t *part_ptr, if (params.display == BGPART) { if (db2_info_ptr) { + char *job_running = _set_running_job_str( + db2_info_ptr->job_list, 1); mvwprintw(text_win, main_ycord, main_xcord, "%.16s", @@ -594,13 +633,9 @@ static int _print_text_part(partition_info_t *part_ptr, db2_info_ptr->state)); main_xcord += 7; - if (db2_info_ptr->job_running > NO_JOB_RUNNING) - snprintf(tmp_char, sizeof(tmp_char), - "%d", - db2_info_ptr->job_running); - else - snprintf(tmp_char, sizeof(tmp_char), - "-"); + snprintf(tmp_char, sizeof(tmp_char), + "%s", job_running); + xfree(job_running); mvwprintw(text_win, main_ycord, @@ -737,21 +772,16 @@ static int _print_text_part(partition_info_t *part_ptr, if (params.display == BGPART) { if (db2_info_ptr) { + char *job_running = _set_running_job_str( + db2_info_ptr->job_list, 1); printf("%16.16s ", db2_info_ptr->bg_block_name); printf("%5.5s ", bg_block_state_string( db2_info_ptr->state)); - if (db2_info_ptr->job_running > NO_JOB_RUNNING) - snprintf(tmp_char, sizeof(tmp_char), - "%d", - db2_info_ptr->job_running); - else - snprintf(tmp_char, sizeof(tmp_char), - "-"); - - printf("%8.8s ", tmp_char); + printf("%8.8s ", job_running); + xfree(job_running); conn_str = conn_type_string_full( db2_info_ptr->bg_conn_type); @@ -792,7 +822,10 @@ static void _block_list_del(void *object) xfree(block_ptr->ionode_str); if (block_ptr->nodelist) list_destroy(block_ptr->nodelist); - + if (block_ptr->job_list) { + list_destroy(block_ptr->job_list); + block_ptr->job_list = NULL; + } xfree(block_ptr); } @@ -805,11 +838,6 @@ static void _nodelist_del(void *object) return; } -static int _list_match_all(void *object, void *key) -{ - return 1; -} - static int _in_slurm_partition(List slurm_nodes, List bg_nodes) { ListIterator slurm_itr; diff --git a/src/sview/block_info.c b/src/sview/block_info.c index d2379ff4776..2082d4aa596 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -46,7 +46,7 @@ typedef struct { * start_range_1, end_range_1, * start_range_2, .., -1 */ int color_inx; - int job_running; + List job_list; bool printed; bool small_block; char *imageblrts; /* ImageBlrts for this block */ @@ -185,6 +185,32 @@ static int _in_slurm_partition(int *part_inx, int *block_inx); static void _process_each_block(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter*iter, gpointer userdata); +static char *_set_running_job_str(List job_list, bool compact) +{ + int cnt = list_count(job_list); + block_job_info_t *block_job; + + if (!cnt) { + return xstrdup("-"); + } else if (cnt == 1) { + block_job = list_peek(job_list); + return xstrdup_printf("%u", block_job->job_id); + } else if (compact) + return xstrdup("multiple"); + else { + char *tmp_char = NULL; + ListIterator itr = list_iterator_create(job_list); + while ((block_job = list_next(itr))) { + if (tmp_char) + xstrcat(tmp_char, " "); + xstrfmtcat(tmp_char, "%u", block_job->job_id); + } + return tmp_char; + } + + return NULL; +} + static void _block_list_del(void *object) { sview_block_info_t *block_ptr = (sview_block_info_t *)object; @@ -197,6 +223,12 @@ static void _block_list_del(void *object) xfree(block_ptr->imagelinux); xfree(block_ptr->imagemloader); xfree(block_ptr->imageramdisk); + + if (block_ptr->job_list) { + list_destroy(block_ptr->job_list); + block_ptr->job_list = NULL; + } + /* don't xfree(block_ptr->mp_inx); it isn't copied like the chars and is freed in the api */ @@ -287,16 +319,13 @@ static void _layout_block_record(GtkTreeView *treeview, block_ptr->imageramdisk); } - if (block_ptr->job_running > NO_JOB_RUNNING) - snprintf(tmp_cnt, sizeof(tmp_cnt), - "%d", block_ptr->job_running); - else - snprintf(tmp_cnt, sizeof(tmp_cnt), "-"); + tmp_char = _set_running_job_str(block_ptr->job_list, 0); add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_block, SORTID_JOB), - tmp_cnt); + tmp_char); + xfree(tmp_char); if (cluster_flags & CLUSTER_FLAG_BGL) { add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_block, @@ -324,19 +353,14 @@ static void _layout_block_record(GtkTreeView *treeview, static void _update_block_record(sview_block_info_t *block_ptr, GtkTreeStore *treestore, GtkTreeIter *iter) { - char job_running[20], cnode_cnt[20]; - char *tmp_char = NULL; - - if (block_ptr->job_running > NO_JOB_RUNNING) - snprintf(job_running, sizeof(job_running), - "%d", block_ptr->job_running); - else - snprintf(job_running, sizeof(job_running), "-"); + char cnode_cnt[20]; + char *tmp_char = NULL, *tmp_char2 = NULL; - convert_num_unit((float)block_ptr->cnode_cnt, cnode_cnt, sizeof(cnode_cnt), - UNIT_NONE); + convert_num_unit((float)block_ptr->cnode_cnt, cnode_cnt, + sizeof(cnode_cnt), UNIT_NONE); tmp_char = conn_type_string_full(block_ptr->bg_conn_type); + tmp_char2 = _set_running_job_str(block_ptr->job_list, 0); /* Combining these records provides a slight performance improvement */ gtk_tree_store_set(treestore, iter, @@ -346,7 +370,7 @@ static void _update_block_record(sview_block_info_t *block_ptr, SORTID_COLOR_INX, block_ptr->color_inx, SORTID_CONN, tmp_char, SORTID_IMAGEMLOADER, block_ptr->imagemloader, - SORTID_JOB, job_running, + SORTID_JOB, tmp_char2, SORTID_NODE_INX, block_ptr->mp_inx, SORTID_MP_STR, cnode_cnt, SORTID_NODELIST, block_ptr->mp_str, @@ -357,6 +381,7 @@ static void _update_block_record(sview_block_info_t *block_ptr, SORTID_UPDATED, 1, -1); xfree(tmp_char); + xfree(tmp_char2); if (cluster_flags & CLUSTER_FLAG_BGP) { gtk_tree_store_set(treestore, iter, @@ -471,11 +496,9 @@ static int _sview_block_sort_aval_dec(sview_block_info_t* rec_a, int size_a = rec_a->cnode_cnt; int size_b = rec_b->cnode_cnt; - if ((rec_a->job_running == NO_JOB_RUNNING) - && (rec_b->job_running != NO_JOB_RUNNING)) + if (list_count(rec_a->job_list) < list_count(rec_b->job_list)) return 1; - else if ((rec_a->job_running != NO_JOB_RUNNING) - && (rec_b->job_running == NO_JOB_RUNNING)) + else if (list_count(rec_a->job_list) > list_count(rec_b->job_list)) return -1; if ((rec_a->state == BG_BLOCK_FREE) && (rec_b->state != BG_BLOCK_FREE)) @@ -622,6 +645,11 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, = block_info_ptr->block_array[i].mp_inx; _set_block_partition(part_info_ptr, block_ptr); + block_ptr->job_list = list_create(slurm_free_block_job_info); + if (block_info_ptr->block_array[i].job_list) + list_transfer(block_ptr->job_list, + block_info_ptr->block_array[i].job_list); + if (block_ptr->bg_conn_type[0] >= SELECT_SMALL) block_ptr->size = 0; @@ -670,7 +698,7 @@ need_refresh: if (block_ptr->state & BG_BLOCK_ERROR_FLAG) state = NODE_STATE_ERROR; - else if (block_ptr->job_running > NO_JOB_RUNNING) + else if (list_count(block_ptr->job_list)) state = NODE_STATE_ALLOCATED; else state = NODE_STATE_IDLE; @@ -1300,7 +1328,7 @@ display_it: if (block_ptr->state & BG_BLOCK_ERROR_FLAG) state = NODE_STATE_ERROR; - else if (block_ptr->job_running > NO_JOB_RUNNING) + else if (list_count(block_ptr->job_list)) state = NODE_STATE_ALLOCATED; else state = NODE_STATE_IDLE; diff --git a/src/sview/grid.c b/src/sview/grid.c index 78edc547447..d9b19454212 100644 --- a/src/sview/grid.c +++ b/src/sview/grid.c @@ -1362,7 +1362,7 @@ extern void add_extra_bluegene_buttons(List *button_list, int inx, } if (bg_info_ptr->state & BG_BLOCK_ERROR_FLAG) grid_button->state = NODE_STATE_ERROR; - else if (bg_info_ptr->job_running > NO_JOB_RUNNING) + else if (list_count(bg_info_ptr->job_list)) grid_button->state = NODE_STATE_ALLOCATED; else grid_button->state = NODE_STATE_IDLE; -- GitLab