History log of /freebsd-10.1-release/lib/libkvm/kvm_proc.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 241303 06-Oct-2012 avg

kvm_getprocs: gracefully handle errors from kvm_deadprocs

and don't confuse callers with incorrect return value

MFC after: 9 days


# 241302 06-Oct-2012 avg

kvm_proclist: ignore processes in larvae state

Reviewed by: jhb
MFC after: 8 days


# 230873 01-Feb-2012 trociny

Try to avoid ambiguity when sysctl returns ENOMEM additionally
checking the returned oldlen: when ENOMEM is due to the supplied
buffer being too short the return oldlen is equal to buffer size.

Without this additional check kvm_getprocs() gets stuck in loop if the
returned ENOMEM was due the exceeded memorylocked limit. This is
easily can be observed running `limits -l 1k top'.

Submitted by: Andrey Zonov <andrey zonov org>
MFC after: 1 week


# 230146 15-Jan-2012 trociny

In kvm_argv(), the case when the supplied buffer was too short to hold the
requested value was handled incorrectly, and the function retuned NULL
instead of the truncated result.

Fix this and also remove unnecessary check for buf != NULL, which alway
retuns true.

MFC after: 3 days


# 227839 22-Nov-2011 trociny

Now kvm_getenvv() and kvm_getargv() don't need procfs(5).

MFC after: 2 weeks


# 224199 18-Jul-2011 bz

Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.
Provide backward compatibility defines under BURN_BRIDGES.

Suggested by: jhb
Reviewed by: emaste
Sponsored by: Sandvine Incorporated
Approved by: re (kib)


# 217745 23-Jan-2011 uqs

libkvm: fix process runtime calculation on crashdumps

Fix a long standing bug, where the procs ticks where assumed to be in
us. Instead, read cpu_tick_frequency from the kernel and use the same
logic to convert runtime. This is still too optimistic in that it
assumes cpu_tick_frequency is available and fixed. Since this function
is only called on crashdumps, I think we can live with that. Testing has
shown the values to be correct for different kern.hz inside Virtualbox.

Bump WARNS. Alignment issues on some archs mean this is still at 3.

Reviewed by: bde


# 217744 23-Jan-2011 uqs

libkvm code janitoring

- make WARNS=6 clean for archs w/o strict alignment requirments
- add const, ANSIfy, remove unused vars, cast types for comparison
- thanks to differing definitions of VM_MIN_ADDRESS across our archs, we
need to trick the compiler to not complain about signedness. We could
either fix VM_MIN_ADDRESS to always be a simple integer or make the
check conditional on $ARCH.

Closes PRs: kern/42386, kern/83364
Reviewed by: bde


# 209276 17-Jun-2010 sbruno

Much closer approximation of the kernel's calculation of this value.

Reviewed by: alc
Obtained from: Yahoo Inc.


# 200366 10-Dec-2009 brooks

Add a missing else that negated the truncation of ki_ngroups to
NGROUPS.

Submitted by: Dmitry Pryanishnikov <lynx dot ripe at gmail dot com>


# 196990 08-Sep-2009 brooks

cr_groups is no longer embedded in struct ucred and is instead stored
in a seperate array. As such we need to use kvm_read rather than bcopy
to populate the ki_groups field.

This fixes a crash when running ps -ax on a coredump.

Reported by: brucec
Tested by: brucec
MFC after: 3 days


# 195843 24-Jul-2009 brooks

Revert the changes to struct kinfo_proc in r194498. Instead, fill
in up to 16 (KI_NGROUPS) values and steal a bit from ki_cr_flags
(all bits currently unused) to indicate overflow with the new flag
KI_CRF_GRP_OVERFLOW.

This fixes procstat -s.

Approved by: re (kib)


# 194498 19-Jun-2009 brooks

Rework the credential code to support larger values of NGROUPS and
NGROUPS_MAX, eliminate ABI dependencies on them, and raise the to 1024
and 1023 respectively. (Previously they were equal, but under a close
reading of POSIX, NGROUPS_MAX was defined to be too large by 1 since it
is the number of supplemental groups, not total number of groups.)

The bulk of the change consists of converting the struct ucred member
cr_groups from a static array to a pointer. Do the equivalent in
kinfo_proc.

Introduce new interfaces crcopysafe() and crsetgroups() for duplicating
a process credential before modifying it and for setting group lists
respectively. Both interfaces take care for the details of allocating
groups array. crsetgroups() takes care of truncating the group list
to the current maximum (NGROUPS) if necessary. In the future,
crsetgroups() may be responsible for insuring invariants such as sorting
the supplemental groups to allow groupmember() to be implemented as a
binary search.

Because we can not change struct xucred without breaking application
ABIs, we leave it alone and introduce a new XU_NGROUPS value which is
always 16 and is to be used or NGRPS as appropriate for things such as
NFS which need to use no more than 16 groups. When feasible, truncate
the group list rather than generating an error.

Minor changes:
- Reduce the number of hand rolled versions of groupmember().
- Do not assign to both cr_gid and cr_groups[0].
- Modify ipfw to cache ucreds instead of part of their contents since
they are immutable once referenced by more than one entity.

Submitted by: Isilon Systems (initial implementation)
X-MFC after: never
PR: bin/113398 kern/133867


# 185435 29-Nov-2008 bz

MFp4:
Bring in updated jail support from bz_jail branch.

This enhances the current jail implementation to permit multiple
addresses per jail. In addtion to IPv4, IPv6 is supported as well.
Due to updated checks it is even possible to have jails without
an IP address at all, which basically gives one a chroot with
restricted process view, no networking,..

SCTP support was updated and supports IPv6 in jails as well.

Cpuset support permits jails to be bound to specific processor
sets after creation.

Jails can have an unrestricted (no duplicate protection, etc.) name
in addition to the hostname. The jail name cannot be changed from
within a jail and is considered to be used for management purposes
or as audit-token in the future.

DDB 'show jails' command was added to aid debugging.

Proper compat support permits 32bit jail binaries to be used on 64bit
systems to manage jails. Also backward compatibility was preserved where
possible: for jail v1 syscalls, as well as with user space management
utilities.

Both jail as well as prison version were updated for the new features.
A gap was intentionally left as the intermediate versions had been
used by various patches floating around the last years.

Bump __FreeBSD_version for the afore mentioned and in kernel changes.

Special thanks to:
- Pawel Jakub Dawidek (pjd) for his multi-IPv4 patches
and Olivier Houchard (cognet) for initial single-IPv6 patches.
- Jeff Roberson (jeff) and Randall Stewart (rrs) for their
help, ideas and review on cpuset and SCTP support.
- Robert Watson (rwatson) for lots and lots of help, discussions,
suggestions and review of most of the patch at various stages.
- John Baldwin (jhb) for his help.
- Simon L. Nielsen (simon) as early adopter testing changes
on cluster machines as well as all the testers and people
who provided feedback the last months on freebsd-jail and
other channels.
- My employer, CK Software GmbH, for the support so I could work on this.

Reviewed by: (see above)
MFC after: 3 months (this is just so that I get the mail)
X-MFC Before: 7.2-RELEASE if possible


# 177089 12-Mar-2008 jeff

- Don't inspect the P_SA flag. It's being removed.


# 173025 26-Oct-2007 julian

Aparrently MACXOCOMLEN exisrts only on my machine


# 173004 26-Oct-2007 julian

Introduce a way to make pure kernal threads.
kthread_add() takes the same parameters as the old kthread_create()
plus a pointer to a process structure, and adds a kernel thread
to that process.

kproc_kthread_add() takes the parameters for kthread_add,
plus a process name and a pointer to a pointer to a process instead of just
a pointer, and if the proc * is NULL, it creates the process to the
specifications required, before adding the thread to it.

All other old kthread_xxx() calls return, but act on (struct thread *)
instead of (struct proc *). One reason to change the name is so that
any old kernel modules that are lying around and expect kthread_create()
to make a process will not just accidentally link.

fix top to show kernel threads by their thread name in -SH mode
add a tdnam formatting option to ps to show thread names.

make all idle threads actual kthreads and put them into their own idled process.
make all interrupt threads kthreads and put them in an interd process
(mainly for aesthetic and accounting reasons)
rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper'

man page fixes to follow.


# 172265 21-Sep-2007 jeff

- When using kvm use the new conversion method to derive swtime.

Approved by: re


# 172207 17-Sep-2007 jeff

- Move all of the PS_ flags into either p_flag or td_flags.
- p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or
previously the sched_lock. These bugs have existed for some time.
- Allow swapout to try each thread in a process individually and then
swapin the whole process if any of these fail. This allows us to move
most scheduler related swap flags into td_flags.
- Keep ki_sflag for backwards compat but change all in source tools to
use the new and more correct location of P_INMEM.

Reported by: pho
Reviewed by: attilio, kib
Approved by: re (kensmith)


# 170178 01-Jun-2007 jeff

- Work-around the already partially broken rusage support in kvm by
completely disabling it until a full solution is agreed upon.

Pointy hat to: me


# 165888 08-Jan-2007 imp

Remove the advertising clause. UCB did this some time ago, but these
files were never updated to reflect that.

MFC After: 2 days


# 164938 06-Dec-2006 julian

remove already commented out code


# 163709 26-Oct-2006 jb

Make KSE a kernel option, turned on by default in all GENERIC
kernel configs except sun4v (which doesn't process signals properly
with KSE).

Reviewed by: davidxu@


# 160682 25-Jul-2006 yar

Rev. 1.44 of this file didn't introduce a right solution,
but we don't seem to have one yet, so just add an XXX comment on
passing rux_runtime to bintime2timeval() wrongly.

Spotted by: gcc(1) (warning)


# 147567 23-Jun-2005 peter

Set ki_tdev to NODEV rather than NULL.

Approved by: re


# 143871 20-Mar-2005 pjd

Make kvm(3) aware of ki_jid field.

Reviewed by: gad
MFC after: 3 days


# 143648 15-Mar-2005 phk

Dike out unwarranted reference to si_udev.


# 137907 20-Nov-2004 das

In preparation to remove U areas, don't refer to p_uarea in libkvm.

Reviewed by: arch@


# 137662 13-Nov-2004 csjp

Remove un-needed call to close(2). The fd that close is being
called on is invalid and has no use.

Reviewed by: smkelly


# 136402 11-Oct-2004 peter

Belatedly catch up with the dev_t/cdev changes from a few months back.
Extract the struct cdev pointer and the tty device from inside rather than
incorrectly casting the 'struct cdev *' pointer to a 'dev_t' int. Not
that this was particularly important since it was only used for reading
vmcore files.


# 136195 06-Oct-2004 jhb

- Fix the compile to chase the p_rux changes.
- Add a comment noting that the ru_[us]times values being read aren't
actually valid and need to be computed from the raw values.

Submitted by: many (1)


# 134791 05-Sep-2004 julian

Refactor a bunch of scheduler code to give basically the same behaviour
but with slightly cleaned up interfaces.

The KSE structure has become the same as the "per thread scheduler
private data" structure. In order to not make the diffs too great
one is #defined as the other at this time.

The KSE (or td_sched) structure is now allocated per thread and has no
allocation code of its own.

Concurrency for a KSEGRP is now kept track of via a simple pair of counters
rather than using KSE structures as tokens.

Since the KSE structure is different in each scheduler, kern_switch.c
is now included at the end of each scheduler. Nothing outside the
scheduler knows the contents of the KSE (aka td_sched) structure.

The fields in the ksegrp structure that are to do with the scheduler's
queueing mechanisms are now moved to the kg_sched structure.
(per ksegrp scheduler private data structure). In other words how the
scheduler queues and keeps track of threads is no-one's business except
the scheduler's. This should allow people to write experimental
schedulers with completely different internal structuring.

A scheduler call sched_set_concurrency(kg, N) has been added that
notifies teh scheduler that no more than N threads from that ksegrp
should be allowed to be on concurrently scheduled. This is also
used to enforce 'fainess' at this time so that a ksegrp with
10000 threads can not swamp a the run queue and force out a process
with 1 thread, since the current code will not set the concurrency above
NCPU, and both schedulers will not allow more than that many
onto the system run queue at a time. Each scheduler should eventualy develop
their own methods to do this now that they are effectively separated.

Rejig libthr's kernel interface to follow the same code paths as
linkse for scope system threads. This has slightly hurt libthr's performance
but I will work to recover as much of it as I can.

Thread exit code has been cleaned up greatly.
exit and exec code now transitions a process back to
'standard non-threaded mode' before taking the next step.
Reviewed by: scottl, peter
MFC after: 1 week


# 132756 28-Jul-2004 kan

Remove stale code protected by #ifdef sparc. GCC 3.4.x adds sparc to
predefined symbols on all SPARC platforms and FreeBSD follows the crowd.


# 130996 23-Jun-2004 gad

Fix a test of bit-flag "P_SA" by adding parenthesis around the expression.

Submitted by: Cyrille Lefevre


# 130992 23-Jun-2004 gad

Replace a call to strncpy() with a call to strlcpy()

Submitted by: Cyrille Lefevre


# 130728 19-Jun-2004 gad

Fill in the some new fields 'struct kinfo_proc', namely ki_childstime,
ki_childutime, and ki_emul. Also uses the timeradd() macro to correct
the calculation of ki_childtime. That will correct the value returned
when ki_childtime.tv_usec > 1,000,000.

This also implements a new KERN_PROC_GID option for kvm_getprocs().
It also implements the KERN_PROC_RGID and KERN_PROC_SESSION options
which were added to sys/kern/kern_proc.c revision 1.203.

PR: bin/65803 (a very tiny piece of the PR)
Submitted by: Cyrille Lefevre


# 130640 17-Jun-2004 phk

Second half of the dev_t cleanup.

The big lines are:
NODEV -> NULL
NOUDEV -> NODEV
udev_t -> dev_t
udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.


# 130552 15-Jun-2004 julian

This library has to change whenever the kernel process structure changes.


# 127518 28-Mar-2004 schweikh

Fix a warning: compare u_long ps_strings to 0 instead of NULL.


# 126126 22-Feb-2004 deischen

Teach kvm_getprocs() to recognize a sysctl flag for including threads.


# 120500 27-Sep-2003 tjr

Use the 3-component version of the KERN_PROC_PROC sysctl.


# 118284 31-Jul-2003 phk

Remove unnecssary <vm/swap_pager.h> includes.

These were probably not cleaned up back in whatever murky past these
files were split into separate files.


# 116375 15-Jun-2003 davidxu

P_THREADED was renamed to P_SA, follow up.


# 114996 14-May-2003 jhb

s/procsig/sigacts/ to catch up to procsig and sigacts changes in the kernel.

Approved by: re (scottl)


# 114990 14-May-2003 peter

Bandaid for world. jhb gets the pointy hat here and he needs to look at
this.

Approved by: re (scottl)


# 113340 10-Apr-2003 julian

Catch up with the kernel. Move the current cpu indicator to the thread.


# 112923 01-Apr-2003 jeff

- Spell SIGSETOR correctly.


# 112891 31-Mar-2003 jeff

- Catch up with kernel signal changes.


# 112204 13-Mar-2003 jhb

Catch up to p_tracep -> p_tracevp rename to unbreak world.

Pointy hat to: jhb


# 111585 27-Feb-2003 julian

Change the process flags P_KSES to be P_THREADED.
This is just a cosmetic change but I've been meaning to do it for about a year.


# 104388 02-Oct-2002 jhb

Catch up to SMTX -> SLOCK changes.


# 104307 01-Oct-2002 jmallett

Ressurect libkvm use of the bitmasked signal list in the kernel, now that
reliable signal queues are gone.


# 104248 30-Sep-2002 jmallett

Fix typo, should zero the kinfo_proc's siglist, not the real one's - the real
one doesn't have one.

Submitted by: jake, scottl
Big pointed hat that lands one in the badcommitters box to: jmallett


# 104243 30-Sep-2002 jmallett

The list of queued signals is not, can not, and will not be exported to the
userland. If someone wants to implement a backup p_siglist in the kernel
for compatability and to export one could. For now, just tell KVM to hand
an empty signal set off to the userland.


# 103385 16-Sep-2002 bde

Fixed messes involving $FreeBSD$ starting with one left in the copyright
after adding __FBSDID().

Garbage-collected kvm_readswap(). This was once used by kvm_uread(), but
kvm_uread() now just reads /proc/<pid>/mem and procfs hopefully handles
swapped out pages.


# 103367 15-Sep-2002 julian

Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.
next step is to allow > 1 to be allocated per process. This would give
multi-processor threads. (when the rest of the infrastructure is
in place)

While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc
are diverging more than they should.. corrective action needed soon.


# 103216 11-Sep-2002 julian

Completely redo thread states.

Reviewed by: davidxu@freebsd.org


# 102594 30-Aug-2002 peter

Hopefully unbreak world. ke_slptime is gone. It should really have been
looking at p_ksegrp.kg_slptime anyway.


# 102538 28-Aug-2002 alfred

Allow one to grab the definition of struct ucred by defining _WANT_UCRED
instead of forcing _KERNEL.

Move the include of sys/_label.h in ucred.h under the
_KERNEL || _WANT_UCRED case.


# 102350 24-Aug-2002 kris

&x is not a format string


# 101968 16-Aug-2002 alfred

Hide 'struct ucred' behind '#ifdef _KERNEL', this should stop userland
from attempting to use it for good. There is a catch, kvm_proc.c needs
to '#define _KERNEL' to get at the ucred.

Requested by: rwatson


# 99157 30-Jun-2002 julian

Don't even read in the thread if it is a zombie process.


# 99142 30-Jun-2002 julian

grow a brain and do this right.


# 99128 30-Jun-2002 julian

Don't follow non existant thread pointers (e.g. for zombies)


# 99072 29-Jun-2002 julian

Part 1 of KSE-III

The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)

Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)

NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..


# 94028 07-Apr-2002 dd

Fix (for the second time) kvm_getprocs() for the case where no
processes match the given criteria. Since revision 1.60 of malloc.c,
malloc() and friends return an invalid pointer when given a size of 0.
kvm_getprocs() uses sysctl() with a NULL oldp argument to get an
initial size, but does not check whether it's 0 before passing it to
realloc() (via _kvm_realloc()). Before the aforementioned malloc()
change, this resulted in a minimal allocation made and a valid poitner
returned, but now results in an invalid, but non-NULL, pointer being
returned. When this is passed to sysctl(), the latter returns EFAULT
(as it should).


# 92913 21-Mar-2002 obrien

Remove 'register' keyword.


# 91075 22-Feb-2002 green

Also blindly attempt to fix broken world with respect to proc.p_runtime
changes.


# 90592 12-Feb-2002 julian

I THINK this fixes 'make world'
I'll know as soon as I re-import it and compile it.. :-)
There is no longer a 'pri' strict in the proc struct.
the fields are scattered between the ksegrp and thread in question.


# 90360 07-Feb-2002 julian

pre-emptively fix a KSE/M3 problem.

Make a slight change so that libkvm reaches the main thread via the
linked list, rather than assuming it is in the proc structure. Both
conditions are true in -current but only the first will be true in
the KSE M3 world.


# 86179 07-Nov-2001 peter

kern.ps_arg_max_cache is a long, not an int. I believe this is half of
what broke ps on ia64. It probably also broke on alpha, but the fallback
method of using lseek/read on /proc/*/mem to read ps_strings seems to
work there. It doesn't on ia64 yet.


# 84768 10-Oct-2001 bde

Compensate for "Compensate for header dethreading" by backing it out.


# 83551 16-Sep-2001 dillon

Implement __FBSDID()


# 83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# 82266 24-Aug-2001 peter

Make ps -M corefile work again. This has been broken for quite some time.
kvm_proclist() was aborting when it saw the ithreads with no pgrp.


# 77183 25-May-2001 rwatson

o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.

Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit


# 76243 03-May-2001 dwmalone

Avoid dividing by zero if kd->procbase->ki_structsize is uninitalised.
(I'm testing the numerator rather than the denominator, which looks
weird, but is the right thing to do here).


# 76182 01-May-2001 dwmalone

Don't give a warning about "proc size mismatch" if no struct were
returned. (This arose on a list about a month ago when someone
found bogus warnings if they used "ps -Uuser_with_no_processes".)

Approved by: mckusick


# 76176 01-May-2001 markm

Compensate for header dethreading.


# 72377 11-Feb-2001 jake

Catch up to new priority interface.


# 71577 24-Jan-2001 jhb

Add a new item to kinfo_proc: ki_sflag to mirror p_sflag.


# 71289 20-Jan-2001 wollman

Revert rev. 1.27. This file only included <sys/select.h> because of
brokenness introduced in <sys/select.h> rev. 1.8 which is now OBE.
<sys/tty.h> and <sys/selinfo.h> together do the right thing.


# 70525 30-Dec-2000 ben

Use macro API to <sys/queue.h>


# 69896 12-Dec-2000 mckusick

Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather
only scalar values and structures that are already part of the
kernel/user interface, specifically rusage and rtprio. It no
longer contains proc, session, pcred, ucred, procsig, vmspace,
pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
any of these changed in size, ps, w, fstat, gcore, systat, and
top would all stop working. The new structure has over 200 bytes
of unassigned space for future values to be added, yet is nearly
100 bytes smaller per entry than the structure that it replaced.


# 64297 06-Aug-2000 green

Good, fixing the header showed incorrect usage of it! #define _KERNEL
here for the include of sys/select.h.


# 58642 26-Mar-2000 obrien

-Wall, which caught a real bug where buflen wasn't being set properly.


# 55127 27-Dec-1999 peter

Use kldsym(2) to lookup symbol values. This avoids the kvm_mkdb juggling
and is module aware. Yes, this means that kvm_nlist(3) will find symbols
in loaded modules. The emulation of the nlist struct is pretty crude but
seems to work well enough for all the users in the tree that I found.


# 53239 16-Nov-1999 phk

Introduce commandline caching in the kernel.

This fixes some nasty procfs problems for SMP, makes ps(1) run much faster,
and makes ps(1) even less dependent on /proc which will aid chroot and
jails alike.

To disable this facility and revert to previous behaviour:
sysctl -w kern.ps_arg_cache_limit=0

For full details see the current@FreeBSD.org mail-archives.


# 41880 16-Dec-1998 bde

Adjust for kern.ps_strings and PS_STRINGS not being a pointer. This
fixes a type mismatch in the call to kvm_uread(). The bug has gone
undetected for almost 3 years because kvm_uproc()'s protoype has been
disabled for almost 4 years.

Trust sysctlbyname() to work properly if it succeeds.

Fixed style bugs in revs. 1.19 and 1.22.


# 40268 12-Oct-1998 des

Avoid the "Cannot allocate memory" problem that appears on heavily
loaded systems by retrying the sysctl() with a larger buffer if it
fails with ENOMEM. For good measure, allocate 10% more memory than
sysctl() claims is necessary.

PR: 8275
Reviewed by: David Greenman <dg@freebsd.org>


# 39327 16-Sep-1998 imp

Replace memory leaking instances of realloc with non-leaking reallocf.
In some cases replace if (a == null) a = malloc(x); else a =
realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is
guaranteed to be the same thing.

I've been running these on my system here w/o ill effects for some
time. However, the CTM-express is at part 6 of 34 for the CAM
changes, so I've not been able to do a build world with the CAM in the
tree with these changes. Shouldn't impact anything, but...


# 38534 25-Aug-1998 dfr

The length argument to sysctl is now size_t.


# 37316 30-Jun-1998 phk

Allow /dev/null as path for the "/dev/mem" file, and assume that people
know what they're doing if they do that. This will allow ps to use
the kvm_proc.c bits without having access to /dev/mem.

Fix kvm_proc.c to not need /dev/mem for access to argv/envp


# 32568 16-Jan-1998 bde

Fixed bugs in the conversion of kvm to to use procfs in rev.1.3. All
are in kvm_uread():
- the setting of errno before checking it in the lseek() was lost.
- EOF handling was lost. kvm_uread() retried forever on EOF. EOF is
not really an error, but report it one as in rev.1.2.
- reporting of errno after a read error was lost.

Fixed style bugs in rev.1.3 and rev.1.12.

Not fixed: errno is not reported after lseek() failures.


# 26947 25-Jun-1997 tegge

Fill in parent process id when reading process information from a
memory dump. This fixes one of the problems noted in PR kern/3581.


# 17141 12-Jul-1996 jkh

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


# 16158 06-Jun-1996 phk

Pass correct length OID to kernel for KERN_PROC_ALL.


# 15533 02-May-1996 phk

NBPG -> PAGE_SIZE


# 14523 11-Mar-1996 hsu

From Lite2: proc and file LIST changes


# 14236 24-Feb-1996 peter

If the two recently added sysctl variables exist, use those rather than
the statically compiled PS_STRINGS and USRSTACK variables. This prevents
programs using setproctitle from coredumping if the kernel VM is increased,
and stops libkvm users (w, ps, etc) from needing to be recompiled if only
the VM layout changes.


# 13156 01-Jan-1996 peter

Extract the login name when doing a ps on a dead kernel.


# 12885 16-Dec-1995 peter

Cosmetic cleanup and documentation of kvm_argv.. Hopefully the flow of
the routine can be much more easily understood now... :-)


# 12682 09-Dec-1995 peter

Updates to read the extra indirection in ps_strings. Note that any
static executables that depend on this will need to be relinked (ie: do
this before 'ps'), but the dynamic linked stuff should be OK (ie: 'w')

Obtained from: NetBSD (not much point reinventing the wheel.. :-)


# 8870 30-May-1995 rgrimes

Remove trailing whitespace.


# 7166 19-Mar-1995 joerg

Cast the offset of one call to lseek() to off_t, as it's already done
in all other places here.

This is a hack, the interface should be changed to use off_t's
everywhere around, but this will require to update all the programs
that happen to use libkvm.


# 6683 24-Feb-1995 phk

Remove some unused variables and fix two blatant core dump triggers.


# 4095 02-Nov-1994 dg

Fix from Gary Jennejohn - use 'cp' not 'buf' in read call. Oops.


# 3477 09-Oct-1994 sos

Added spare space on the usr stack. Used in ibcs2 emulation.


# 2029 11-Aug-1994 dg

Made kvm routines use procfs to get out process data such as argument
strings.


# 1603 28-May-1994 rgrimes

Fix kvm_i386.c just enough to make it compile and return lots of errors
when called. Noop out swapread in kvm_proc.c as our vm system is
different.


# 1574 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1573,
which included commits to RCS files with non-trunk default branches.


# 1573 27-May-1994 rgrimes

BSD 4.4 Lite Lib Sources