static void dump_resources(Resources *rsrcs) { char *id = "dump_resources"; /* Log the system's status */ #if 0 (void)sprintf(log_buffer, " %d%% usr, %d%% sys, %d%% idl", rsrcs->usrtime, rsrcs->systime, rsrcs->idltime); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); #endif /* 0 */ (void)sprintf(log_buffer, "Resources for host %s", rsrcs->exechost); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); (void)sprintf(log_buffer, " :: %-24s = %s", "Memory (free):", schd_byte2val(rsrcs->freemem)); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); (void)sprintf(log_buffer, " :: %-24s = %d / %d (%.2f%% utilization)", "Nodes allocated:", rsrcs->nodes_alloc, rsrcs->nodes_total, (rsrcs->nodes_alloc * 100.0) / rsrcs->nodes_total); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); #ifdef NODEMASK (void)sprintf(log_buffer, " :: %-24s = %s", "Nodes configured:", schd_format_nodemask(&(rsrcs->availmask), &(rsrcs->availmask))); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); (void)sprintf(log_buffer, " :: %-24s = %s", "Nodes in use:", schd_format_nodemask(&(rsrcs->availmask), &(rsrcs->nodes_used))); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); #endif /* NODEMASK */ (void)sprintf(log_buffer, " :: %-24s = %0.2f", "CPU Load average:", rsrcs->loadave); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); (void)sprintf(log_buffer, " :: %-24s = %d", "Running jobs:", rsrcs->njobs); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); if (schd_MANAGE_HPM) { (void)sprintf(log_buffer, " :: %-24s = %s mode, %sin use", "HPM Counters:", rsrcs->flags & RSRCS_FLAGS_HPM_USER ? "user" : "global", rsrcs->flags & RSRCS_FLAGS_HPM_IN_USE ? "" : "not "); log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer); } }
void schd_dump_queue(Queue *queue, int dumpjobs) { Job *job; UserAcl *aclent; char num[32]; char *ptr; int columns; #ifdef NODEMASK Bitfield all_ones; #endif /* NODEMASK */ DBPRT(("\nQueue '%s@%s': %sabled/%sed", queue->qname, queue->exechost, (queue->flags & QFLAGS_DISABLED) ? "Dis" : "En", (queue->flags & QFLAGS_STOPPED) ? "Stopp" : "Start")); DBPRT(("%s%s%s%s ", (queue->flags & QFLAGS_FULL) ? "/Full" : "", (queue->flags & QFLAGS_MAXRUN) ? "/MaxRun" : "", (queue->flags & QFLAGS_DRAINING) ? "/Drain" : "", (queue->flags & QFLAGS_USER_ACL) ? "/ACL" : "")); if (schd_ENFORCE_PRIME_TIME && schd_TimeNow >= schd_ENFORCE_PRIME_TIME) DBPRT(("obsv_pt:%s", queue->observe_pt ? "Yes" : "No")); DBPRT(("\n")); #ifdef NODEMASK if (queue->flags & QFLAGS_NODEMASK) { BITFIELD_SETALL(&all_ones); DBPRT((" Nodes: %s\n", schd_format_nodemask(&queue->queuemask, &all_ones))); DBPRT((" Avail: %s\n", schd_format_nodemask(&queue->queuemask, &queue->availmask))); } #endif /* NODEMASK */ sprintf(num, "%d", queue->running); DBPRT((" Job counts: %s running, ", queue->running != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->maxrun); DBPRT(("%s max ", queue->maxrun != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->userrun); DBPRT(("(%s/user), ", queue->userrun != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->queued); DBPRT(("%s queued\n", queue->queued != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->nodes_assn); DBPRT((" Nodes:%s/", queue->nodes_assn != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->nodes_max); DBPRT(("%s", queue->nodes_max != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->nodes_default); DBPRT((" [def %s, ", queue->nodes_default != UNSPECIFIED ? num : "???")); sprintf(num, "%d", queue->nodes_min); DBPRT(("min %s], ", queue->nodes_min != UNSPECIFIED ? num : "???")); DBPRT(("wallt max %s ", (queue->wallt_max != UNSPECIFIED) ? schd_sec2val(queue->wallt_max) : "???")); DBPRT(("[def %s ", queue->wallt_default != UNSPECIFIED ? schd_sec2val(queue->wallt_default) : "???")); DBPRT(("min %s]\n", (queue->wallt_min != UNSPECIFIED) ? schd_sec2val(queue->wallt_min) : "???")); if (queue->empty_by) /* ctime(2) returns a '\n'-terminated string, so no additional '\n' */ DBPRT((" Queue will empty by: %s", ctime(&queue->empty_by))); if (queue->idle_since) /* ctime(2) returns a '\n'-terminated string, so no additional '\n' */ DBPRT((" Queue idle since: %s", ctime(&queue->idle_since))); if (queue->useracl && (queue->flags & QFLAGS_USER_ACL)) { DBPRT((" User ACL: ")); columns = 9; /* Start with 9 columns for 'User ACL: ' */ for (aclent = queue->useracl; aclent != NULL; aclent = aclent->next) { columns += strlen(aclent->user) + 1; if (columns >= 72) { DBPRT(("\n ")); columns = 0; } DBPRT(("%s%s", ((columns == 0) || (aclent == queue->useracl)) ? "" : "/", aclent->user)); } DBPRT(("\n")); } if (dumpjobs && queue->jobs) { DBPRT((" Jobs: ")); columns = 5; /* Start with 5 columns for 'Jobs: ' */ for (job = queue->jobs; job != NULL; job = job->next) { /* Just the job numbers -- but be sure to put the '.' back! */ if ((ptr = strchr(job->jobid, '.')) != NULL) * ptr = '\0'; columns += strlen(job->jobid) + 3; /* 3 == job->state + '/' + ' ' */ if (columns >= 72) { DBPRT(("\n ")); columns = 0; } DBPRT((" %s/", job->jobid)); DBPRT(("%c", (job->flags & JFLAGS_PRIORITY) ? '!' : (job->flags & JFLAGS_WAITING) ? 'W' : job->state)); if (ptr != NULL) *ptr = '.'; } DBPRT(("\n")); } }
int schd_alloc_nodes(int request, Queue *queue, Bitfield *maskp) { char *id = "schd_alloc_nodes"; Bitfield avail; Bitfield mask; Bitfield contig; int remain; int qmsb; int qlsb; int i, n; int count; int found; /* Make certain the nodecount request can be fulfilled. */ if (request <= 0 || request > BITFIELD_NUM_ONES(&(queue->availmask))) return 0; /* * Make a copy of the queue's available bit mask to play with, and clear * the allocated nodes mask. */ BITFIELD_CPY(&avail, &(queue->availmask)); BITFIELD_CLRALL(&mask); /* How many have been found, and how many remain. */ found = 0; remain = request; while (remain > 0) { /* * Find first and last available bit positions in the * queue's available node mask. */ qmsb = BITFIELD_MS_ONE(&avail); qlsb = BITFIELD_LS_ONE(&avail); /* * Starting with the size of the remaining nodes needed to satisfy * this request, look for a set of 'n' contiguous bits in the * available node mask. If that is not found, try the next smallest * contiguous vector, etc. */ for (n = remain; n > 0; n--) { /* * Create a contiguous bitmask of 'n' bits, starting at the * position of the highest bit in the avail mask. */ BITFIELD_CLRALL(&contig); for (i = 0; i < n; i++) BITFIELD_SETB(&contig, qmsb - i); /* * Calculate how many times this contiguous bitmask needs to be * shifted to the right to cover every set of 'n' bits between * the qmsb and qlsb, inclusive. Count the initial configuration * as well (the trailing '+ 1'). */ count = (qmsb + 1 - qlsb) - n + 1; /* * Shift the contiguous mask right one bit at a time, checking * if all the bits in the mask are set in the available mask. */ for (i = 0; i < count; i++) { /* Are all bits in contig also set in the avail mask? */ if (BITFIELD_TSTALLM(&avail, &contig)) { break; } BITFIELD_SHIFTR(&contig); } /* * If the contiguous bits are available, add them to the new job * nodemask, and remove them from the avail mask. Adjust the * remaining node count, and start the next hunt for the remaining * nodes. */ if (i < count) { BITFIELD_SETM(&mask, &contig); BITFIELD_CLRM(&avail, &contig); found += n; remain -= n; break; /* for(n) loop */ } } /* Check for something going wrong. */ if (n == 0) { DBPRT(("%s: couldn't find any contiguous bits (even one!)\n", id)); break; /* while(remain) loop */ } } /* * If no bits remain to be allocated, copy the new mask into the provided * space, and return the number of bits requested. */ if (!remain && (found == request)) { BITFIELD_CPY(maskp, &mask); DBPRT(("%s: mask %s\n", id, schd_format_nodemask(&queue->queuemask, maskp))); return found; } return 0; }