OpenBSD CVS

CVS log for src/lib/libkvm/kvm_proc2.c


[BACK] Up to [local] / src / lib / libkvm

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.38 / (download) - annotate - [select for diffs], Tue Feb 22 17:35:01 2022 UTC (2 years, 3 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, HEAD
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

MAXCOMLEN is no longer needed in these programs, so remove the annotation
from sys/param.h include lines, or remove the include lines entirely if
it this was the least requirement.
ok millert

Revision 1.37 / (download) - annotate - [select for diffs], Mon Feb 14 18:09:08 2022 UTC (2 years, 3 months ago) by rob
Branch: MAIN
Changes since 1.36: +1 -2 lines
Diff to previous 1.36 (colored)

Revert change to ps for displaying chrooted process.
Ok deraadt

Revision 1.36 / (download) - annotate - [select for diffs], Tue Feb 8 12:10:39 2022 UTC (2 years, 4 months ago) by jsg
Branch: MAIN
Changes since 1.35: +2 -1 lines
Diff to previous 1.35 (colored)

Using FILL_KPROC() from sysctl.h after rev 1.223 requires a definition
of struct filedesc.  Include sys/filedesc.h here to unbreak the build.

problem found by and ok tb@

Revision 1.35 / (download) - annotate - [select for diffs], Wed Oct 6 00:42:46 2021 UTC (2 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.34: +2 -2 lines
Diff to previous 1.34 (colored)

annotate sys/param.h uses as required, and pull in standard userland
.h files as required.... preparing for a potential future when sys/proc.h
might be more clean...
do not touch the MD .c files yet, the dragons remain full of fire

Revision 1.34 / (download) - annotate - [select for diffs], Fri Sep 10 00:02:43 2021 UTC (2 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.33: +4 -2 lines
Diff to previous 1.33 (colored)

annotate what symbols are used from sys/param.h lines, or delete them
if not required.  when deleting, add sys/signal.h or other lines which
were not being pulled in

Revision 1.33 / (download) - annotate - [select for diffs], Mon Feb 8 10:51:01 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.32: +5 -6 lines
Diff to previous 1.32 (colored)

Revert the convertion of per-process thread into a SMR_TAILQ.

We did not reach a consensus about using SMR to unlock single_thread_set()
so there's no point in keeping this change.

Revision 1.32 / (download) - annotate - [select for diffs], Mon Dec 7 16:55:28 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.31: +6 -5 lines
Diff to previous 1.31 (colored)

Convert the per-process thread list into a SMR_TAILQ.

Currently all iterations are done under KERNEL_LOCK() and therefor use
the *_LOCKED() variant.

From and ok claudio@

Revision 1.31 / (download) - annotate - [select for diffs], Wed Dec 11 12:36:28 2019 UTC (4 years, 6 months ago) by sthen
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.30: +2 -1 lines
Diff to previous 1.30 (colored)

add sys/wait.h to unbreak builds; following "Replace p_xstat with ps_xexit and
ps_xsig" (sysctl.h r1.198 and friends) FILL_KPROC requires W_EXITCODE from there.

cc  -static -pie -o ps keyword.o nlist.o print.o ps.o utf8.o -lkvm
ld: error: undefined symbol: W_EXITCODE
>>> referenced by kvm_proc2.c:293 (/usr/src/lib/libkvm/kvm_proc2.c:293)
[...]

Revision 1.30 / (download) - annotate - [select for diffs], Tue Oct 22 21:19:22 2019 UTC (4 years, 7 months ago) by cheloha
Branch: MAIN
Changes since 1.29: +37 -1 lines
Diff to previous 1.29 (colored)

struct proc: change ps_start from utc time to uptime

Allows us to determine how long a process has been running, even if the
UTC clock jumps.

With help from bluhm@ and millert@, who squashed several bugs.

ok bluhm@ millert@

Revision 1.29 / (download) - annotate - [select for diffs], Sun Jun 23 16:57:02 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.28: +2 -1 lines
Diff to previous 1.28 (colored)

Export unveil state so that ps(8) can show it.  Two new status flags,
you'll see one, or neither.
'u' - process installed unveils, but not yet locked with unveil(0,0)
      or pledge w/o "unveil"
'U' - process has installed unveils, and locked.
ok rob

Revision 1.28 / (download) - annotate - [select for diffs], Fri Jun 7 10:55:41 2019 UTC (5 years ago) by asou
Branch: MAIN
Changes since 1.27: +2 -2 lines
Diff to previous 1.27 (colored)

fix print not specified process.

ok guenther@ yasuoka@

Revision 1.27 / (download) - annotate - [select for diffs], Mon Nov 7 00:26:33 2016 UTC (7 years, 7 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.26: +14 -28 lines
Diff to previous 1.26 (colored)

Split PID from TID, giving processes a PID unrelated to the TID of their
initial thread

ok jsing@ kettenis@

Revision 1.26 / (download) - annotate - [select for diffs], Tue Sep 8 15:40:32 2015 UTC (8 years, 9 months ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.25: +27 -25 lines
Diff to previous 1.25 (colored)

port the changes just made to kvm_getfiles in kvm_file2.c r1.47 to
kvm_getprocs.

basically cope with the number of procs growing between when we get
the size and when we get the list.

ok guenther@

Revision 1.25 / (download) - annotate - [select for diffs], Wed Oct 15 02:03:05 2014 UTC (9 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.24: +2 -2 lines
Diff to previous 1.24 (colored)

Apply reallocarray() idiom.
ok guenther

Revision 1.24 / (download) - annotate - [select for diffs], Tue Jul 8 23:31:22 2014 UTC (9 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.23: +4 -2 lines
Diff to previous 1.23 (colored)

sys/user.h can now be substantially gutted.
ok guenther

Revision 1.23 / (download) - annotate - [select for diffs], Fri Jul 4 05:58:31 2014 UTC (9 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.22: +27 -8 lines
Diff to previous 1.22 (colored)

Track whether a process is a zombie or not yet fully built via flags
PS_{ZOMBIE,EMBRYO} on the process instead of peeking into the process's
thread data.  This eliminates the need for the thread-level SDEAD state.

Change kvm_getprocs() (both the sysctl() and kvm backends) to report the
"most active" scheduler state for the process's threads.

tweaks kettenis@
feedback and ok matthew@

Revision 1.22 / (download) - annotate - [select for diffs], Sun May 25 20:28:28 2014 UTC (10 years ago) by guenther
Branch: MAIN
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

Get the vmspace pointer from the process, not the thread

Revision 1.21 / (download) - annotate - [select for diffs], Sun Mar 30 21:54:49 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.20: +6 -12 lines
Diff to previous 1.20 (colored)

Eliminates struct pcred by moving the real and saved ugids into
struct ucred; struct process then directly links to the ucred

Based on a discussion at c2k10 or so before noting that FreeBSD and
NetBSD did this too.

ok matthew@

Revision 1.20 / (download) - annotate - [select for diffs], Sat Mar 22 11:18:05 2014 UTC (10 years, 2 months ago) by florian
Branch: MAIN
Changes since 1.19: +4 -4 lines
Diff to previous 1.19 (colored)

Unbreak tree; p_sigacts moved from struct proc to struct process

Revision 1.19 / (download) - annotate - [select for diffs], Wed Feb 5 03:49:00 2014 UTC (10 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.18: +3 -3 lines
Diff to previous 1.18 (colored)

More crash dump parsing fixes: correct paddr in process info and pids
in file info.  Drop some unnecessary casts and unused variables too.

ok millert@

Revision 1.18 / (download) - annotate - [select for diffs], Mon Jan 20 21:19:28 2014 UTC (10 years, 4 months ago) by guenther
Branch: MAIN
Changes since 1.17: +103 -75 lines
Diff to previous 1.17 (colored)

Threads can't be zombies, only processes, so change zombproc to zombprocess,
make it a list of processes, and change P_NOZOMBIE and P_STOPPED from thread
flags to process flags.  Add allprocess list for the code that just wants
to see processes.

ok tedu@

Revision 1.17 / (download) - annotate - [select for diffs], Tue Nov 12 14:49:41 2013 UTC (10 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.16: +32 -28 lines
Diff to previous 1.16 (colored)

Apply format __attribute__ to _kvm_err() and fix the errors that it detects.
Treat failure to KREAD teh pcredd or ucreds to be errors insteading of
continuing with bogus data.

ok deraadt@ millert@

Revision 1.16 / (download) - annotate - [select for diffs], Wed Mar 20 14:46:45 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.15: +2 -2 lines
Diff to previous 1.15 (colored)

spaces

Revision 1.15 / (download) - annotate - [select for diffs], Wed Mar 20 03:43:08 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

When non-root asks sysctl for kinfo proc or file requests, do not fill in
any kernel addresses information.
ok guenther

Revision 1.14 / (download) - annotate - [select for diffs], Mon Nov 12 00:29:09 2012 UTC (11 years, 7 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

Fix pid matching on kernel crashdumps in kvm_getprocs(KERN_PROC_PID)

Revision 1.13 / (download) - annotate - [select for diffs], Tue Apr 17 23:17:53 2012 UTC (12 years, 1 month ago) by pirofti
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.12: +9 -1 lines
Diff to previous 1.12 (colored)

Make it optional for kvm_getprocs() (and related sysctl) to return
thread information.

Add a KERN_PROC_SHOW_THREADS flag that has to be set in order to get the
thread info and make it off by default. This creates backwards compatibility
for applications that relied on a given size/number of items to be returned.

Modify ps(1) and top(1) accordingly.

Okay guenther@.

Revision 1.12 / (download) - annotate - [select for diffs], Sat Apr 14 12:15:21 2012 UTC (12 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.11: +17 -16 lines
Diff to previous 1.11 (colored)

Update to match nprocs-->nprocess/nthreads changes

Revision 1.11 / (download) - annotate - [select for diffs], Thu Apr 12 14:59:19 2012 UTC (12 years, 2 months ago) by pirofti
Branch: MAIN
Changes since 1.10: +34 -3 lines
Diff to previous 1.10 (colored)

Add per thread accounting, mainly for usage & friends.

This expands the already bloated FILL_KPROC macro to take an extra
parameter that indicates if the callee is a thread or a process.

The userland bits are adjusted accordingly and ps(1) and top(1) now
display per thread usage times when -H is used.

Also pkill(1) had to be adjusted so that duplicates don't pop up.

libkvm does basically the same thing as the kernel bits.

Okay guenther@.

Revision 1.10 / (download) - annotate - [select for diffs], Fri Mar 23 15:51:25 2012 UTC (12 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.9: +2 -8 lines
Diff to previous 1.9 (colored)

Make rusage totals, itimers, and profile settings per-process instead
of per-rthread.  Handling of per-thread tick and runtime counters
inspired by how FreeBSD does it.

ok kettenis@

Revision 1.9 / (download) - annotate - [select for diffs], Sat Jan 7 05:38:12 2012 UTC (12 years, 5 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.8: +14 -9 lines
Diff to previous 1.8 (colored)

Add rtable id and thread id to struct kinfo_proc (and fix process id)
and add an 'rtableid' keyword to ps.

Add rtable id, thread id, and socket splice info to struct kinfo_file2
and make fstat display socket splice information.

Remove old KVM_PROC2 and kinfo_proc2 interfaces; bump libkvm major

Socket splice info and corrections from bluhm@  "Lovely" deraadt@

Revision 1.8 / (download) - annotate - [select for diffs], Tue Jul 5 04:48:01 2011 UTC (12 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.7: +14 -2 lines
Diff to previous 1.7 (colored)

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down.  This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@

Revision 1.7 / (download) - annotate - [select for diffs], Mon Apr 18 21:44:55 2011 UTC (13 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.6: +2 -14 lines
Diff to previous 1.6 (colored)

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts).  Until
that is untangled, the sigacts change is unsafe.  sthen@ was the victim
for this one

Revision 1.6 / (download) - annotate - [select for diffs], Fri Apr 15 17:58:25 2011 UTC (13 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.5: +12 -7 lines
Diff to previous 1.5 (colored)

p_sigacts is NULL for zombies, so FILL_KPROC() and  kvm_proclist() have
to handle that with the sigacts change.

problem observed and diagnosed by claudio@ and kettenis@

Revision 1.5 / (download) - annotate - [select for diffs], Fri Apr 15 04:52:40 2011 UTC (13 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.4: +9 -2 lines
Diff to previous 1.4 (colored)

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc.  Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@

Revision 1.4 / (download) - annotate - [select for diffs], Sat Mar 12 04:54:28 2011 UTC (13 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.3: +26 -20 lines
Diff to previous 1.3 (colored)

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2().  The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions

Revision 1.3 / (download) - annotate - [select for diffs], Mon Jul 26 01:56:27 2010 UTC (13 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.2: +27 -14 lines
Diff to previous 1.2 (colored)

Correct the links between threads, processes, pgrps, and sessions,
so that the process-level stuff is to/from struct process and not
struct proc.  This fixes a bunch of problem cases in rthreads.
Based on earlier work by blambert and myself, but mostly written
at c2k10.

Tested by many: deraadt, sthen, krw, ray, and in snapshots

Revision 1.2 / (download) - annotate - [select for diffs], Tue Jun 29 16:39:23 2010 UTC (13 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.1: +7 -1 lines
Diff to previous 1.1 (colored)

Fail instead of lying if a process asks sysctl()'s KERN_PROC2 or
KERN_FILE2 (or their libkvm wrappers) for more information than the
running implementation knows how to provide.

ok millert@ deraadt@

Revision 1.1 / (download) - annotate - [select for diffs], Sun Jan 10 03:37:50 2010 UTC (14 years, 5 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7

Reimplement kvm_getproc2()'s support for reading crash dumps and
/dev/mem to be direct instead of going through kvm_getprocs(), as
that function is going to get more an more broken as we move stuff
from struct proc to struct process for rthreads.  To minimize the
code copying, put the common logic of filling in a kinfo_proc2
structure into a macro FILL_KPROC2() in <sys/sysctl.h> for use from
both the kernel and user-space.  This also hides the KERN_PROC
#define behind "#if defined(_KERNEL)||defined(_LIBKVM)", as it's
deprecated.

Positive feedback from millert and blambert; so committing to unblock
further rthreads work.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.