From 99cc5d63fada211672ef13210e432718f24027e4 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 6 Oct 2010 11:31:47 +0400 Subject: [PATCH] Implement transparent resource limiting I needed to limit the amount of virtual memory that is consumed by our tasks, but can't really use resources_max/resources_default, since scheduler will see these parameters and will try to match the nodes basing on such specifications. That's not desirable: when I need to limit vmem to, say, 2gb, I just want the programs not to exceed this limit, but I don't really want to allocate only nodes with the 2gb of free virtual memory per slot (and at least Maui will do this if I will use resources_max/resources_default). I had also unified mom_do_poll across all arch-specific modules, since this routine does the same thing and only the names of resources for which we will enable polling is different. So, generic_mom_do_poll() was introduced and all instances of mom_do_poll() now use this routine. Signed-off-by: Eygene Ryabinkin I am also not very much sure about pjob->ji_wattr vs ji_wattr when 'at_action' handler is spawned inside set_resc_deflt(), but I will leave the final decision for more knowledgeable people. --- src/include/mom_func.h | 3 + src/include/pbs_ifl.h | 1 + src/include/pbs_job.h | 2 + src/include/qmgr_que_public.h | 1 + src/include/qmgr_svr_public.h | 1 + src/include/queue.h | 2 + src/include/server.h | 1 + src/resmom/aix4/mom_mach.c | 34 ++------------ src/resmom/aix4/mom_mach.h | 2 +- src/resmom/aix5/mom_mach.c | 34 ++------------ src/resmom/aix5/mom_mach.h | 2 +- src/resmom/cygwin/mom_mach.c | 41 +++-------------- src/resmom/cygwin/mom_mach.h | 2 +- src/resmom/darwin/mom_mach.c | 39 ++-------------- src/resmom/darwin/mom_mach.h | 2 +- src/resmom/digitalunix/mom_mach.c | 34 ++------------ src/resmom/digitalunix/mom_mach.h | 2 +- src/resmom/freebsd/mom_mach.c | 34 ++------------ src/resmom/freebsd/mom_mach.h | 2 +- src/resmom/freebsd5/mom_mach.c | 34 ++------------ src/resmom/freebsd5/mom_mach.h | 2 +- src/resmom/fujitsu/mom_mach.c | 34 ++------------ src/resmom/fujitsu/mom_mach.h | 2 +- src/resmom/hpux10/mom_mach.c | 34 ++------------ src/resmom/hpux10/mom_mach.h | 2 +- src/resmom/hpux11/mom_mach.c | 34 ++------------ src/resmom/hpux11/mom_mach.h | 2 +- src/resmom/irix5/mom_mach.c | 36 ++------------- src/resmom/irix5/mom_mach.h | 2 +- src/resmom/irix6/mom_mach.c | 37 ++------------- src/resmom/irix6/mom_mach.h | 2 +- src/resmom/irix6array/mom_mach.c | 38 ++------------- src/resmom/irix6array/mom_mach.h | 2 +- src/resmom/job_func.c | 60 ++++++++++++++++++++++++ src/resmom/linux/mom_mach.c | 41 +++-------------- src/resmom/linux/mom_mach.h | 2 +- src/resmom/mom_main.c | 3 +- src/resmom/netbsd/mom_mach.c | 34 ++------------ src/resmom/netbsd/mom_mach.h | 2 +- src/resmom/solaris5/mom_mach.c | 34 ++------------ src/resmom/solaris5/mom_mach.h | 2 +- src/resmom/solaris7/mom_mach.c | 34 ++------------ src/resmom/solaris7/mom_mach.h | 2 +- src/resmom/sunos4/mom_mach.c | 34 ++------------ src/resmom/sunos4/mom_mach.h | 2 +- src/resmom/unicos8/mom_mach.c | 32 ++----------- src/resmom/unicos8/mom_mach.h | 2 +- src/resmom/unicosmk2/mom_mach.c | 30 ++----------- src/resmom/unicosmk2/mom_mach.h | 2 +- src/server/job_attr_def.c | 12 +++++ src/server/queue_attr_def.c | 12 +++++ src/server/svr_attr_def.c | 12 +++++ src/server/svr_jobfunc.c | 90 +++++++++++++++++++++++++++++++++--- 53 files changed, 299 insertions(+), 643 deletions(-) diff --git a/src/include/mom_func.h b/src/include/mom_func.h index de48a88..6b127ba 100644 --- a/src/include/mom_func.h +++ b/src/include/mom_func.h @@ -188,6 +188,9 @@ extern int mom_open_socket_to_jobs_server(job* pjob, char *id, void (*message_ /* defined in mach-dependant mom_mach.c */ extern int kill_task(struct task *, int, int); +/* helpers for mach-dependent MOM parts */ +extern int generic_mom_do_poll(job *pjob, ...); + /* Defines for pe_io_type, see run_pelog() */ #define PE_IO_TYPE_NULL -1 diff --git a/src/include/pbs_ifl.h b/src/include/pbs_ifl.h index c7281a7..5fe0c81 100644 --- a/src/include/pbs_ifl.h +++ b/src/include/pbs_ifl.h @@ -190,6 +190,7 @@ #define ATTR_rescdflt "resources_default" #define ATTR_rescmax "resources_max" #define ATTR_rescmin "resources_min" +#define ATTR_resclimit "resource_limits" #define ATTR_rerunnable "restartable" /* TORQUE only */ #define ATTR_rndzretry "rendezvous_retry" #define ATTR_routedest "route_destinations" diff --git a/src/include/pbs_job.h b/src/include/pbs_job.h index 4d1e9c7..8eb9d82 100644 --- a/src/include/pbs_job.h +++ b/src/include/pbs_job.h @@ -331,6 +331,7 @@ enum job_atr #ifdef USEJOBCREATE JOB_ATR_pagg_id, #endif /* USEJOBCREATE */ + JOB_ATR_reslimits, #include "site_job_attr_enum.h" JOB_ATR_UNKN, /* the special "unknown" type */ @@ -915,6 +916,7 @@ extern int svr_enquejob(job *); extern void svr_evaljobstate(job *, int *, int *, int); extern void svr_mailowner(job *, int, int, char *); extern void set_resc_deflt(job *, attribute *); +extern void set_resc_limits(job *, attribute *); extern void set_statechar(job *); extern int svr_setjobstate(job *, int, int); diff --git a/src/include/qmgr_que_public.h b/src/include/qmgr_que_public.h index 4aeb8e2..7998dfe 100644 --- a/src/include/qmgr_que_public.h +++ b/src/include/qmgr_que_public.h @@ -113,6 +113,7 @@ ATTR_rescavail, ATTR_rescdflt, ATTR_rescmax, ATTR_rescmin, +ATTR_resclimit, ATTR_rerunnable, ATTR_rndzretry, ATTR_routedest, diff --git a/src/include/qmgr_svr_public.h b/src/include/qmgr_svr_public.h index fd4842b..3b746b5 100644 --- a/src/include/qmgr_svr_public.h +++ b/src/include/qmgr_svr_public.h @@ -114,6 +114,7 @@ ATTR_rescavail, ATTR_resccost, ATTR_rescdflt, ATTR_rescmax, +ATTR_resclimit, ATTR_schedit, ATTR_scheduling, ATTR_syscost, diff --git a/src/include/queue.h b/src/include/queue.h index 747bf10..4eabf42 100644 --- a/src/include/queue.h +++ b/src/include/queue.h @@ -148,6 +148,8 @@ enum queueattr QR_ATR_RouteRetryTime, QR_ATR_RouteLifeTime, + QA_ATR_ResourceLimits, + #include "site_que_attr_enum.h" QA_ATR_Enabled, /* these are last for qmgr print function */ QA_ATR_Started, diff --git a/src/include/server.h b/src/include/server.h index efd163e..092f689 100644 --- a/src/include/server.h +++ b/src/include/server.h @@ -177,6 +177,7 @@ enum srv_atr SRV_ATR_JobForceCancelTime, SRV_ATR_MaxArraySize, SRV_ATR_MaxSlotLimit, + SRV_ATR_ResourceLimits, #include "site_svr_attr_enum.h" /* This must be last */ SRV_ATR_LAST diff --git a/src/resmom/aix4/mom_mach.c b/src/resmom/aix4/mom_mach.c index 69fe55a..3409f3d 100644 --- a/src/resmom/aix4/mom_mach.c +++ b/src/resmom/aix4/mom_mach.c @@ -1006,33 +1006,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } /* @@ -1412,7 +1386,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -1421,7 +1395,7 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); DBPRT(("%s: entered\n", id)) @@ -1433,7 +1407,7 @@ mom_over_limit(job *pjob) #endif /* IBM_SP2 */ pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); for (; pres != NULL; pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/aix4/mom_mach.h b/src/resmom/aix4/mom_mach.h index c7c3819..43a8b0d 100644 --- a/src/resmom/aix4/mom_mach.h +++ b/src/resmom/aix4/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/aix5/mom_mach.c b/src/resmom/aix5/mom_mach.c index 212b61b..562efee 100644 --- a/src/resmom/aix5/mom_mach.c +++ b/src/resmom/aix5/mom_mach.c @@ -1010,33 +1010,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } /* @@ -1380,7 +1354,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -1389,7 +1363,7 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); DBPRT(("%s: entered\n", id)) @@ -1401,7 +1375,7 @@ mom_over_limit(job *pjob) #endif /* IBM_SP2 */ pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); for (; pres != NULL; pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/aix5/mom_mach.h b/src/resmom/aix5/mom_mach.h index 5f3ca14..9738f74 100644 --- a/src/resmom/aix5/mom_mach.h +++ b/src/resmom/aix5/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/cygwin/mom_mach.c b/src/resmom/cygwin/mom_mach.c index 3c93441..c897861 100644 --- a/src/resmom/cygwin/mom_mach.c +++ b/src/resmom/cygwin/mom_mach.c @@ -1408,9 +1408,6 @@ int mom_do_poll( job *pjob) /* I */ { - char *pname; - resource *pres; - assert(pjob != NULL); if (LOGLEVEL >= 4) @@ -1422,35 +1419,8 @@ int mom_do_poll( "evaluating limits for job"); } - assert(pjob != NULL); - - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - - pres = (resource *)GET_NEXT( - pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - - pname = pres->rs_defin->rs_name; - - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - { - return(TRUE); - } - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return(FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", + "pvmem", "vmem", NULL); } /* END mom_do_poll() */ @@ -1615,7 +1585,8 @@ mom_get_sample(void) int mom_over_limit( - job *pjob) /* I */ + job *pjob, /* I */ + enum job_atr attr) /* I */ { char *pname; @@ -1627,10 +1598,10 @@ int mom_over_limit( resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *)GET_NEXT( - pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + pjob->ji_wattr[(int)attr].at_val.at_list); for (;pres != NULL;pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/cygwin/mom_mach.h b/src/resmom/cygwin/mom_mach.h index b51e4ab..88a6b0a 100644 --- a/src/resmom/cygwin/mom_mach.h +++ b/src/resmom/cygwin/mom_mach.h @@ -117,7 +117,7 @@ extern int mom_do_poll (job *); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll (); /* Initialize poll ability */ extern int mom_get_sample (); /* Sample kernel poll data */ -extern int mom_over_limit (job *); /* Is polled job over limit? */ +extern int mom_over_limit (job *, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use (job *); /* Set resource_used list */ extern int mom_kill (int, int); /* Kill a session */ extern int mom_close_poll (); /* Terminate poll ability */ diff --git a/src/resmom/darwin/mom_mach.c b/src/resmom/darwin/mom_mach.c index d82b823..8825023 100644 --- a/src/resmom/darwin/mom_mach.c +++ b/src/resmom/darwin/mom_mach.c @@ -909,37 +909,7 @@ int mom_do_poll( job *pjob) { -#ifndef NDEBUG - char *id = "mom_do_poll"; -#endif - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - { - return (TRUE); - } - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return(FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } @@ -1170,7 +1140,8 @@ mom_get_sample(void) int mom_over_limit( - job *pjob) + job *pjob, + enum job_atr attr) { #ifndef NDEBUG @@ -1182,9 +1153,9 @@ int mom_over_limit( resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); - pres = (resource *)GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + pres = (resource *)GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/darwin/mom_mach.h b/src/resmom/darwin/mom_mach.h index 750b353..b7a1fe6 100644 --- a/src/resmom/darwin/mom_mach.h +++ b/src/resmom/darwin/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/digitalunix/mom_mach.c b/src/resmom/digitalunix/mom_mach.c index 140820c..00903f3 100644 --- a/src/resmom/digitalunix/mom_mach.c +++ b/src/resmom/digitalunix/mom_mach.c @@ -725,33 +725,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "vmem", NULL); } /* @@ -863,7 +837,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -872,9 +846,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/digitalunix/mom_mach.h b/src/resmom/digitalunix/mom_mach.h index bbfde52..5383d98 100644 --- a/src/resmom/digitalunix/mom_mach.h +++ b/src/resmom/digitalunix/mom_mach.h @@ -103,7 +103,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/freebsd/mom_mach.c b/src/resmom/freebsd/mom_mach.c index a0eb26f..dab4eb5 100644 --- a/src/resmom/freebsd/mom_mach.c +++ b/src/resmom/freebsd/mom_mach.c @@ -790,33 +790,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } /* @@ -960,7 +934,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -969,9 +943,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/freebsd/mom_mach.h b/src/resmom/freebsd/mom_mach.h index d0ad6c0..0a4a6a9 100644 --- a/src/resmom/freebsd/mom_mach.h +++ b/src/resmom/freebsd/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/freebsd5/mom_mach.c b/src/resmom/freebsd5/mom_mach.c index c450c25..fdb6b6c 100644 --- a/src/resmom/freebsd5/mom_mach.c +++ b/src/resmom/freebsd5/mom_mach.c @@ -762,33 +762,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } /* @@ -899,7 +873,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -908,9 +882,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/freebsd5/mom_mach.h b/src/resmom/freebsd5/mom_mach.h index 1cbc3c9..353ba66 100644 --- a/src/resmom/freebsd5/mom_mach.h +++ b/src/resmom/freebsd5/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/fujitsu/mom_mach.c b/src/resmom/fujitsu/mom_mach.c index e5d5ff1..f430849 100644 --- a/src/resmom/fujitsu/mom_mach.c +++ b/src/resmom/fujitsu/mom_mach.c @@ -760,33 +760,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "vmem", NULL); } /* @@ -898,7 +872,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -907,9 +881,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/fujitsu/mom_mach.h b/src/resmom/fujitsu/mom_mach.h index 2ffeb9f..bf23e88 100644 --- a/src/resmom/fujitsu/mom_mach.h +++ b/src/resmom/fujitsu/mom_mach.h @@ -103,7 +103,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/hpux10/mom_mach.c b/src/resmom/hpux10/mom_mach.c index e836396..3b686c6 100644 --- a/src/resmom/hpux10/mom_mach.c +++ b/src/resmom/hpux10/mom_mach.c @@ -684,33 +684,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "vmem", NULL); } /* @@ -780,7 +754,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -789,9 +763,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/hpux10/mom_mach.h b/src/resmom/hpux10/mom_mach.h index de7fb00..dd0bc75 100644 --- a/src/resmom/hpux10/mom_mach.h +++ b/src/resmom/hpux10/mom_mach.h @@ -103,7 +103,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/hpux11/mom_mach.c b/src/resmom/hpux11/mom_mach.c index 71acb08..9d63e4d 100644 --- a/src/resmom/hpux11/mom_mach.c +++ b/src/resmom/hpux11/mom_mach.c @@ -730,33 +730,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "vmem", NULL); } /* @@ -844,7 +818,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -854,9 +828,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) usedcput = cput_sum(pjob); diff --git a/src/resmom/hpux11/mom_mach.h b/src/resmom/hpux11/mom_mach.h index 6026d44..b020d13 100644 --- a/src/resmom/hpux11/mom_mach.h +++ b/src/resmom/hpux11/mom_mach.h @@ -103,7 +103,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/irix5/mom_mach.c b/src/resmom/irix5/mom_mach.c index 47380dd..83a8a1b 100644 --- a/src/resmom/irix5/mom_mach.c +++ b/src/resmom/irix5/mom_mach.c @@ -921,34 +921,8 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "pvmem", + "vmem", NULL); } /* @@ -988,7 +962,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -997,9 +971,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); for (; pres != NULL; pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/irix5/mom_mach.h b/src/resmom/irix5/mom_mach.h index f103568..6e213f1 100644 --- a/src/resmom/irix5/mom_mach.h +++ b/src/resmom/irix5/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/irix6/mom_mach.c b/src/resmom/irix6/mom_mach.c index e00078f..08f4d43 100644 --- a/src/resmom/irix6/mom_mach.c +++ b/src/resmom/irix6/mom_mach.c @@ -936,35 +936,8 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "ncpus") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "ncpus", "cput", "pcput", + "pvmem", "vmem", NULL); } /* @@ -1118,7 +1091,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *pname; int retval; @@ -1128,9 +1101,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); for (; pres != NULL; pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/irix6/mom_mach.h b/src/resmom/irix6/mom_mach.h index d4ce11d..2ad6ee1 100644 --- a/src/resmom/irix6/mom_mach.h +++ b/src/resmom/irix6/mom_mach.h @@ -106,7 +106,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/irix6array/mom_mach.c b/src/resmom/irix6array/mom_mach.c index e5faf14..f490c0a 100644 --- a/src/resmom/irix6array/mom_mach.c +++ b/src/resmom/irix6array/mom_mach.c @@ -950,36 +950,8 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "mem") == 0 || - strcmp(pname, "ncpus") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "mem", "ncpus", + "cput", "pcput", "pvmem", "vmem", NULL); } /* @@ -1178,7 +1150,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *pname; int retval; @@ -1188,9 +1160,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); for (; pres != NULL; pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/irix6array/mom_mach.h b/src/resmom/irix6array/mom_mach.h index bd7a401..b20042f 100644 --- a/src/resmom/irix6array/mom_mach.h +++ b/src/resmom/irix6array/mom_mach.h @@ -106,7 +106,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/job_func.c b/src/resmom/job_func.c index 2116855..311712f 100644 --- a/src/resmom/job_func.c +++ b/src/resmom/job_func.c @@ -92,6 +92,9 @@ * * job_unlink_file() unlinks a given file using job credentials * + * generic_mom_do_poll() provides generic function for + * machine-dependent MOM components. + * * Include private function: * job_init_wattr() initialize job working attribute array to "unspecified" */ @@ -116,6 +119,7 @@ #include #include #include +#include #include #include #include @@ -820,5 +824,61 @@ job *find_job( return(pj); /* may be NULL */ } /* END find_job() */ + +/* + * State whether MOM main loop has to poll this job to determine if some + * limits are being exceeded. + * + * Returns TRUE if polling is necessary, FALSE otherwise. Actual + * polling is done using the mom_over_limit machine-dependent function. + * + * The set of variable arguments should be NULL-terminated list of + * strings that name resources we will be able to extract from the + * polling loop (on the given platform). + */ + +int +generic_mom_do_poll(job *pjob, ...) + { + char *id = "generic_mom_do_poll"; + char *pname, *argname; + resource *pres; + enum job_atr check_attrs[] = {JOB_ATR_resource, JOB_ATR_reslimits}; + size_t i; + va_list ap; + + DBPRT(("%s: entered\n", id)) + assert(pjob != NULL); + for (i = 0; i < sizeof(check_attrs)/sizeof(check_attrs[0]); i++) + { + assert(pjob->ji_wattr[(int)check_attrs[i]].at_type == ATR_TYPE_RESC); + pres = (resource *) + GET_NEXT(pjob->ji_wattr[(int)check_attrs[i]].at_val.at_list); + + while (pres != NULL) + { + assert(pres->rs_defin != NULL); + pname = pres->rs_defin->rs_name; + assert(pname != NULL); + assert(*pname != '\0'); + + va_start(ap, pjob); + while ((argname = va_arg(ap, char *)) != NULL) + { + if (strcmp(pname, argname) == 0) + { + va_end(ap); + return TRUE; + } + } + va_end(ap); + + pres = (resource *)GET_NEXT(pres->rs_link); + } + } + + return (FALSE); + } + /* END job_func.c */ diff --git a/src/resmom/linux/mom_mach.c b/src/resmom/linux/mom_mach.c index ee4736f..d0f93d3 100644 --- a/src/resmom/linux/mom_mach.c +++ b/src/resmom/linux/mom_mach.c @@ -1572,9 +1572,6 @@ int mom_do_poll( job *pjob) /* I */ { - char *pname; - resource *pres; - assert(pjob != NULL); if (LOGLEVEL >= 4) @@ -1586,35 +1583,8 @@ int mom_do_poll( "evaluating limits for job"); } - assert(pjob != NULL); - - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - - pres = (resource *)GET_NEXT( - pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - - pname = pres->rs_defin->rs_name; - - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - { - return(TRUE); - } - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return(FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", + "pvmem", "vmem", NULL); } /* END mom_do_poll() */ @@ -1779,7 +1749,8 @@ mom_get_sample(void) int mom_over_limit( - job *pjob) /* I */ + job *pjob, /* I */ + enum job_atr attr) /* I */ { char *pname; @@ -1791,10 +1762,10 @@ int mom_over_limit( resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *)GET_NEXT( - pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + pjob->ji_wattr[(int)attr].at_val.at_list); for (;pres != NULL;pres = (resource *)GET_NEXT(pres->rs_link)) { diff --git a/src/resmom/linux/mom_mach.h b/src/resmom/linux/mom_mach.h index 9256959..f5bed56 100644 --- a/src/resmom/linux/mom_mach.h +++ b/src/resmom/linux/mom_mach.h @@ -123,7 +123,7 @@ extern int mom_do_poll(job *); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *); /* Is polled job over limit? */ +extern int mom_over_limit(job *, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *); /* Set resource_used list */ extern int mom_kill(int, int); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/mom_main.c b/src/resmom/mom_main.c index 16bf98a..b9f8f6e 100644 --- a/src/resmom/mom_main.c +++ b/src/resmom/mom_main.c @@ -5892,7 +5892,8 @@ int job_over_limit( unsigned long limit; char *units; - if (mom_over_limit(pjob)) + if (mom_over_limit(pjob, JOB_ATR_resource) || + mom_over_limit(pjob, JOB_ATR_reslimits)) { /* mom limits violated, log_buffer populated */ diff --git a/src/resmom/netbsd/mom_mach.c b/src/resmom/netbsd/mom_mach.c index 69ca8ba..2ca8221 100644 --- a/src/resmom/netbsd/mom_mach.c +++ b/src/resmom/netbsd/mom_mach.c @@ -737,33 +737,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } /* @@ -900,7 +874,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -909,9 +883,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/netbsd/mom_mach.h b/src/resmom/netbsd/mom_mach.h index f73091e..1a82189 100644 --- a/src/resmom/netbsd/mom_mach.h +++ b/src/resmom/netbsd/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/solaris5/mom_mach.c b/src/resmom/solaris5/mom_mach.c index 7a09b5d..58ca3e4 100644 --- a/src/resmom/solaris5/mom_mach.c +++ b/src/resmom/solaris5/mom_mach.c @@ -720,33 +720,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "vmem", NULL); } /* @@ -858,7 +832,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -867,9 +841,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/solaris5/mom_mach.h b/src/resmom/solaris5/mom_mach.h index bca5ff0..0176701 100644 --- a/src/resmom/solaris5/mom_mach.h +++ b/src/resmom/solaris5/mom_mach.h @@ -103,7 +103,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mach_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/solaris7/mom_mach.c b/src/resmom/solaris7/mom_mach.c index 0108908..9c87de5 100644 --- a/src/resmom/solaris7/mom_mach.c +++ b/src/resmom/solaris7/mom_mach.c @@ -727,33 +727,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pcput") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pcput", "vmem", NULL); } /* @@ -842,7 +816,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -851,9 +825,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/solaris7/mom_mach.h b/src/resmom/solaris7/mom_mach.h index e87379c..7b049f9 100644 --- a/src/resmom/solaris7/mom_mach.h +++ b/src/resmom/solaris7/mom_mach.h @@ -117,7 +117,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mach_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/sunos4/mom_mach.c b/src/resmom/sunos4/mom_mach.c index a1715f3..ef6e2f1 100644 --- a/src/resmom/sunos4/mom_mach.c +++ b/src/resmom/sunos4/mom_mach.c @@ -760,33 +760,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0 || - strcmp(pname, "cput") == 0 || - strcmp(pname, "pvmem") == 0 || - strcmp(pname, "vmem") == 0) - return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", "cput", "pvmem", "vmem", NULL); } /* @@ -946,7 +920,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { char *id = "mom_over_limit"; char *pname; @@ -955,9 +929,9 @@ mom_over_limit(job *pjob) resource *pres; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered\n", id)) diff --git a/src/resmom/sunos4/mom_mach.h b/src/resmom/sunos4/mom_mach.h index 1460406..7c0ddcf 100644 --- a/src/resmom/sunos4/mom_mach.h +++ b/src/resmom/sunos4/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/unicos8/mom_mach.c b/src/resmom/unicos8/mom_mach.c index 36b48e2..5f3a376 100644 --- a/src/resmom/unicos8/mom_mach.c +++ b/src/resmom/unicos8/mom_mach.c @@ -1817,31 +1817,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - static char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "ncpus") == 0) return (TRUE); - - if (strcmp(pname, "walltime") == 0) return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "ncpus", "walltime", NULL); } /* @@ -1982,7 +1958,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { static char *id = "mom_over_limit"; char *pname; @@ -1992,9 +1968,9 @@ mom_over_limit(job *pjob) int num; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) diff --git a/src/resmom/unicos8/mom_mach.h b/src/resmom/unicos8/mom_mach.h index 3e2975f..220e09c 100644 --- a/src/resmom/unicos8/mom_mach.h +++ b/src/resmom/unicos8/mom_mach.h @@ -106,7 +106,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/resmom/unicosmk2/mom_mach.c b/src/resmom/unicosmk2/mom_mach.c index cd09c1a..b4f2e23 100644 --- a/src/resmom/unicosmk2/mom_mach.c +++ b/src/resmom/unicosmk2/mom_mach.c @@ -1131,29 +1131,7 @@ mom_set_limits( int mom_do_poll(job *pjob) { - static char *id = "mom_do_poll"; - char *pname; - resource *pres; - - DBPRT(("%s: entered\n", id)) - assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); - pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); - - while (pres != NULL) - { - assert(pres->rs_defin != NULL); - pname = pres->rs_defin->rs_name; - assert(pname != NULL); - assert(*pname != '\0'); - - if (strcmp(pname, "walltime") == 0) return (TRUE); - - pres = (resource *)GET_NEXT(pres->rs_link); - } - - return (FALSE); + return generic_mom_do_poll(pjob, "walltime", NULL); } /* @@ -1192,7 +1170,7 @@ mom_get_sample(void) */ int -mom_over_limit(job *pjob) +mom_over_limit(job *pjob, enum job_atr attr) { static char *id = "mom_over_limit"; char *pname; @@ -1202,9 +1180,9 @@ mom_over_limit(job *pjob) int num; assert(pjob != NULL); - assert(pjob->ji_wattr[(int)JOB_ATR_resource].at_type == ATR_TYPE_RESC); + assert(pjob->ji_wattr[(int)attr].at_type == ATR_TYPE_RESC); pres = (resource *) - GET_NEXT(pjob->ji_wattr[(int)JOB_ATR_resource].at_val.at_list); + GET_NEXT(pjob->ji_wattr[(int)attr].at_val.at_list); DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) diff --git a/src/resmom/unicosmk2/mom_mach.h b/src/resmom/unicosmk2/mom_mach.h index 3bd00b8..e1e7b7c 100644 --- a/src/resmom/unicosmk2/mom_mach.h +++ b/src/resmom/unicosmk2/mom_mach.h @@ -105,7 +105,7 @@ extern int mom_do_poll(job *pjob); /* Should limits be polled? */ extern int mom_does_checkpoint(); /* see if mom does checkpoint */ extern int mom_open_poll(); /* Initialize poll ability */ extern int mom_get_sample(); /* Sample kernel poll data */ -extern int mom_over_limit(job *pjob); /* Is polled job over limit? */ +extern int mom_over_limit(job *pjob, enum job_atr); /* Is polled job over limit? */ extern int mom_set_use(job *pjob); /* Set resource_used list */ extern int mom_kill(int sid, int sig); /* Kill a session */ extern int mom_close_poll(); /* Terminate poll ability */ diff --git a/src/server/job_attr_def.c b/src/server/job_attr_def.c index 40fdec3..c0e36c0 100644 --- a/src/server/job_attr_def.c +++ b/src/server/job_attr_def.c @@ -931,6 +931,18 @@ attribute_def job_attr_def[] = { PARENT_TYPE_JOB}, #endif /* USEJOBCREATE */ + /* JOB_ATR_reslimits */ + {ATTR_resclimit, /* "resource_limits" - enforced resource limits */ + decode_str, + encode_str, + set_str, + comp_str, + free_str, + NULL_FUNC, + ATR_DFLAG_Creat | ATR_DFLAG_MGRD | ATR_DFLAG_USRD | ATR_DFLAG_OPRD, + ATR_TYPE_STR, + PARENT_TYPE_JOB}, + /* Site defined attributes if any, see site_job_attr_*.h */ #include "site_job_attr_def.h" diff --git a/src/server/queue_attr_def.c b/src/server/queue_attr_def.c index b7a26b8..eb8e6a7 100644 --- a/src/server/queue_attr_def.c +++ b/src/server/queue_attr_def.c @@ -659,6 +659,18 @@ attribute_def que_attr_def[] = { ATR_TYPE_LONG, PARENT_TYPE_QUE_RTE}, + /* QA_ATR_ResourceLimits */ + {ATTR_resclimit, /* "resource_limits" */ + decode_resc, + encode_resc, + set_resc, + comp_resc, + free_resc, + NULL_FUNC, + NO_USER_SET, + ATR_TYPE_RESC, + PARENT_TYPE_QUE_ALL}, + /* site supplied attribute definitions, if any, see site_que_attr_*.h */ #include "site_que_attr_def.h" diff --git a/src/server/svr_attr_def.c b/src/server/svr_attr_def.c index 261bb4a..5c6108d 100644 --- a/src/server/svr_attr_def.c +++ b/src/server/svr_attr_def.c @@ -1076,6 +1076,18 @@ attribute_def svr_attr_def[] = { ATR_TYPE_LONG, PARENT_TYPE_SERVER}, + /* SRV_ATR_ResourceLimits */ + {ATTR_resclimit, /* "resource_limits" */ + decode_resc, + encode_resc, + set_resc, + comp_resc, + free_resc, + NULL_FUNC, + NO_USER_SET, + ATR_TYPE_RESC, + PARENT_TYPE_SERVER}, + /* site supplied server attribute definitions if any, see site_svr_attr_*.h */ #include "site_svr_attr_def.h" diff --git a/src/server/svr_jobfunc.c b/src/server/svr_jobfunc.c index b456699..00bdeac 100644 --- a/src/server/svr_jobfunc.c +++ b/src/server/svr_jobfunc.c @@ -91,6 +91,7 @@ * prefix_std_file() - build the fully prefixed default name for std e/o * get_jobowner() - get job owner name without @host suffix * set_resc_deflt() - set unspecified resource_limit to default values + * set_resc_limits() - set queue/server resource limits * set_statechar() - set the job state attribute character value * * Private functions @@ -480,6 +481,7 @@ int svr_enquejob( */ set_resc_deflt(pjob, NULL); + set_resc_limits(pjob, NULL); /* * set any "unspecified" checkpoint with queue default values, if any @@ -560,6 +562,8 @@ void svr_dequejob( attribute *pattr; pbs_queue *pque; resource *presc; + enum job_atr res_clear[] = {JOB_ATR_resource, JOB_ATR_reslimits}; + size_t i; /* remove job from server's all job list and reduce server counts */ @@ -624,18 +628,21 @@ void svr_dequejob( /* clear any default resource values. */ - pattr = &pjob->ji_wattr[JOB_ATR_resource]; - - if (pattr->at_flags & ATR_VFLAG_SET) + for (i = 0; i < sizeof(res_clear)/sizeof(res_clear[0]); i++) { - presc = (resource *)GET_NEXT(pattr->at_val.at_list); + pattr = &pjob->ji_wattr[res_clear[i]]; - while (presc != NULL) + if (pattr->at_flags & ATR_VFLAG_SET) { - if (presc->rs_value.at_flags & ATR_VFLAG_DEFLT) - presc->rs_defin->rs_free(&presc->rs_value); + presc = (resource *)GET_NEXT(pattr->at_val.at_list); + + while (presc != NULL) + { + if (presc->rs_value.at_flags & ATR_VFLAG_DEFLT) + presc->rs_defin->rs_free(&presc->rs_value); - presc = (resource *)GET_NEXT(presc->rs_link); + presc = (resource *)GET_NEXT(presc->rs_link); + } } } @@ -2298,6 +2305,7 @@ void get_jobowner( /** * @see set_resc_deflt() - parent + * @see set_resc_limits() - parent * * @param jb * @param *dflt @@ -2417,6 +2425,7 @@ void set_resc_deflt( { pdef = &job_attr_def[i]; + /* XXX: do we really want pjob->ji_wattr if ji_wattr is not NULL? */ if ((pjob->ji_wattr[i].at_flags & ATR_VFLAG_SET) && (pdef->at_action)) { if ((rc = pdef->at_action(&pjob->ji_wattr[i], pjob, ATR_ACTION_NEW)) != 0) @@ -2434,6 +2443,71 @@ void set_resc_deflt( + + +/** + * Set job limits + * + * @see svr_enquejob() - parent + * @see set_deflt_resc() - child + * + * @param pjob (I) [modified] + * @param ji_wattr + * + * NOTE: if ji_wattr parameter is passed in, update it instead of pjob + */ + +void set_resc_limits( + + job *pjob, /* I (modified) */ + attribute *ji_wattr) /* I (optional) decoded attributes */ + + { + attribute *ja; + + pbs_queue *pque; + attribute_def *pdef; + int i, rc; + + pque = pjob->ji_qhdr; + + assert(pque != NULL); + + if (ji_wattr == NULL) + ji_wattr = pjob->ji_wattr; + + ja = &ji_wattr[JOB_ATR_reslimits]; + + /* apply queue defaults first since they take precedence */ + + set_limits_resc(ja, &pque->qu_attr[QA_ATR_ResourceLimits]); + + /* server defaults will only be applied to attributes which have + not yet been set */ + + set_limits_resc(ja, &server.sv_attr[SRV_ATR_ResourceLimits]); + + for (i = 0;i < JOB_ATR_LAST;++i) + { + pdef = &job_attr_def[i]; + + if ((ji_wattr[i].at_flags & ATR_VFLAG_SET) && (pdef->at_action)) + { + if ((rc = pdef->at_action(&ji_wattr[i], pjob, ATR_ACTION_NEW)) != 0) + { + /* FIXME: return an actual error */ + + return; + } + } + } + + return; + } /* END set_resc_deflt() */ + + + + /** * Set job defaults * -- 1.7.2.1