History log of /freebsd-current/lib/libmemstat/memstat_malloc.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


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

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\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


# bdcc2226 06-Nov-2020 Mateusz Guzik <mjg@FreeBSD.org>

malloc: move malloc_type_internal into malloc_type

According to code comments the original motivation was to allow for
malloc_type_internal changes without ABI breakage. This can be trivially
accomplished by providing spare fields and versioning the struct, as
implemented in the patch below.

The upshots are one less memory indirection on each alloc and disappearance
of mt_zone.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27104


# 828afdda 02-Nov-2020 Mateusz Guzik <mjg@FreeBSD.org>

malloc: export kernel zones instead of relying on them being power-of-2

Reviewed by: markj (previous version)
Differential Revision: https://reviews.freebsd.org/D27026


# f38828cb 11-Oct-2018 Mateusz Guzik <mjg@FreeBSD.org>

libmemstat: adjust for per-cpu stats after r338899

Reported by: yuripv
Reviewed by: kib, markj
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17490


# 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.


# 1882360b 01-Aug-2011 Sergey Kandaurov <pluknet@FreeBSD.org>

Get rid of MAXCPU knowledge used for internal needs only. Switch to
dynamic memory allocation to hold per-CPU memory types data (sized to
mp_maxid for UMA, and to mp_maxcpus for malloc to match the kernel).

That fixes libmemstat with arbitrary large MAXCPU values and therefore
eliminates MEMSTAT_ERROR_TOOMANYCPUS error type.

Reviewed by: jhb
Approved by: re (kib)


# 34e4a6f4 08-May-2011 Attilio Rao <attilio@FreeBSD.org>

Revert MAXCPU introduction. In userland it is always 1.

Noted by: marcel


# 1d221389 02-May-2011 Attilio Rao <attilio@FreeBSD.org>

Remove the redefinition of MEMSTAT_MAXCPU and just use MAXCPU for that.

Reviewed by: sbruno


# 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.


# 7293f0e6 15-May-2009 John Baldwin <jhb@FreeBSD.org>

Update the KVM backend for malloc stats to catch up to the internal structure
BI change from the addition of DTrace malloc(9) probes.

Submitted by: Ben Kelly ben of wanderview dot com


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

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


# 44803694 21-May-2007 Robert Watson <rwatson@FreeBSD.org>

Make pointer argument to kread_string() const since the kernel structure
field is const, and then employ __DECONST before getting into the kvm
code. This eliminates a gcc 4.2 warning about losing constification.

__DECONST advice from: sam


# ba23fa9b 06-Aug-2005 Robert Watson <rwatson@FreeBSD.org>

Teach libmemstat(3) how to extract malloc(9) statistics using kvm(3),
so that libmemstat can be used to view full memory statistics from
kernel core dumps and /dev/mem. This is provided via a new query
function, memstat_kvm_malloc(), which is also automatically invoked
by memstat_kvm_all(). A kvm handle must be passed in.

This will allow malloc(9)-specific code to be removed from vmstat(8).


# 22247a2a 01-Aug-2005 Robert Watson <rwatson@FreeBSD.org>

Correct two libmemstat(3) bugs:

- Move memory_type_list flushing logic from memstat_mtl_free() to
_memstat_mtl_empty(), a libmemstat-internal function that can
be called from other parts of the library. Invoke
_memstat_mtl_empty() from memstat_mtl_free(), which also frees
the containing list structure.

Invoke _memstat_mtl_empty() instead of memstat_mtl_free() in
various error cases in memstat_malloc.c and memstat_uma.c, which
previously resulted in the list being freed prematurely.

- Reverse the order of updating the mt_kegfree and mt_free fields
of the memory_type in memstat_uma.c, otherwise keg free items
won't be counted properly for non-secondary zones.

MFC after: 3 days


# 34562808 23-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

Introduce more formal error handling for libmemstat(3):

- Define a set of libmemstat(3) error constants, which are used by all
libmemstat(3) methods except for memstat_mtl_alloc(), which allocates
a memory type list and may return ENOMEM via errno.

- Define a per-memory_type_list current error value, which is set when a
call associated with a memory list fails. This requires wrapping a
structure around the queue(9) list head data structure, but this change
is not visible to libmemstat(3) consumers due to using access methods.

- Add a new accessor method, memstat_mtl_geterror() to retrieve the error
number.

- Consistently set the error number in a number of failure modes where
previously some combination of setting errno and printf'ing error
descriptions was used. libmemstat(3) will now no longer print to stdio
under any circumstances. Returns of NULL/-1 for errors remain the
same.

This avoids use of stdio, misuse of error numbers, and should make it
easier to program a libmemstat(3) consumer able to print useful error
messages. Currently, no error-to-string function is provided, as I'm
unsure how to address internationalization concerns.

MFC after: 1 day


# ddefbc89 23-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

Prefix two non-static libmemstat(3) internal functions with '_' symbols, to
try and discourage use outside the library.

Remove duplicate declaration of memstat_mtl_free() from memstat_internal.h,
as it's not internal, and the memstat.h definition suffices.


# 3ab4da68 15-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

Re-spell wronge less wrongly as wrong.

Submitted by: jkoshy
MFC after: 1 week


# 0cddce49 14-Jul-2005 Robert Watson <rwatson@FreeBSD.org>

Add libmemstat(3), a library for use by debugging and monitoring
applications in tracking kernel memory statistics. It provides an
abstracted interface to uma(9) and malloc(9) statistics, wrapped
around the recently added binary stream sysctls for the allocators.

Using this interface, it is easy to build monitoring tools, query
specific memory types for usage information, etc. Facilities are
provided for binding caller-provided data to memory types,
incremental updates of memory types, and queries that span multiple
allocators.

Support for additional allocators is (relatively) easy to add.

The API for libmemstat(3) will probably change some over time as
consumers are written, and requirements evolve. It is written to
avoid encoding ABIs for data structure layout into consuming
applications for this reason.

MFC after: 1 week