History log of /freebsd-current/lib/libkvm/kvm_getswapinfo.c
Revision Date Author Comments
# a2f733ab 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

lib: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 34e2051f 17-Feb-2020 Mark Johnston <markj@FreeBSD.org>

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


# 6bff85ff 10-May-2018 Dag-Erling Smørgrav <des@FreeBSD.org>

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


# 5e53a4f9 25-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# eca80cd0 02-Jan-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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


# 7f911abe 27-Nov-2015 John Baldwin <jhb@FreeBSD.org>

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


# 9789cd30 26-Nov-2015 John Baldwin <jhb@FreeBSD.org>

Remove trailing whitespace.


# c10970dd 23-Jan-2011 Ulrich Spörlein <uqs@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# e8865caf 07-Feb-2007 John Baldwin <jhb@FreeBSD.org>

- 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


# 9e749cc9 31-Jul-2004 Warner Losh <imp@FreeBSD.org>

Expand the license referenced indirectly inline.


# b8c60991 31-Jul-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove various unused variables, prototypes and local variables.


# 5d6fec5b 31-Jul-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Disable and lobotomize the kvm image reading swapinfo code, the kernel
layout is about to change.

The sysctl based method still returns correct information.


# 5243b679 31-Jul-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Retire the SWIF_DUMP_TREE code, this is in the way for a rework of
the swap_pager layout.


# a8818ec9 31-Jul-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Unifdef -UDEBUG_SWAPINFO The kernel data structures are about to change.


# 57e6d29b 10-Jan-2003 Matthew Dillon <dillon@FreeBSD.org>

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


# 42c43e60 03-Jan-2003 Poul-Henning Kamp <phk@FreeBSD.org>

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.


# 6eabd845 10-Oct-2001 Bruce Evans <bde@FreeBSD.org>

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


# e67f5b9f 16-Sep-2001 Matthew Dillon <dillon@FreeBSD.org>

Implement __FBSDID()


# e04a7c4a 01-Jun-2001 Thomas Moestl <tmm@FreeBSD.org>

Change this to support the new way swap device information is exported
via sysctl, and clean up some style and (size_t != int) issues.


# 82633431 01-May-2001 Mark Murray <markm@FreeBSD.org>

Compensate for header dethreading.


# ae3a37ad 23-Feb-2001 Robert Watson <rwatson@FreeBSD.org>

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


# 1a37aa56 09-Dec-2000 David E. O'Brien <obrien@FreeBSD.org>

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# b217bcfe 30-Nov-2000 Alfred Perlstein <alfred@FreeBSD.org>

remove unneded sys/ucred.h include


# d707aa56 16-Apr-2000 Jonathan Lemon <jlemon@FreeBSD.org>

Remove unneeded #include


# b7875890 26-Mar-2000 David E. O'Brien <obrien@FreeBSD.org>

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


# c4a7cdb3 27-Dec-1999 Peter Wemm <peter@FreeBSD.org>

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.


# c464420c 29-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Report swapdevices as cdevs rather than bdevs.

Remove unused dev2budev() function.


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# bf0e1ee3 11-May-1999 Peter Wemm <peter@FreeBSD.org>

Tidy up references to <sys/rlist.h> and support for the old swap management
that went away in January.


# bd54ec1e 14-Feb-1999 Dmitrij Tejblum <dt@FreeBSD.org>

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.


# f3401d0c 05-Feb-1999 Matthew Dillon <dillon@FreeBSD.org>

Handle case where no swap is configured


# 45908a6a 27-Jan-1999 Bruce Evans <bde@FreeBSD.org>

Removed evil typedef kvm_swap_t and all uses of it (not many).

Hoped for by: wollman


# 876c5c11 24-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Fix swap radix tree dump formatting ( pstat -ss ), it was printing the
wrong radix for recursive subnodes.


# a14dedd1 22-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Add SWIF_DEV_PREFIX flag to add "/dev/..." to device name.


# e92324a2 22-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Implement kvm_getswapinfo() libkvm function. Will be used by
pstat, top, and systat.