Commit Graph

90 Commits

Author SHA1 Message Date
dsl 7c166415e7 Remove the #include <sys/user.h> from all of libkvm.
sys/user.h is a stub that just #includes sys/pcb.h.
There are no 'struct pcb' anywhere in here, so I'm extremely doubtful
any of the builds will fail.
OTOH it might be relying on a header that pcb.h includes.
In any case i386 and amd64 build.
2014-02-19 20:21:22 +00:00
martin f8fdd418df Measure kinfo_proc2::p_vm_vsize in pages, as it was always documented.
This value seems to never have been used anywhere.
This makes it consistent with it's cousin p_vm_msize (which is in pages as
well and has several uses).
2012-06-05 08:23:05 +00:00
uebayasi 9a0d0defa9 Fix build. 2010-11-12 04:52:08 +00:00
jym 8bb0c87c7e Define KREAD() inside kvm_private.h, for reusability. 2010-09-26 22:28:05 +00:00
jym 962a341df6 Change kvm_pa2off() and kvm_kvatop() prototypes (private to kvm(3)):
-int     _kvm_kvatop(kvm_t *, u_long, u_long *);
-off_t   _kvm_pa2off(kvm_t *, u_long);
+int     _kvm_kvatop(kvm_t *, vaddr_t, paddr_t *);
+off_t   _kvm_pa2off(kvm_t *, paddr_t);

Basically, use vaddr_t for VA and paddr_t for PA. In addition, for variables
representing addresses, use paddr_t or vaddr_t, depending on the context.

For most arches, vaddr_t and paddr_t are equivalent to unsigned long. However,
the change was needed for exotic situations, like i386 PAE, were unsigned long
is not suitable for PA which are 64 bits long. As this required a complete
change of the function prototypes, all arches had to be adapted accordingly.

Core files from before this commit should still work with the new code; I did
not see any direct dependency between core's structure and kvatop/pa2off.

The change was compile tested for all arches, as it impacts all of them.

See also:

http://mail-index.netbsd.org/current-users/2010/09/07/msg014249.html
2010-09-20 23:23:16 +00:00
jym 6dc46b923b Ansify and KNF all functions within kvm(3). No objection on current-users@.
Used as ground for u_long => vaddr_t/paddr_t replacements in kvm(3)
private functions.

Compile tested for all arches. See also:

http://mail-index.netbsd.org/current-users/2010/09/07/msg014249.html
2010-09-19 02:07:00 +00:00
rmind 40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
yamt edde2bdd71 kvm_getprocs actually works with KVM_NO_FILES. 2009-05-16 11:56:47 +00:00
mrg fcc023545e - add new RLIMIT_AS (aka RLIMIT_VMEM) resource that limits the total
address space available to processes.  this limit exists in most other
modern unix variants, and like most of them, our defaults are unlimited.
remove the old mmap / rlimit.datasize hack.

- adds the VMCMD_STACK flag to all the stack-creation vmcmd callers.
it is currently unused, but was added a few years ago.

- add a pair of new process size values to kinfo_proc2{}. one is the
total size of the process memory map, and the other is the total size
adjusted for unused stack space (since most processes have a lot of
this...)

- patch sh, and csh to notice RLIMIT_AS.  (in some cases, the alias
RLIMIT_VMEM was already present and used if availble.)

- patch ps, top and systat to notice the new k_vm_vsize member of
kinfo_proc2{}.

- update irix, svr4, svr4_32, linux and osf1 emulations to support
this information.  (freebsd could be done, but that it's best left
as part of the full-update of compat/freebsd.)


this addresses PR 7897.  it also gives correct memory usage values,
which have never been entirely correct (since mmap), and have been
very incorrect since jemalloc() was enabled.

tested on i386 and sparc64, build tested on several other platforms.

