📄 mom_mach.c
字号:
DBPRT(("Memory bank busy time in clocks = %ld\n", tinfo.mc_bbsy)) DBPRT(("Number of clock ticks per second = %ld\n", tinfo.mc_clktck)) DBPRT(("System serial number = %ld\n", tinfo.mc_serial)) DBPRT(("UNICOS release level = %ld\n", tinfo.mc_rls))#if SRFS var_init();#endif end_proc(); return;}voiddep_cleanup(){ char *id = "dep_cleanup"; int i; log_record(PBSEVENT_SYSTEM, 0, id, "dependent cleanup");#if SRFS var_cleanup();#endif}/* * Internal size decoding routine. * * Accepts a resource pointer and a pointer to the unsigned long integer * to receive the decoded value. It returns a PBS error code, and the * decoded value in the unsigned long integer. * * For Unicos, * * sizeof(word) = sizeof(int) */static int getsize(pres, ret) resource *pres; unsigned long *ret;{ unsigned long value; if (pres->rs_value.at_type != ATR_TYPE_SIZE) return (PBSE_ATTRTYPE); value = pres->rs_value.at_val.at_size.atsv_num; if (pres->rs_value.at_val.at_size.atsv_units == ATR_SV_WORDSZ) { if (value > ULONG_MAX / sizeof(int)) return (PBSE_BADATVAL); value *= sizeof(int); } if (value > ULONG_MAX >> pres->rs_value.at_val.at_size.atsv_shift) return (PBSE_BADATVAL); *ret = value << pres->rs_value.at_val.at_size.atsv_shift; return (PBSE_NONE);}/* * Internal time decoding routine. * * Accepts a resource pointer and a pointer to the unsigned long integer * to receive the decoded value. It returns a PBS error code, and the * decoded value of time in seconds in the unsigned long integer. */static int gettime(pres, ret) resource *pres; unsigned long *ret;{ if (pres->rs_value.at_type != ATR_TYPE_LONG) return (PBSE_ATTRTYPE); if (pres->rs_value.at_val.at_long < 0) return (PBSE_BADATVAL); *ret = pres->rs_value.at_val.at_long; return (PBSE_NONE);}/* * Internal long decoding routine. * * Accepts a resource pointer and a pointer to a long integer * to receive the decoded value. It returns a PBS error code, and the * decoded value of number in the long integer. */static int getlong(pres, ret) resource *pres; long *ret;{ if (pres->rs_value.at_type != ATR_TYPE_LONG) return (PBSE_ATTRTYPE); if (pres->rs_value.at_val.at_long < 0) return (PBSE_BADATVAL); *ret = pres->rs_value.at_val.at_long; return (PBSE_NONE);}/* * Internal boolean decoding routine. * * Accepts a resource pointer and a pointer to the unsigned integer * to receive the decoded value. It returns a PBS error code, and the * decoded value of true (1) or false (0). */static int getbool(pres, ret) resource *pres; unsigned int *ret;{ unsigned int val; if (pres->rs_value.at_type != ATR_TYPE_LONG) return (PBSE_ATTRTYPE); val = pres->rs_value.at_val.at_long; if (val != 0 && val != 1) return (PBSE_BADATVAL); *ret = val; return (PBSE_NONE);}staticintinjob(pjob, sesid) job *pjob; pid_t sesid;{ task *ptask; for (ptask = (task *)GET_NEXT(pjob->ji_tasks); ptask; ptask = (task *)GET_NEXT(ptask->ti_jobtask)) { if (ptask->ti_qs.ti_sid <= 1) continue; if (ptask->ti_qs.ti_sid == sesid) return TRUE; } return FALSE;}/* * Internal job cpu count decoding routine. * * Accepts a job pointer. Returns the sum of all "multi-task" * procs in a job. */static unsigned long cpus_sum(pjob) job *pjob;{ static char *id = "cpus_sum"; struct proc *pproc; int i; ulong cpus; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) cpus = 0; pproc = process_table; for (i = 0; i < process_table_size; i++, pproc++) { if ( pproc->p_stat == 0 ) continue; if ( !injob(pjob, pproc->p_pcomm.pc_sid) ) continue; if ( pproc->p_pcomm.pc_maxcnt <= 1 ) continue; cpus += pproc->p_pcomm.pc_maxcnt; DBPRT(("Session: %d, maxcnt = %d, tot = %d\n", pproc->p_pcomm.pc_sid, pproc->p_pcomm.pc_maxcnt, cpus)) } return (cpus);}/* * Internal job cpu time decoding routine. * * Accepts a job pointer. Returns the sum of all cpu time * consumed for all processes executed by the job, in seconds. */static unsigned long cput_sum(pjob) job *pjob;{ static char *id = "cput_sum"; struct sess *psess; int i; ulong cputime = 0; int nps = 0; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) psess = session_table; for (i = 0; i < session_table_size; i++, psess++) { if ( !injob(pjob, psess->s_sid) ) continue; nps++; cputime += (psess->s_ucputime + psess->s_scputime)/CLK_TCK; DBPRT(("Session: %d, cput = %d\n", psess->s_sid, cputime)) } if (nps == 0) pjob->ji_flags |= MOM_NO_PROC; return ((unsigned long)((double)cputime * cputfactor));}#define CLICKS 4096/* * Internal job memory decoding routine. * * Accepts a job pointer. Returns the sum of all memory * consumed for all processes executed by the job, in bytes. */static unsigned long mem_sum(pjob) job *pjob;{ static char *id = "mem_sum"; struct sess *psess; int i; ulong memsize = 0; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) psess = session_table; for (i = 0; i < session_table_size; psess++, i++) { if ( !injob(pjob, psess->s_sid) ) continue; memsize += ((psess->s_memhiwat) * CLICKS); DBPRT(("Session: %d, mem = %d\n", psess->s_sid, memsize)) } return (memsize);}#define BLOCKS 4096/* * Internal job file space decoding routine. * * Accepts a job pointer. Returns the sum of all file space * consumed for all processes executed by the job, in bytes. */static long pf_sum(pjob) job *pjob;{ static char *id = "pf_sum"; struct sess *psess; int i; long fsize = 0; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) psess = session_table; for (i = 0; i < session_table_size; psess++, i++) { if ( !injob(pjob, psess->s_sid) ) continue; fsize += ((psess->s_fsblkused) * BLOCKS); DBPRT(("Session: %d, pf = %d\n", psess->s_sid, fsize)) } return (fsize);}/* * Internal session SDS decoding routine. * * Accepts a job pointer. Returns the sum of all SDS * consumed for all processes executed by the job, in bytes. */static unsigned long sds_sum(pjob) job *pjob;{ static char *id = "sds_sum"; struct sess *psess; int i; ulong sdssize = 0; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) psess = session_table; for (i = 0; i < session_table_size; psess++, i++) { if ( !injob(pjob, psess->s_sid) ) continue; sdssize += ((psess->s_sdsuse) * CLICKS); DBPRT(("Session: %d, sds = %d\n", psess->s_sid, sdssize)) } return (sdssize);}#if SRFS/* * Internal session SRFS decoding routine. * * Accepts a job pointer and device num. Returns the max of all SRFS * consumed for the device for all processes executed by the session, * in bytes. */static unsigned long srfs_sum(pjob, dev) job *pjob; dev_t dev;{ static char *id = "srfs_sum"; struct sess *psess; int i; ulong srfssize; DBPRT(("%s: entered dev %d %s\n", id, dev, pjob->ji_qs.ji_jobid)) if (dev == -1) return 0; srfssize = 0; psess = session_table; for (i = 0; i < session_table_size; psess++, i++) { if ( !injob(pjob, psess->s_sid) ) continue; srfssize += ((psess->s_srfs[dev].hiwater) * BLOCKS); DBPRT(("Session: %d, sds = %d\n", psess->s_sid, srfssize)) } return (srfssize);}static intsrfs_error(mes1, mes2) char *mes1, *mes2;{ char buf[512]; sprintf(buf, "%s (%s) errno=%d", mes1, mes2, errno); log_err(errno, mes1, mes2); return (error(buf, PBSE_RESCUNAV));}#endif /* SRFS *//* * Internal session procs decoding routine. * * Accepts a job pointer id. Returns the number of processes * active for the job. */static unsigned long proc_cnt(pjob) job *pjob;{ static char *id = "proc_cnt"; struct sess *psess; int i; ulong nprocs = 0; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) psess = session_table; for (i = 0; i < session_table_size; psess++, i++) { if ( !injob(pjob, psess->s_sid) ) continue; nprocs += psess->s_nprocs; DBPRT(("Session: %d, nprocs = %d\n", psess->s_sid, nprocs)) } return (nprocs);}/* * Internal session mpp time decoding routine. * * Accepts a session id. Returns the sum of all moo time * consumed for all processes executed by the session, in seconds. */static unsigned long mppt_sum(pjob) job *pjob;{ static char *id = "mppt_ses"; struct sess *psess; int i; ulong mpptime = 0; DBPRT(("%s: entered %s\n", id, pjob->ji_qs.ji_jobid)) psess = session_table; for (i = 0; i < session_table_size; psess++, i++) { if ( !injob(pjob, psess->s_sid) ) continue; mpptime += psess->s_mpptimeused; DBPRT(("Session: %d, mppt = %d\n", psess->s_sid, mpptime)) } return (mpptime);}extern char *msg_momsetlim;/* * Internal error routine */int error(string, value) char *string; int value;{ int i = 0; char *message; assert(string != NULL); assert(*string != '\0'); assert(value > PBSE_); /* minimum PBS error number */ assert(value <= PBSE_NOSYNCMSTR); /* maximum PBS error number */ assert(pbs_err_to_txt[i].err_no != 0); do { if (pbs_err_to_txt[i].err_no == value) break; } while (pbs_err_to_txt[++i].err_no != 0); assert(pbs_err_to_txt[i].err_txt != NULL); message = *pbs_err_to_txt[i].err_txt; assert(message != NULL); assert(*message != '\0'); (void)fprintf(stderr, msg_momsetlim, string, message); (void)fflush(stderr); return (value);}/* * which_limit - set either user's limit or udb limit: * * If user's limit is a default, then use lesser of it or udb * * Else, use user's limit unless it is greater than the udb and the * the udb limit is not unlimited. This case is an error. */static int which_limit(rlimit, udblimit, r_flags, zlimit, rtn_limit) long rlimit; /* limit value from resource_limit */ long udblimit; /* limit for that resource from UDB */ int r_flags; /* resource entry flags (ATR_VFLAG_DEFLT) */ int zlimit; /* true if 0 in udb mean real limit of zero */ long *rtn_limit; /* RETURN: the limit to set */{ if (r_flags & ATR_VFLAG_DEFLT) { /* User's limit is a default value, if default > UDB, use UDB */ if ( (udblimit == MAXUE_LONG) || ((udblimit == 0) && (zlimit == 0)) || (rlimit < udblimit) ) *rtn_limit = rlimit; else *rtn_limit = udblimit; } else { /* user specified an actual limit */ if (zlimit) { if ((udblimit != MAXUE_LONG) && (rlimit > udblimit)) return (PBSE_EXLIMIT); } else { if (((udblimit != 0) || (udblimit != MAXUE_LONG)) && (rlimit > udblimit)) return (PBSE_EXLIMIT); } *rtn_limit = rlimit; } return (0);}/* * Establish system-enforced limits for the tasks of a job. * * Run through the resource list, checking the values for all items * we recognize. * * If set_mode is SET_LIMIT_SET, then also set hard limits for the * system enforced limits (not-polled). * If anything goes wrong with the process, return a PBS error code * and print a message on standard error. A zero-length resource list * is not an error. * * If set_mode is SET_LIMIT_SET the entry conditions are: * 1. MOM has already forked, and we are called from the child. * 2. The child is still running as root. * 3. Standard error is open to the user's file. * * If set_mode is SET_LIMIT_ALTER, we are beening called to modify * existing limits. Unlike bsd based systems that use setrlimit, the * Cray limit() call can set limits for another session. Hence all * limits can be adjusted. */int mom_set_limits(pjob, set_mode) job *pjob; int set_mode; /* unused here */{ static char *id = "mom_set_limits"; int acid; int maxcore; int maxcput;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -