On Fri, Apr 04, 2003 at 06:07:12PM -0600, Glenn Johnson wrote: > On Fri, Apr 04, 2003 at 03:54:05PM -0800, Julian Elischer wrote: > > > yes.. > > > > The entire process structure and it's surrounding enviroment has been > > through a blender. > > > > What do you wnat to do? > > I would like to learn what I need to do to get the software to compile > on FreeBSD-5. I guess the question is, what information do I need to > provide? The software in question is OpenPBS (http://www.openpbs.org), > so it nothing proprietary. There were a whole bunch of dependency > problems that I worked through manually and finally got to the point > of the kp_proc failure. Here is a snippet of code that produces the > failure: Here are untested patches I made for this a while ago. There's also a port PR somewhere. --- src/resmom/freebsd/mom_mach.c.orig Tue Dec 4 16:38:48 2001 +++ src/resmom/freebsd/mom_mach.c Wed Jan 15 21:04:15 2003 _at__at_ -368,11 +368,21 _at__at_ continue; nps++; +#if __FreeBSD_version < 500000 cputime += tvk(pp->kp_proc.p_rtime); - - if (pp->kp_proc.p_ru == NULL) { +#else + cputime += tvk(pp->ki_runtime); +#endif + +#if __FreeBSD_version < 500000 + if (pp->kp_proc.p_ru == NULL) +#else + if (&pp->ki_rusage == NULL) +#endif + { struct pstats ps; +#if __FreeBSD_version < 500000 DBPRT(("%s: p_stats 0x%lx\n", id, (u_long)pp->kp_proc.p_stats)) if (pp->kp_proc.p_stats == NULL) _at__at_ -387,10 +397,27 _at__at_ tv(ps.p_ru.ru_stime) + tv(ps.p_cru.ru_utime) + tv(ps.p_cru.ru_stime); +#else + DBPRT(("%s: p_stats 0x%lx\n", id, + (u_long)pp->ki_user->u_stats)) + if (&pp->ki_addr->u_stats == NULL) + continue; + + if (kvm_read(kd, (u_long)&pp->ki_addr->u_stats, &ps, + sizeof(ps)) != sizeof(ps)) { + log_err(errno, id, "kvm_read(u_stats)"); + continue; + } + cputime += tv(ps.p_ru.ru_utime) + + tv(ps.p_ru.ru_stime) + + tv(ps.p_cru.ru_utime) + + tv(ps.p_cru.ru_stime); +#endif } else { struct rusage ru; +#if __FreeBSD_version < 500000 DBPRT(("%s: p_ru 0x%lx\n", id, (u_long)pp->kp_proc.p_ru)) if (kvm_read(kd, (u_long)pp->kp_proc.p_ru, &ru, _at__at_ -402,6 +429,19 _at__at_ } DBPRT(("%s: ses %d pid %d cputime %d\n", id, sess_tbl[i], pp->kp_proc.p_pid, cputime)) +#else + DBPRT(("%s: p_ru 0x%lx\n", id, + (u_long)pp->ki_rusage)) + if (kvm_read(kd, (u_long)&pp->ki_rusage, &ru, + sizeof(ru)) != sizeof(ru)) { + log_err(errno, id, "kvm_read(session)"); + continue; + } + cputime += tv(ru.ru_utime) + tv(ru.ru_stime); + } + DBPRT(("%s: ses %d pid %d cputime %d\n", id, + sess_tbl[i], pp->ki_pid, cputime)) +#endif } if (nps == 0) _at__at_ -429,12 +469,19 _at__at_ if (!injob(pjob, sess_tbl[i])) continue; - +#if __FreeBSD_version < 500000 memsize += ctob(pp->kp_eproc.e_vm.vm_tsize + pp->kp_eproc.e_vm.vm_dsize + pp->kp_eproc.e_vm.vm_ssize); DBPRT(("%s: ses %d pid=%d totmem=%lu\n", id, sess_tbl[i], pp->kp_proc.p_pid, memsize)) +#else + memsize += ctob(pp->ki_tsize + + pp->ki_dsize + + pp->ki_ssize); + DBPRT(("%s: ses %d pid=%d totmem=%lu\n", id, + sess_tbl[i], pp->ki_pid, memsize)) +#endif } return (memsize); _at__at_ -457,10 +504,17 _at__at_ if (!injob(pjob, sess_tbl[i])) continue; +#if __FreeBSD_version < 500000 memsize += ctob(pp->kp_eproc.e_vm.vm_rssize); DBPRT(("%s: pid=%d ses=%d mem=%d totmem=%d\n", id, pp->kp_proc.p_pid, sess_tbl[i], pp->kp_eproc.e_vm.vm_rssize, memsize)) +#else + memsize += ctob(pp->ki_rssize); + DBPRT(("%s: pid=%d ses=%d mem=%d totmem=%d\n", id, + pp->ki_pid, sess_tbl[i], + pp->ki_rssize, memsize)) +#endif } return (memsize); _at__at_ -481,10 +535,18 _at__at_ if (!injob(pjob, sess_tbl[i])) continue; +#if __FreeBSD_version < 500000 if (ctob(pp->kp_eproc.e_vm.vm_tsize + pp->kp_eproc.e_vm.vm_dsize + pp->kp_eproc.e_vm.vm_ssize) > limit) return (TRUE); +#else + if (ctob(pp->ki_tsize + + pp->ki_dsize + + pp->ki_ssize) > limit) + return (TRUE); +#endif + } return (FALSE); _at__at_ -722,7 +784,12 _at__at_ struct kinfo_proc *a; struct kinfo_proc *b; { +#if __FreeBSD_version < 500000 return((int)a->kp_eproc.e_paddr - (int)b->kp_eproc.e_paddr); +#else + return((int)a->ki_paddr - (int)b->ki_paddr); +#endif + } int _at__at_ -730,7 +797,12 _at__at_ struct session *key; struct kinfo_proc *member; { + +#if __FreeBSD_version < 500000 return((int)key->s_leader - (int)member->kp_eproc.e_paddr); +#else + return((int)key->s_leader - (int)member->ki_paddr); +#endif } /* _at__at_ -775,13 +847,20 _at__at_ qsort(proc_tbl, nproc, sizeof(struct kinfo_proc), qs_cmp); for (i=0, kp=proc_tbl; i<nproc; i++, kp++) { +#if __FreeBSD_version < 500000 if (kvm_read(kd, (u_long)kp->kp_eproc.e_sess, &ss, sizeof(ss)) - != sizeof(ss)) { + != sizeof(ss)) +#else + if (kvm_read(kd, (u_long)kp->ki_paddr->p_pgrp->pg_session, &ss, sizeof(ss)) + != sizeof(ss)) +#endif + { sprintf(log_buffer, "kvm_read: %s", kvm_geterr(kd)); log_err(errno, id, log_buffer); return (PBSE_SYSTEM); } +#if __FreeBSD_version < 500000 if (ss.s_leader == kp->kp_eproc.e_paddr || ss.s_leader == NULL) { sid = kp->kp_proc.p_pid; _at__at_ -791,6 +870,17 _at__at_ sizeof(struct kinfo_proc), bs_cmp); sid = leader ? leader->kp_proc.p_pid : 0; } +#else + if (ss.s_leader == kp->ki_paddr || + ss.s_leader == NULL) { + sid = kp->ki_pid; + } + else { + leader = bsearch(&ss, proc_tbl, nproc, + sizeof(struct kinfo_proc), bs_cmp); + sid = leader ? leader->ki_pid : 0; + } +#endif sess_tbl[i] = sid; } _at__at_ -995,9 +1085,16 _at__at_ if (sesid != sess_tbl[i]) continue; +#if __FreeBSD_version < 500000 DBPRT(("%s: send signal %d to pid %d\n", id, sig, pp->kp_proc.p_pid)) (void)kill(pp->kp_proc.p_pid, sig); +#else + DBPRT(("%s: send signal %d to pid %d\n", id, + sig, pp->ki_pid)) + (void)kill(pp->ki_pid, sig); + +#endif ++ct; } return ct; _at__at_ -1102,8 +1199,13 _at__at_ if (jobid != sess_tbl[i]) continue; +#if __FreeBSD_version < 500000 cputime += tvk(pp->kp_proc.p_rtime); +#else + +#endif +#if __FreeBSD_version < 500000 if (pp->kp_proc.p_ru == NULL) { struct pstats ps; _at__at_ -1132,6 +1234,36 _at__at_ } DBPRT(("%s: ses %d pid %d cputime %d\n", id, jobid, pp->kp_proc.p_pid, cputime)) +#else + if (&pp->ki_rusage == NULL) { + struct pstats ps; + + if (&pp->ki_addr->u_stats == NULL) + continue; + + if (kvm_read(kd, (u_long)&pp->ki_addr->u_stats, &ps, + sizeof(ps)) != sizeof(ps)) { + log_err(errno, id, "kvm_read(u_stats)"); + continue; + } + cputime += tv(ps.p_ru.ru_utime) + + tv(ps.p_ru.ru_stime) + + tv(ps.p_cru.ru_utime) + + tv(ps.p_cru.ru_stime); + } + else { + struct rusage ru; + + if (kvm_read(kd, (u_long)pp->ki_paddr->p_ru, &ru, + sizeof(ru)) != sizeof(ru)) { + log_err(errno, id, "kvm_read(session)"); + continue; + } + cputime += tv(ru.ru_utime) + tv(ru.ru_stime); + } + DBPRT(("%s: ses %d pid %d cputime %d\n", id, + jobid, pp->ki_pid, cputime)) +#endif } _at__at_ -1150,6 +1282,7 _at__at_ for (i=0; i<nproc; i++) { struct kinfo_proc *pp = &proc_tbl[i]; +#if __FreeBSD_version < 500000 if (pid != pp->kp_proc.p_pid) continue; _at__at_ -1180,9 +1313,41 _at__at_ break; } cputime += tv(ru.ru_utime) + tv(ru.ru_stime); - } DBPRT(("%s: pid %d cputime %d\n", id, pid, cputime)) +#else + if (pid != pp->ki_pid) + continue; + + cputime = tvk(pp->ki_runtime); + + if (&pp->ki_rusage == NULL) { + struct pstats ps; + + if (&pp->ki_addr->u_stats == NULL) + break; + if (kvm_read(kd, (u_long)&pp->ki_addr->u_stats, &ps, + sizeof(ps)) != sizeof(ps)) { + log_err(errno, id, "kvm_read(u_stats)"); + break; + } + cputime += tv(ps.p_ru.ru_utime) + + tv(ps.p_ru.ru_stime) + + tv(ps.p_cru.ru_utime) + + tv(ps.p_cru.ru_stime); + } + else { + struct rusage ru; + + if (kvm_read(kd, (u_long)&pp->ki_rusage, &ru, + sizeof(ru)) != sizeof(ru)) { + log_err(errno, id, "kvm_read(session)"); + break; + } + cputime += tv(ru.ru_utime) + tv(ru.ru_stime); + } +#endif + DBPRT(("%s: pid %d cputime %d\n", id, pid, cputime)) sprintf(ret_string, "%.2f", (double)cputime * cputfactor); return ret_string; } _at__at_ -1245,9 +1410,16 _at__at_ continue; found = 1; + +#if __FreeBSD_version < 500000 addmem = pp->kp_eproc.e_vm.vm_tsize + pp->kp_eproc.e_vm.vm_dsize + pp->kp_eproc.e_vm.vm_ssize; +#else + addmem = pp->ki_tsize + + pp->ki_dsize + + pp->ki_ssize; +#endif memsize += addmem; } if (found) { _at__at_ -1273,12 +1445,24 _at__at_ for (i=0; i<nproc; i++) { struct kinfo_proc *pp = &proc_tbl[i]; +#if __FreeBSD_version < 500000 if (pid != pp->kp_proc.p_pid) continue; +#else + if (pid != pp->ki_pid) + continue; +#endif + +#if __FreeBSD_version < 500000 memsize = pp->kp_eproc.e_vm.vm_tsize + pp->kp_eproc.e_vm.vm_dsize + pp->kp_eproc.e_vm.vm_ssize; +#else + memsize = pp->ki_tsize + + pp->ki_dsize + + pp->ki_ssize; +#endif sprintf(ret_string, "%ukb", ctob(memsize) >> 10); /* KB */ return ret_string; } _at__at_ -1342,7 +1526,11 _at__at_ continue; found = 1; +#if __FreeBSD_version < 500000 resisize += pp->kp_eproc.e_vm.vm_rssize; +#else + resisize += pp->ki_rssize; +#endif } if (found) { sprintf(ret_string, "%ukb", ctob(resisize) >> 10); /* KB */ _at__at_ -1369,10 +1557,19 _at__at_ for (i=0; i<nproc; i++) { struct kinfo_proc *pp = &proc_tbl[i]; +#if __FreeBSD_version < 500000 if (pid != pp->kp_proc.p_pid) continue; +#else + if (pid != pp->ki_pid) + continue; +#endif +#if __FreeBSD_version < 500000 resisize = pp->kp_eproc.e_vm.vm_rssize; +#else + resisize = pp->ki_rssize; +#endif sprintf(ret_string, "%ukb", ctob(resisize) >> 10); /* KB */ return ret_string; } _at__at_ -1446,12 +1643,22 _at__at_ for (i=0; i<nproc; i++) { struct kinfo_proc *pp = &proc_tbl[i]; +#if __FreeBSD_version < 500000 if (pp->kp_eproc.e_pcred.p_ruid == 0) continue; +#else + if (pp->ki_ruid == 0) + continue; +#endif jobid = sess_tbl[i]; +#if __FreeBSD_version < 500000 DBPRT(("%s: pid %d sid %u\n", id, (int)pp->kp_proc.p_pid, jobid)) +#else + DBPRT(("%s: pid %d sid %u\n", + id, (int)pp->ki_pid, jobid)) +#endif for (j=0; j<njids; j++) { if (jids[j] == jobid) break; _at__at_ -1531,13 +1738,22 _at__at_ for (i=0; i<nproc; i++) { struct kinfo_proc *pp = &proc_tbl[i]; +#if __FreeBSD_version < 500000 DBPRT(("%s[%d]: pid %d sid %u\n", id, num_pids, pp->kp_proc.p_pid, sess_tbl[i])) +#else + DBPRT(("%s[%d]: pid %d sid %u\n", + id, num_pids, pp->ki_pid, sess_tbl[i])) +#endif if (jobid != sess_tbl[i]) continue; checkret(&fmt, 100); +#if __FreeBSD_version < 500000 sprintf(fmt, " %d", pp->kp_proc.p_pid); +#else + sprintf(fmt, " %d", pp->ki_pid); +#endif fmt += strlen(fmt); num_pids++; } _at__at_ -1575,11 +1791,20 _at__at_ for (i=0; i<nproc; i++) { struct kinfo_proc *pp = &proc_tbl[i]; +#if __FreeBSD_version < 500000 if ((uid = pp->kp_eproc.e_pcred.p_ruid) == 0) continue; DBPRT(("%s: pid %d uid %u\n", id, (int)pp->kp_proc.p_pid, uid)) +#else + if ((uid = pp->ki_ruid) == 0) + continue; + + DBPRT(("%s: pid %d uid %u\n", + id, (int)pp->ki_pid, uid)) +#endif + for (j=0; j<nuids; j++) { if (uids[j] == uid) break; _at__at_ -1842,10 +2067,16 _at__at_ continue; } else { +#if __FreeBSD_version < 500000 if (value != pp->kp_proc.p_pid) continue; +#else + if (value != pp->ki_pid) + continue; +#endif } +#if __FreeBSD_version < 500000 if (pp->kp_proc.p_stats == NULL) { rm_errno = RM_ERR_SYSTEM; return NULL; _at__at_ -1857,6 +2088,19 _at__at_ rm_errno = RM_ERR_SYSTEM; return NULL; } +#else + if (&pp->ki_addr->u_stats == NULL) { + rm_errno = RM_ERR_SYSTEM; + return NULL; + } + + if (kvm_read(kd, (u_long)&pp->ki_addr->u_stats, &ps, + sizeof(ps)) != sizeof(ps)) { + log_err(errno, id, "kvm_read(u_stats)"); + rm_errno = RM_ERR_SYSTEM; + return NULL; + } +#endif found = 1; start = MIN(start, ps.p_start.tv_sec); }
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:02 UTC