aboutsummaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_getswapinfo.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove swblk_t.Mark Johnston2020-02-171-4/+2
| | | | | | | | | | | | | | | | | | | It was used only to store the bounds of each swap device. However, since swblk_t is a signed 32-bit int and daddr_t is a signed 64-bit int, swp_pager_isondev() may return an invalid result if swap devices are repeatedly added and removed and sw_end for a device ends up becoming a negative number. Note that the removed comment about maximum swap size still applies. Reviewed by: jeff, kib Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23666 Notes: svn path=/head/; revision=358026
* Reduce <sys/queue.h> pollution.Dag-Erling Smørgrav2018-05-111-0/+1
| | | | | | | | | | | | While <sys/sysctl.h> includes <sys/queue.h> unconditionally, it is only actually used in code which is conditional on _KERNEL. Make the #include itself conditional as well, and fix userland code that uses <sys/queue.h> for other purposes but relied on <sys/sysctl.h> to bring it in. MFC after: 1 week Notes: svn path=/head/; revision=333475
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-261-1/+3
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326219
* libkvm - extend a bit the swap statistics field.Pedro F. Giffuni2017-01-021-2/+4
| | | | | | | | | | | Change ksw_used and ksw_total to unsigned, which increases the maximum total swap that can be displayed properly from ~8TB to ~16TB. Obtained from: DragonflyBSD (ecc2e461) MFC after: 2 weeks Notes: svn path=/head/; revision=311101
* Add support to libkvm for reading vmcores from other architectures.John Baldwin2015-11-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add a kvaddr_type to represent kernel virtual addresses instead of unsigned long. - Add a struct kvm_nlist which is a stripped down version of struct nlist that uses kvaddr_t for n_value. - Add a kvm_native() routine that returns true if an open kvm descriptor is for a native kernel and memory image. - Add a kvm_open2() function similar to kvm_openfiles(). It drops the unused 'swapfile' argument and adds a new function pointer argument for a symbol resolving function. Native kernels still use _fdnlist() from libc to resolve symbols if a resolver function is not supplied, but cross kernels require a resolver. - Add a kvm_nlist2() function similar to kvm_nlist() except that it uses struct kvm_nlist instead of struct nlist. - Add a kvm_read2() function similar to kvm_read() except that it uses kvaddr_t instead of unsigned long for the kernel virtual address. - Add a new kvm_arch switch of routines needed by a vmcore backend. Each backend is responsible for implementing kvm_read2() for a given vmcore format. - Use libelf to read headers from ELF kernels and cores (except for powerpc cores). - Add internal helper routines for the common page offset hash table used by the minidump backends. - Port all of the existing kvm backends to implement a kvm_arch switch and to be cross-friendly by using private constants instead of ones that vary by platform (e.g. PAGE_SIZE). Static assertions are present when a given backend is compiled natively to ensure the private constants match the real ones. - Enable all of the existing vmcore backends on all platforms. This means that libkvm on any platform should be able to perform KVA translation and read data from a vmcore of any platform. Tested on: amd64, i386, sparc64 (marius) Differential Revision: https://reviews.freebsd.org/D3341 Notes: svn path=/head/; revision=291406
* Remove trailing whitespace.John Baldwin2015-11-261-3/+3
| | | | Notes: svn path=/head/; revision=291372
* libkvm code janitoringUlrich Spörlein2011-01-231-30/+14
| | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=217744
* - Move 'struct swdevt' back into swap_pager.h and expose it to userland.John Baldwin2007-02-071-5/+94
| | | | | | | | | | | - Restore support for fetching swap information from crash dumps via kvm_get_swapinfo(3) to fix pstat -T/-s on crash dumps. Reviewed by: arch@, phk MFC after: 1 week Notes: svn path=/head/; revision=166550
* Expand the license referenced indirectly inline.Warner Losh2004-07-311-3/+20
| | | | Notes: svn path=/head/; revision=132935
* Remove various unused variables, prototypes and local variables.Poul-Henning Kamp2003-07-311-25/+0
| | | | Notes: svn path=/head/; revision=118283
* Disable and lobotomize the kvm image reading swapinfo code, the kernelPoul-Henning Kamp2003-07-311-125/+1
| | | | | | | | | layout is about to change. The sysctl based method still returns correct information. Notes: svn path=/head/; revision=118282
* Retire the SWIF_DUMP_TREE code, this is in the way for a rework ofPoul-Henning Kamp2003-07-311-190/+0
| | | | | | | the swap_pager layout. Notes: svn path=/head/; revision=118280
* Unifdef -UDEBUG_SWAPINFO The kernel data structures are about to change.Poul-Henning Kamp2003-07-311-79/+0
| | | | Notes: svn path=/head/; revision=118276
* Remove all use of the LOG2() macro/inline, undoing some non-optimal cruftMatthew Dillon2003-01-111-2/+2
| | | | | | | | | | that crept in recently. GCC will optimize the divides and multiplies for us. Submitted by: David Schultz <dschultz@uclink.Berkeley.EDU> MFC after: 1 day Notes: svn path=/head/; revision=109086
* Make struct swblock kernel only, to make vm/swap_pager.h userland includable.Poul-Henning Kamp2003-01-031-1/+1
| | | | | | | | Move struct swdevt from sys/conf.h to the more appropriate vm/swap_pager.h. Adjust #include use in libkvm and pstat(8) to match. Notes: svn path=/head/; revision=108602
* Compensate for "Compensate for header dethreading" by backing it out.Bruce Evans2001-10-101-2/+0
| | | | Notes: svn path=/head/; revision=84768
* Implement __FBSDID()Matthew Dillon2001-09-161-10/+2
| | | | Notes: svn path=/head/; revision=83551
* Change this to support the new way swap device information is exportedThomas Moestl2001-06-011-77/+66
| | | | | | | via sysctl, and clean up some style and (size_t != int) issues. Notes: svn path=/head/; revision=77605
* Compensate for header dethreading.Mark Murray2001-05-011-0/+2
| | | | Notes: svn path=/head/; revision=76176
* Adapt libkvm_getswapinfo() to make use of recently committed vm and swapRobert Watson2001-02-231-60/+254
| | | | | | | | | | | | | | | | | | | sysctls exporting swap information. When running on a live kernel, the sysctl's will now be used instead of kvm_read, allowing consumers of this interface to run without privilege (setgid kmem). Retain the ability to run on coredumps, or on a kernel using kmem if explicitly pointed at one. A side effect of this change is that kvm_getswapinfo() is faster now in the general case. If the SWIF_DUMP_TREE flag is given (pstat -ss does this), the radix tree walker, which still uses kvm_read in any case, is invoked, and therefore does require privilege. Submitted by: Thomas Moestl <tmoestl@gmx.net> Reviewed by: freebsd-audit Notes: svn path=/head/; revision=72950
* Add `_PATH_DEVZERO'.David E. O'Brien2000-12-091-1/+2
| | | | | | | Use _PATH_* where where possible. Notes: svn path=/head/; revision=69793
* remove unneded sys/ucred.h includeAlfred Perlstein2000-11-301-1/+0
| | | | Notes: svn path=/head/; revision=69396
* Remove unneeded #includeJonathan Lemon2000-04-161-1/+0
| | | | Notes: svn path=/head/; revision=59286
* -Wall, which caught a real bug where buflen wasn't being set properly.David E. O'Brien2000-03-271-8/+4
| | | | Notes: svn path=/head/; revision=58642
* Use kldsym(2) to lookup symbol values. This avoids the kvm_mkdb jugglingPeter Wemm1999-12-271-1/+0
| | | | | | | | | 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. Notes: svn path=/head/; revision=55127
* Report swapdevices as cdevs rather than bdevs.Poul-Henning Kamp1999-11-291-1/+1
| | | | | | | Remove unused dev2budev() function. Notes: svn path=/head/; revision=53899
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Tidy up references to <sys/rlist.h> and support for the old swap managementPeter Wemm1999-05-111-88/+9
| | | | | | | that went away in January. Notes: svn path=/head/; revision=47018
* From rev. 1.12 of usr.sbin/pstat/pstat.c by phk:Dmitrij Tejblum1999-02-141-3/+6
| | | | | | | | Reflect the fact that we do not swap on the first <dmmax> blocks of a swapdev, to protect disklabels and other such magic stuff. Notes: svn path=/head/; revision=44021
* Handle case where no swap is configuredMatthew Dillon1999-02-061-3/+10
| | | | Notes: svn path=/head/; revision=43696
* Removed evil typedef kvm_swap_t and all uses of it (not many).Bruce Evans1999-01-271-6/+8
| | | | | | | Hoped for by: wollman Notes: svn path=/head/; revision=43282
* Fix swap radix tree dump formatting ( pstat -ss ), it was printing theMatthew Dillon1999-01-251-4/+4
| | | | | | | wrong radix for recursive subnodes. Notes: svn path=/head/; revision=43173
* Add SWIF_DEV_PREFIX flag to add "/dev/..." to device name.Matthew Dillon1999-01-221-2/+3
| | | | Notes: svn path=/head/; revision=43048
* Implement kvm_getswapinfo() libkvm function. Will be used byMatthew Dillon1999-01-221-0/+486
pstat, top, and systat. Notes: svn path=/head/; revision=43045