Commit Graph

34 Commits

Author SHA1 Message Date
markj
0a959e0bae Remove swblk_t.
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
2020-02-17 15:11:07 +00:00
des
58d2db41a5 Reduce <sys/queue.h> pollution.
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
2018-05-11 00:01:43 +00:00
pfg
260ba0bff1 lib: further adoption of SPDX licensing ID tags.
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.
2017-11-26 02:00:33 +00:00
pfg
0955860a29 libkvm - extend a bit the swap statistics field.
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
2017-01-02 15:12:11 +00:00
jhb
ab35544b83 Add support to libkvm for reading vmcores from other architectures.
- 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
2015-11-27 18:58:26 +00:00
jhb
795417cba0 Remove trailing whitespace. 2015-11-26 19:42:10 +00:00
uqs
7fdf187c11 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
2011-01-23 11:08:28 +00:00
jhb
9c764c7fc3 - Move 'struct swdevt' back into swap_pager.h and expose it to userland.
- 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
2007-02-07 17:43:11 +00:00
imp
4f59933abf Expand the license referenced indirectly inline. 2004-07-31 18:49:53 +00:00
phk
065d723b50 Remove various unused variables, prototypes and local variables. 2003-07-31 21:42:12 +00:00
phk
f51993282f Disable and lobotomize the kvm image reading swapinfo code, the kernel
layout is about to change.

The sysctl based method still returns correct information.
2003-07-31 21:38:32 +00:00
phk
5a8eb87c5a Retire the SWIF_DUMP_TREE code, this is in the way for a rework of
the swap_pager layout.
2003-07-31 21:30:28 +00:00
phk
2ba1b34bc1 Unifdef -UDEBUG_SWAPINFO The kernel data structures are about to change. 2003-07-31 20:53:04 +00:00
dillon
7060fb8de0 Remove all use of the LOG2() macro/inline, undoing some non-optimal cruft
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
2003-01-11 01:09:51 +00:00
phk
b884c995db Make struct swblock kernel only, to make vm/swap_pager.h userland includable.
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.
2003-01-03 16:23:12 +00:00
bde
229c3ac7c3 Compensate for "Compensate for header dethreading" by backing it out. 2001-10-10 17:48:44 +00:00
dillon
41abc6d4e4 Implement __FBSDID() 2001-09-16 21:35:07 +00:00
tmm
6e0384074f Change this to support the new way swap device information is exported
via sysctl, and clean up some style and (size_t != int) issues.
2001-06-01 22:57:07 +00:00
markm
ddbd7bc718 Compensate for header dethreading. 2001-05-01 09:24:15 +00:00
rwatson
78bbdcc2c4 Adapt libkvm_getswapinfo() to make use of recently committed vm and swap
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
2001-02-23 18:49:16 +00:00
obrien
c2ee1dcc02 Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.
2000-12-09 09:35:55 +00:00
alfred
71d563e06c remove unneded sys/ucred.h include 2000-11-30 18:34:08 +00:00
jlemon
68b8d52e43 Remove unneeded #include 2000-04-16 17:36:48 +00:00
obrien
cc06168002 -Wall, which caught a real bug where buflen wasn't being set properly. 2000-03-27 00:33:45 +00:00
peter
047fa82dd0 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.
1999-12-27 07:14:58 +00:00
phk
9809b71a89 Report swapdevices as cdevs rather than bdevs.
Remove unused dev2budev() function.
1999-11-29 21:37:18 +00:00
peter
76f0c923fe $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
peter
280d1557df Tidy up references to <sys/rlist.h> and support for the old swap management
that went away in January.
1999-05-11 14:32:18 +00:00
dt
9fb9019141 From rev. 1.12 of usr.sbin/pstat/pstat.c by phk:
Reflect the fact that we do not swap on the first <dmmax> blocks of a
swapdev, to protect disklabels and other such magic stuff.
1999-02-14 21:42:05 +00:00
dillon
4ddefa4315 Handle case where no swap is configured 1999-02-06 06:31:57 +00:00
bde
76aad88d08 Removed evil typedef kvm_swap_t and all uses of it (not many).
Hoped for by:	wollman
1999-01-27 11:29:15 +00:00
dillon
850c26db34 Fix swap radix tree dump formatting ( pstat -ss ), it was printing the
wrong radix for recursive subnodes.
1999-01-25 04:07:07 +00:00
dillon
34551cfe05 Add SWIF_DEV_PREFIX flag to add "/dev/..." to device name. 1999-01-22 10:57:03 +00:00
dillon
247543f77e Implement kvm_getswapinfo() libkvm function. Will be used by
pstat, top, and systat.
1999-01-22 10:36:04 +00:00