summaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_proc.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r200366Brooks Davis2009-12-181-1/+1
| | | | | | | | | Add a missing else that negated the truncation of ki_ngroups to NGROUPS. Submitted by: Dmitry Pryanishnikov <lynx dot ripe at gmail dot com> Notes: svn path=/stable/8/; revision=200662
* MFC r196990:Brooks Davis2009-09-241-1/+1
| | | | | | | | | | | | | | | | 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 Approved by: re@ (kib) Notes: svn path=/stable/8/; revision=197474
* Revert the changes to struct kinfo_proc in r194498. Instead, fillBrooks Davis2009-07-241-2/+8
| | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=195843
* Rework the credential code to support larger values of NGROUPS andBrooks Davis2009-06-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=194498
* MFp4:Bjoern A. Zeeb2008-11-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=185435
* - Don't inspect the P_SA flag. It's being removed.Jeff Roberson2008-03-121-7/+2
| | | | Notes: svn path=/head/; revision=177089
* Aparrently MACXOCOMLEN exisrts only on my machineJulian Elischer2007-10-261-1/+1
| | | | Notes: svn path=/head/; revision=173025
* Introduce a way to make pure kernal threads.Julian Elischer2007-10-261-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=173004
* - When using kvm use the new conversion method to derive swtime.Jeff Roberson2007-09-211-3/+16
| | | | | | | Approved by: re Notes: svn path=/head/; revision=172265
* - Move all of the PS_ flags into either p_flag or td_flags.Jeff Roberson2007-09-171-2/+2
| | | | | | | | | | | | | | | | | - 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) Notes: svn path=/head/; revision=172207
* - Work-around the already partially broken rusage support in kvm byJeff Roberson2007-06-011-0/+2
| | | | | | | | | completely disabling it until a full solution is agreed upon. Pointy hat to: me Notes: svn path=/head/; revision=170178
* Remove the advertising clause. UCB did this some time ago, but theseWarner Losh2007-01-081-4/+0
| | | | | | | | | files were never updated to reflect that. MFC After: 2 days Notes: svn path=/head/; revision=165888
* remove already commented out codeJulian Elischer2006-12-061-33/+0
| | | | Notes: svn path=/head/; revision=164938
* Make KSE a kernel option, turned on by default in all GENERICJohn Birrell2006-10-261-4/+4
| | | | | | | | | | kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@ Notes: svn path=/head/; revision=163709
* Rev. 1.44 of this file didn't introduce a right solution,Yaroslav Tykhiy2006-07-251-0/+7
| | | | | | | | | | 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) Notes: svn path=/head/; revision=160682
* Set ki_tdev to NODEV rather than NULL.Peter Wemm2005-06-241-1/+1
| | | | | | | Approved by: re Notes: svn path=/head/; revision=147567
* Make kvm(3) aware of ki_jid field.Pawel Jakub Dawidek2005-03-201-1/+17
| | | | | | | | Reviewed by: gad MFC after: 3 days Notes: svn path=/head/; revision=143871
* Dike out unwarranted reference to si_udev.Poul-Henning Kamp2005-03-151-0/+4
| | | | Notes: svn path=/head/; revision=143648
* In preparation to remove U areas, don't refer to p_uarea in libkvm.David Schultz2004-11-201-1/+1
| | | | | | | Reviewed by: arch@ Notes: svn path=/head/; revision=137907
* Remove un-needed call to close(2). The fd that close is beingChristian S.J. Peron2004-11-131-1/+0
| | | | | | | | | called on is invalid and has no use. Reviewed by: smkelly Notes: svn path=/head/; revision=137662
* Belatedly catch up with the dev_t/cdev changes from a few months back.Peter Wemm2004-10-111-1/+11
| | | | | | | | | | 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. Notes: svn path=/head/; revision=136402
* - Fix the compile to chase the p_rux changes.John Baldwin2004-10-061-1/+7
| | | | | | | | | | - 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) Notes: svn path=/head/; revision=136195
* Refactor a bunch of scheduler code to give basically the same behaviourJulian Elischer2004-09-051-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=134791
* Remove stale code protected by #ifdef sparc. GCC 3.4.x adds sparc toAlexander Kabaev2004-07-281-9/+0
| | | | | | | predefined symbols on all SPARC platforms and FreeBSD follows the crowd. Notes: svn path=/head/; revision=132756
* Fix a test of bit-flag "P_SA" by adding parenthesis around the expression.Garance A Drosehn2004-06-231-1/+1
| | | | | | | Submitted by: Cyrille Lefevre Notes: svn path=/head/; revision=130996
* Replace a call to strncpy() with a call to strlcpy()Garance A Drosehn2004-06-231-4/+2
| | | | | | | Submitted by: Cyrille Lefevre Notes: svn path=/head/; revision=130992
* Fill in the some new fields 'struct kinfo_proc', namely ki_childstime,Garance A Drosehn2004-06-191-5/+29
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=130728
* Second half of the dev_t cleanup.Poul-Henning Kamp2004-06-171-1/+1
| | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=130640
* This library has to change whenever the kernel process structure changes.Julian Elischer2004-06-161-1/+1
| | | | Notes: svn path=/head/; revision=130552
* Fix a warning: compare u_long ps_strings to 0 instead of NULL.Jens Schweikhardt2004-03-281-1/+1
| | | | Notes: svn path=/head/; revision=127518
* Teach kvm_getprocs() to recognize a sysctl flag for including threads.Daniel Eischen2004-02-221-5/+8
| | | | Notes: svn path=/head/; revision=126126
* Use the 3-component version of the KERN_PROC_PROC sysctl.Tim J. Robbins2003-09-271-2/+4
| | | | Notes: svn path=/head/; revision=120500
* Remove unnecssary <vm/swap_pager.h> includes.Poul-Henning Kamp2003-07-311-1/+0
| | | | | | | | These were probably not cleaned up back in whatever murky past these files were split into separate files. Notes: svn path=/head/; revision=118284
* P_THREADED was renamed to P_SA, follow up.David Xu2003-06-151-2/+2
| | | | Notes: svn path=/head/; revision=116375
* s/procsig/sigacts/ to catch up to procsig and sigacts changes in the kernel.John Baldwin2003-05-141-10/+6
| | | | | | | Approved by: re (scottl) Notes: svn path=/head/; revision=114996
* Bandaid for world. jhb gets the pointy hat here and he needs to look atPeter Wemm2003-05-141-0/+4
| | | | | | | | | this. Approved by: re (scottl) Notes: svn path=/head/; revision=114990
* Catch up with the kernel. Move the current cpu indicator to the thread.Julian Elischer2003-04-101-3/+1
| | | | Notes: svn path=/head/; revision=113340
* - Spell SIGSETOR correctly.Jeff Roberson2003-04-011-1/+1
| | | | Notes: svn path=/head/; revision=112923
* - Catch up with kernel signal changes.Jeff Roberson2003-03-311-1/+2
| | | | Notes: svn path=/head/; revision=112891
* Catch up to p_tracep -> p_tracevp rename to unbreak world.John Baldwin2003-03-131-1/+1
| | | | | | | Pointy hat to: jhb Notes: svn path=/head/; revision=112204
* Change the process flags P_KSES to be P_THREADED.Julian Elischer2003-02-271-2/+2
| | | | | | | This is just a cosmetic change but I've been meaning to do it for about a year. Notes: svn path=/head/; revision=111585
* Catch up to SMTX -> SLOCK changes.John Baldwin2002-10-021-7/+7
| | | | Notes: svn path=/head/; revision=104388
* Ressurect libkvm use of the bitmasked signal list in the kernel, now thatJuli Mallett2002-10-011-7/+1
| | | | | | | reliable signal queues are gone. Notes: svn path=/head/; revision=104307
* Fix typo, should zero the kinfo_proc's siglist, not the real one's - the realJuli Mallett2002-10-011-1/+1
| | | | | | | | | | one doesn't have one. Submitted by: jake, scottl Big pointed hat that lands one in the badcommitters box to: jmallett Notes: svn path=/head/; revision=104248
* The list of queued signals is not, can not, and will not be exported to theJuli Mallett2002-09-301-1/+7
| | | | | | | | | 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. Notes: svn path=/head/; revision=104243
* Fixed messes involving $FreeBSD$ starting with one left in the copyrightBruce Evans2002-09-161-21/+5
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=103385
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.Julian Elischer2002-09-151-12/+45
| | | | | | | | | | | | 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. Notes: svn path=/head/; revision=103367
* Completely redo thread states.Julian Elischer2002-09-111-21/+24
| | | | | | | Reviewed by: davidxu@freebsd.org Notes: svn path=/head/; revision=103216
* Hopefully unbreak world. ke_slptime is gone. It should really have beenPeter Wemm2002-08-301-1/+1
| | | | | | | looking at p_ksegrp.kg_slptime anyway. Notes: svn path=/head/; revision=102594
* Allow one to grab the definition of struct ucred by defining _WANT_UCREDAlfred Perlstein2002-08-281-2/+1
| | | | | | | | | | instead of forcing _KERNEL. Move the include of sys/_label.h in ucred.h under the _KERNEL || _WANT_UCRED case. Notes: svn path=/head/; revision=102538