diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -871,10 +871,7 @@ else pid = -1; db_printf("Tracing pid %d tid %ld td %p\n", pid, (long)td->td_tid, td); - if (td->td_proc != NULL && (td->td_proc->p_flag & P_INMEM) == 0) - db_printf("--- swapped out\n"); - else - db_trace_thread(td, count); + db_trace_thread(td, count); } static void @@ -898,10 +895,7 @@ db_printf("\nTracing command %s pid %d" " tid %ld td %p\n", td->td_proc->p_comm, td->td_proc->p_pid, (long)td->td_tid, td); - if (td->td_proc->p_flag & P_INMEM) - db_trace_thread(td, -1); - else - db_printf("--- swapped out\n"); + db_trace_thread(td, -1); if (db_pager_quit) { kdb_jmpbuf(prev_jb); return; diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -215,8 +215,6 @@ state[1] = '\0'; /* Additional process state flags. */ - if (!(p->p_flag & P_INMEM)) - strlcat(state, "W", sizeof(state)); if (p->p_flag & P_TRACED) strlcat(state, "X", sizeof(state)); if (p->p_flag & P_WEXIT && p->p_state != PRS_ZOMBIE) diff --git a/sys/ddb/db_thread.c b/sys/ddb/db_thread.c --- a/sys/ddb/db_thread.c +++ b/sys/ddb/db_thread.c @@ -87,11 +87,8 @@ (void *)thr->td_kstack); prev_jb = kdb_jmpbuf(jb); if (setjmp(jb) == 0) { - if (thr->td_proc->p_flag & P_INMEM) { - if (db_trace_thread(thr, 1) != 0) - db_printf("***\n"); - } else - db_printf("*** swapped out\n"); + if (db_trace_thread(thr, 1) != 0) + db_printf("***\n"); } kdb_jmpbuf(prev_jb); thr = kdb_thr_next(thr); diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -61,6 +61,7 @@ int procfs_doprocstatus(PFS_FILL_ARGS) { + struct timeval start, ut, st; struct session *sess; struct thread *tdfirst; struct tty *tp; @@ -121,21 +122,16 @@ wmesg = "nochan"; thread_unlock(tdfirst); - if (p->p_flag & P_INMEM) { - struct timeval start, ut, st; - - PROC_STATLOCK(p); - calcru(p, &ut, &st); - PROC_STATUNLOCK(p); - start = p->p_stats->p_start; - getboottime(&boottime); - timevaladd(&start, &boottime); - sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", - (intmax_t)start.tv_sec, start.tv_usec, - (intmax_t)ut.tv_sec, ut.tv_usec, - (intmax_t)st.tv_sec, st.tv_usec); - } else - sbuf_printf(sb, " -1,-1 -1,-1 -1,-1"); + PROC_STATLOCK(p); + calcru(p, &ut, &st); + PROC_STATUNLOCK(p); + start = p->p_stats->p_start; + getboottime(&boottime); + timevaladd(&start, &boottime); + sbuf_printf(sb, " %jd,%ld %jd,%ld %jd,%ld", + (intmax_t)start.tv_sec, start.tv_usec, + (intmax_t)ut.tv_sec, ut.tv_usec, + (intmax_t)st.tv_sec, st.tv_usec); sbuf_printf(sb, " %s", wmesg); diff --git a/sys/i386/linux/linux_ptrace_machdep.c b/sys/i386/linux/linux_ptrace_machdep.c --- a/sys/i386/linux/linux_ptrace_machdep.c +++ b/sys/i386/linux/linux_ptrace_machdep.c @@ -213,7 +213,7 @@ { PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); - if (cpu_fxsr == 0 || (td->td_proc->p_flag & P_INMEM) == 0) + if (cpu_fxsr == 0) return (EIO); bcopy(&get_pcb_user_save_td(td)->sv_xmm, fpxregs, sizeof(*fpxregs)); return (0); @@ -224,7 +224,7 @@ { PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); - if (cpu_fxsr == 0 || (td->td_proc->p_flag & P_INMEM) == 0) + if (cpu_fxsr == 0) return (EIO); bcopy(fpxregs, &get_pcb_user_save_td(td)->sv_xmm, sizeof(*fpxregs)); return (0); diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1148,10 +1148,7 @@ kp->ki_ssize = vm->vm_ssize; } else if (p->p_state == PRS_ZOMBIE) kp->ki_stat = SZOMB; - if (kp->ki_flag & P_INMEM) - kp->ki_sflag = PS_INMEM; - else - kp->ki_sflag = 0; + kp->ki_sflag = PS_INMEM; /* Calculate legacy swtime as seconds since 'swtick'. */ kp->ki_swtime = (ticks - p->p_swtick) / hz; kp->ki_pid = p->p_pid; diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -332,12 +332,6 @@ ASSERT_RACCT_ENABLED(); - /* - * If the process is swapped out, we count its %cpu usage as zero. - * This behaviour is consistent with the userland ps(1) tool. - */ - if ((p->p_flag & P_INMEM) == 0) - return (0); swtime = (ticks - p->p_swtick) / hz; /* diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -71,7 +71,7 @@ #define PROC_ASSERT_TRACEREQ(p) MPASS(((p)->p_flag2 & P2_PTRACEREQ) != 0) /* - * Functions implemented using PROC_ACTION(): + * Functions implemented below: * * proc_read_regs(proc, regs) * Get the current user-visible register set from the process @@ -96,43 +96,32 @@ * Arrange for the process to trap after executing a single instruction. */ -#define PROC_ACTION(action) do { \ - int error; \ - \ - PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); \ - if ((td->td_proc->p_flag & P_INMEM) == 0) \ - error = EIO; \ - else \ - error = (action); \ - return (error); \ -} while (0) - int proc_read_regs(struct thread *td, struct reg *regs) { - - PROC_ACTION(fill_regs(td, regs)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (fill_regs(td, regs)); } int proc_write_regs(struct thread *td, struct reg *regs) { - - PROC_ACTION(set_regs(td, regs)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (set_regs(td, regs)); } int proc_read_dbregs(struct thread *td, struct dbreg *dbregs) { - - PROC_ACTION(fill_dbregs(td, dbregs)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (fill_dbregs(td, dbregs)); } int proc_write_dbregs(struct thread *td, struct dbreg *dbregs) { - - PROC_ACTION(set_dbregs(td, dbregs)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (set_dbregs(td, dbregs)); } /* @@ -142,15 +131,15 @@ int proc_read_fpregs(struct thread *td, struct fpreg *fpregs) { - - PROC_ACTION(fill_fpregs(td, fpregs)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (fill_fpregs(td, fpregs)); } int proc_write_fpregs(struct thread *td, struct fpreg *fpregs) { - - PROC_ACTION(set_fpregs(td, fpregs)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (set_fpregs(td, fpregs)); } static struct regset * @@ -295,51 +284,51 @@ int proc_read_regs32(struct thread *td, struct reg32 *regs32) { - - PROC_ACTION(fill_regs32(td, regs32)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (fill_regs32(td, regs32)); } int proc_write_regs32(struct thread *td, struct reg32 *regs32) { - - PROC_ACTION(set_regs32(td, regs32)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (set_regs32(td, regs32)); } int proc_read_dbregs32(struct thread *td, struct dbreg32 *dbregs32) { - - PROC_ACTION(fill_dbregs32(td, dbregs32)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (fill_dbregs32(td, dbregs32)); } int proc_write_dbregs32(struct thread *td, struct dbreg32 *dbregs32) { - - PROC_ACTION(set_dbregs32(td, dbregs32)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (set_dbregs32(td, dbregs32)); } int proc_read_fpregs32(struct thread *td, struct fpreg32 *fpregs32) { - - PROC_ACTION(fill_fpregs32(td, fpregs32)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (fill_fpregs32(td, fpregs32)); } int proc_write_fpregs32(struct thread *td, struct fpreg32 *fpregs32) { - - PROC_ACTION(set_fpregs32(td, fpregs32)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (set_fpregs32(td, fpregs32)); } #endif int proc_sstep(struct thread *td) { - - PROC_ACTION(ptrace_single_step(td)); + PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); + return (ptrace_single_step(td)); } int diff --git a/sys/sys/proc.h b/sys/sys/proc.h --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -835,7 +835,7 @@ #define P_TOTAL_STOP 0x02000000 /* Stopped in stop_all_proc. */ #define P_INEXEC 0x04000000 /* Process is in execve(). */ #define P_STATCHILD 0x08000000 /* Child process stopped or exited. */ -#define P_INMEM 0x10000000 /* Loaded into memory. */ +#define P_INMEM 0x10000000 /* Loaded into memory, always set. */ #define P_UNUSED1 0x20000000 /* --available-- */ #define P_UNUSED2 0x40000000 /* --available-- */ #define P_PPTRACE 0x80000000 /* PT_TRACEME by vforked child. */ diff --git a/sys/sys/user.h b/sys/sys/user.h --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -225,7 +225,7 @@ * Legacy PS_ flag. This moved to p_flag but is maintained for * compatibility. */ -#define PS_INMEM 0x00001 /* Loaded into memory. */ +#define PS_INMEM 0x00001 /* Loaded into memory, always true. */ /* ki_sessflag values */ #define KI_CTTY 0x00000001 /* controlling tty vnode active */ diff --git a/sys/vm/vm_swapout.c b/sys/vm/vm_swapout.c --- a/sys/vm/vm_swapout.c +++ b/sys/vm/vm_swapout.c @@ -383,13 +383,6 @@ limit = OFF_TO_IDX( qmin(rsslim.rlim_cur, rsslim.rlim_max)); - /* - * let processes that are swapped out really be - * swapped out set the limit to nothing (will force a - * swap-out.) - */ - if ((p->p_flag & P_INMEM) == 0) - limit = 0; /* XXX */ vm = vmspace_acquire_ref(p); _PHOLD(p); PROC_UNLOCK(p);