thanks to many folks for feedback and testing but most espcially
chuq and yamt for critical suggestions that lead to this patch not
having a special ugliness i wasn't happy with anyway :-)
2009-03-29 01:02:48 +00:00
christos 7bf2b3b453 tdev is unsigned 2008-12-28 19:49:26 +00:00
christos 6127c68e1c cast dev_t's to int32_t because XXX: sysctl can't change size. This should
be not a problem since tty's live in the low part of the dev range.
2008-12-28 19:46:47 +00:00
cegger 83776b8eea check error case for kvm_getlwps or SIGSEGV occurs due to dereferecing a NULL pointer.
return NULL if there are no threads or proceed further through all loops.
Fixes PR 40004. Ok rmind@
2008-11-29 18:24:58 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
elad 5c80416b17 PR/37962: Andrew Doran: libkvm is busted due to kauth_cred redefinition
Sync structure with kernel version.
2008-02-05 15:56:01 +00:00
ad a7a2d171df Handle reading from raw disk devices. 2008-01-15 13:57:41 +00:00
yamt 392c2dc8c2 sync with kernel. 2007-12-22 01:22:03 +00:00
ad 8fd9a85c2a Catch up with scheduling changes in the kernel. 2007-11-06 01:46:08 +00:00
ad dea8adf74d 'true' is a C99 keyword. 2007-07-09 22:28:13 +00:00
christos 4fbeddc144 treat ESRCH as a soft error. From Anon Ymous 2007-07-07 18:27:26 +00:00
christos 1a4c3f68b4 - Fix kvm_getlwps not to spit errors if we lose the race:
- if the process does not exist anymore, return NULL
	- if the process has created more lwps retry
	XXX[1]: We should fix sysctl_kern_lwp() to return the number of lwps it
		needs in oldlenp when ENOMEM. The we can avoid calling sysctl
		twice (by starting let's say with always 1 lwp, or 10).
	XXX[2]: We should fix kvm_getlwps to never spit errors.
- Silence new lint warnings
2007-07-06 14:25:42 +00:00
christos 4be3505e2e fix for yamt-idlelwp 2007-05-17 21:42:32 +00:00
dsl 7effc1a79d Set kp2p->p_ru = 0 in the kproc2 structure.
It was only ever non-zero for zombies, and now doesn't exist.
The 'pstats' field has been valid for zombies for a while (it isn't in
the uarea any more).
Fixes part of build breakage.
2007-05-01 06:58:08 +00:00
christos 2a84b2c2c1 Revert the kauth_impl.h change. Elad is going to maintain this. Asked by core@ 2007-02-24 20:41:33 +00:00
dsl c8acc5992d Update only user code that uses the types of the e_[pu]cred members
of struct kinfo_proc.
2007-02-18 15:22:44 +00:00
ad 401499f30e Sync with kernel changes introduced by merging the newlock2 branch. 2007-02-09 22:08:48 +00:00
elad eb3ad821f0 PR/35506: Chuck Silvers: ps doesn't work on crash dumps, libkvm doesn't
know about kauth

Implemented _kvm_convertcred() to handle copying kauth_cred_t to userspace
and converting it to the appropriate 'struct eproc' members ('pcred' and
'ucred' respectively).

Okay mlelstv@.
2007-02-06 21:21:51 +00:00
chs f4850e655c fill in p_stat for crashdumps like the kernel does for the sysctl. 2007-01-28 21:31:13 +00:00
yamt daa6d99693 kvm_getproc2: retry on ENOMEM.
it happens when the number of processes are changed in the mean time.
2006-12-31 16:20:18 +00:00
yamt 060eacec48 #include a necessary header directly, rather than via user.h. 2006-05-11 12:00:20 +00:00
christos 0213791d0c 1. Eliminate some unnecessary to kvm_{m,re}alloc.
2. Don't malloc/free procbase/procbase2/lwpbase continuously. Keep track
   of the size, and only do it if necessary.
3. Write a macro to malloc/realloc and set the size of members so that it
   is done correctly. Previous open coded version in kvm_file.c always
   set the length, which is incorrect.
4. Remove bogus check against INT_MAX.
5. use NULL to initialize pointers instead of 0.
2006-02-16 20:48:42 +00:00
yamt 6cae8c8d70 as swap is now optional, ENXIO on /dev/drum is normal. 2005-07-30 16:32:29 +00:00
jmc 2c8974a914 Fix fallout from vm_anon changes 2005-05-11 17:41:52 +00:00
toshii ac142bbda7 Fix typos. 2004-05-12 17:20:01 +00:00
atatat 42d379d041 Use new PTRTOUINT64() macro instead of local PTRTOINT64() macro. 2004-02-19 03:57:56 +00:00
christos 895d7dee51 zero out nl, from Todd Miller. thanks! 2003-11-17 20:41:54 +00:00
wiz 37ac1db454 available, not avaliable. From miod@openbsd. 2003-09-29 09:50:21 +00:00
agc eb7c1594f1 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22280, verified by myself.
2003-08-07 16:42:00 +00:00
christos 9d952b3742 remove scanning of deadproc, since zombproc should contain all the processes
in deadproc according to the comment in kern_proc.c. deadproc is not a
struct proclist anymore, so it would require more work to scan anyway, and
this is unnecessary.
2003-03-28 14:01:32 +00:00
ross f80c89ab02 fix LP64 and other warnings 2003-03-20 22:53:12 +00:00
dsl 9be8ac5294 Alternative pid/proc allocater, removes all searches associated with pid
lookup and allocation, and any dependency on NPROC or MAXUSERS.
NO_PID changed to -1 (and renamed NO_PGID) to remove artificial limit
on PID_MAX.
As discussed on tech-kern.
2003-03-19 11:36:32 +00:00
atatat 40f3045957 Add p_svuid and p_svgid to kinfo_proc2. Populate them in the kernel
and in libkvm.  Then teach ps how to show them to you.

Also, teach ps how to show the names for all the uids, the rest of the
group numbers, and the "group access list".
2003-03-01 05:41:55 +00:00
enami b7577d634c Use _kvm_freeprocs() rather than free() so that kvm_close() won't
free already free'ed region.
2003-02-26 23:05:53 +00:00
enami 30fca248b5 Cosmetic changes. 2003-02-26 23:04:37 +00:00
christos 45103cd2c0 delint (unsigned long long) -> (unsigned long) casts. 2003-02-02 02:29:59 +00:00
thorpej c62a74e6d5 Merge the nathanw_sa branch. 2003-01-18 10:32:11 +00:00
jdolecek 10b43f7cd4 kvm_doargv2(): make sure the string ends with '\0'; sysctl() might not
properly end it if the data would be longer than the supplied
	buffer

This fixes lib/11467 by SAITOH Masanobu and lib/12389, maybe also
lib/12439.
2001-03-24 10:02:45 +00:00
jdolecek 233eee3634 Minor fix to kvm_doargv2() - if the kd->argv is reallocated, reinitialize
'ap' too. This doesn't seem to have any effect either way; seems like the
condition is never met?
2001-03-24 09:54:52 +00:00
jdolecek 38f7c1d48b adapt to latest struct proc, struct sigacts, struct sigctx changes 2000-12-22 23:11:19 +00:00
enami 3cc984aab8 Make this file compiles on alpha. 2000-10-05 03:21:01 +00:00
sommerfeld f9d3ae0fbb format-string audit cleanups 2000-10-04 16:11:27 +00:00