forked from lei.chen/myxce
make unsatisfy_() just print unmeet resources
This commit is contained in:
parent
febb4a6c4d
commit
aae4c672b5
1 changed files with 35 additions and 27 deletions
|
|
@ -102,9 +102,11 @@ static int unsatisfy_(xce_scheduler_t* sched, int nres, int* idxs, float* total,
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = 0; i < nres; i++) {
|
for (i = 0; i < nres; i++) {
|
||||||
TRACE("%s resource %d total %f inuse %f uncomit %f wanted %f", __func__,
|
|
||||||
idxs[i], total[i], inuse[i], uncomitted[i], wanted[i]);
|
|
||||||
if (total[i] < inuse[i] + uncomitted[i] + wanted[i]) {
|
if (total[i] < inuse[i] + uncomitted[i] + wanted[i]) {
|
||||||
|
TRACE("%s resource %d total %f inuse %f uncomit %f wanted %f",
|
||||||
|
__func__, idxs[i], total[i], inuse[i], uncomitted[i],
|
||||||
|
wanted[i]);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,8 +118,8 @@ static int unsatisfy_(xce_scheduler_t* sched, int nres, int* idxs, float* total,
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < nres; i++) {
|
for (i = 0; i < nres; i++) {
|
||||||
if (total[i] < inuse[i] + uncomitted[i] + wanted[i]) {
|
if (total[i] < inuse[i] + uncomitted[i] + wanted[i]) {
|
||||||
xce_resource_t* r = NULL;
|
xce_resource_t* r = NULL;
|
||||||
float need = inuse[i] + uncomitted[i] + wanted[i] - total[i];
|
float need = inuse[i] + uncomitted[i] + wanted[i] - total[i];
|
||||||
|
|
||||||
vget(sched->resmgr, idxs[i], (void**)&r);
|
vget(sched->resmgr, idxs[i], (void**)&r);
|
||||||
TRACE("%s unmet resource %d (%s) shortfall %f", __func__, idxs[i],
|
TRACE("%s unmet resource %d (%s) shortfall %f", __func__, idxs[i],
|
||||||
|
|
@ -132,14 +134,16 @@ static int unsatisfy_(xce_scheduler_t* sched, int nres, int* idxs, float* total,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static host_eval_ctx_t*
|
static host_eval_ctx_t* build_host_eval_ctx(const xce_sched_worker_t* w,
|
||||||
build_host_eval_ctx(const xce_sched_worker_t* w, int num_res)
|
int num_res)
|
||||||
{
|
{
|
||||||
host_eval_ctx_t* ctx = calloc(1, sizeof(*ctx));
|
host_eval_ctx_t* ctx = calloc(1, sizeof(*ctx));
|
||||||
if (ctx == NULL) return NULL;
|
if (ctx == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (num_res <= 0) {
|
if (num_res <= 0) {
|
||||||
/* valid empty context — numvals/strvals remain NULL, bounds checks protect access */
|
/* valid empty context — numvals/strvals remain NULL, bounds checks
|
||||||
|
* protect access */
|
||||||
ctx->num_res = 0;
|
ctx->num_res = 0;
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
@ -155,7 +159,8 @@ build_host_eval_ctx(const xce_sched_worker_t* w, int num_res)
|
||||||
|
|
||||||
for (int i = 0; i < num_res; i++) {
|
for (int i = 0; i < num_res; i++) {
|
||||||
xce_val_t* v = (xce_val_t*)zarray_get((zarray_t*)&w->resvals, i);
|
xce_val_t* v = (xce_val_t*)zarray_get((zarray_t*)&w->resvals, i);
|
||||||
if (v == NULL) continue;
|
if (v == NULL)
|
||||||
|
continue;
|
||||||
switch (v->which) {
|
switch (v->which) {
|
||||||
case Value_u_fvalue:
|
case Value_u_fvalue:
|
||||||
numvals[i] = (double)v->u.fvalue;
|
numvals[i] = (double)v->u.fvalue;
|
||||||
|
|
@ -175,10 +180,10 @@ build_host_eval_ctx(const xce_sched_worker_t* w, int num_res)
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void free_host_eval_ctx(host_eval_ctx_t* ctx)
|
||||||
free_host_eval_ctx(host_eval_ctx_t* ctx)
|
|
||||||
{
|
{
|
||||||
if (ctx == NULL) return;
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
free((void*)ctx->numvals);
|
free((void*)ctx->numvals);
|
||||||
free((void*)ctx->strvals);
|
free((void*)ctx->strvals);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
|
|
@ -186,7 +191,8 @@ free_host_eval_ctx(host_eval_ctx_t* ctx)
|
||||||
|
|
||||||
void sched_worker_release_host_ctx(xce_sched_worker_t* w)
|
void sched_worker_release_host_ctx(xce_sched_worker_t* w)
|
||||||
{
|
{
|
||||||
if (w == NULL) return;
|
if (w == NULL)
|
||||||
|
return;
|
||||||
free_host_eval_ctx(w->host_eval_ctx);
|
free_host_eval_ctx(w->host_eval_ctx);
|
||||||
w->host_eval_ctx = NULL;
|
w->host_eval_ctx = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -194,11 +200,12 @@ void sched_worker_release_host_ctx(xce_sched_worker_t* w)
|
||||||
int sched_meet_host_selection(xce_scheduler_t* sched, xce_sched_worker_t* w,
|
int sched_meet_host_selection(xce_scheduler_t* sched, xce_sched_worker_t* w,
|
||||||
xce_select_t* s)
|
xce_select_t* s)
|
||||||
{
|
{
|
||||||
if (s == NULL || s->root == NULL) return 1;
|
if (s == NULL || s->root == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* Build host context lazily — reused for all jobs against this host. */
|
/* Build host context lazily — reused for all jobs against this host. */
|
||||||
if (w->host_eval_ctx == NULL) {
|
if (w->host_eval_ctx == NULL) {
|
||||||
int num_res = (int)w->resvals.caps;
|
int num_res = (int)w->resvals.caps;
|
||||||
w->host_eval_ctx = build_host_eval_ctx(w, num_res);
|
w->host_eval_ctx = build_host_eval_ctx(w, num_res);
|
||||||
if (w->host_eval_ctx == NULL) {
|
if (w->host_eval_ctx == NULL) {
|
||||||
/* OOM: conservatively pass host */
|
/* OOM: conservatively pass host */
|
||||||
|
|
@ -216,7 +223,8 @@ int sched_meet_host_selection(xce_scheduler_t* sched, xce_sched_worker_t* w,
|
||||||
return (rc > 0) ? 1 : 0;
|
return (rc > 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fallback (no session context — e.g. unit tests or OOM at session start). */
|
/* Fallback (no session context — e.g. unit tests or OOM at session start).
|
||||||
|
*/
|
||||||
int rc = eval_select_simple(s->root, w->host_eval_ctx);
|
int rc = eval_select_simple(s->root, w->host_eval_ctx);
|
||||||
return (rc > 0) ? 1 : 0;
|
return (rc > 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +472,7 @@ static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
|
||||||
if (ctx->reason == NULL) {
|
if (ctx->reason == NULL) {
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_job_preason(ctx->reason->reasons, PREASON_MATCH_FAIL, w->name,
|
add_job_preason(ctx->reason->reasons, PREASON_MATCH_FAIL, w->name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
@ -496,18 +504,18 @@ static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
|
||||||
int i;
|
int i;
|
||||||
if (ctx)
|
if (ctx)
|
||||||
|
|
||||||
for (i = 0; i < ctx->unmeet.count; i++) {
|
for (i = 0; i < ctx->unmeet.count; i++) {
|
||||||
xce_resource_t* r = NULL;
|
xce_resource_t* r = NULL;
|
||||||
|
|
||||||
rc = vget(sched->resmgr, ((int*)ctx->unmeet.idxs.data)[i],
|
rc = vget(sched->resmgr, ((int*)ctx->unmeet.idxs.data)[i],
|
||||||
(void**)&r);
|
(void**)&r);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_job_preason(ctx->reason->reasons, PREASON_NO_RESOURCE,
|
||||||
|
w->name, r->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_job_preason(ctx->reason->reasons, PREASON_NO_RESOURCE, w->name,
|
|
||||||
r->name);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue