Page MenuHomeFreeBSD

D51396.id158708.diff
No OneTemporary

D51396.id158708.diff

diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
--- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
+++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
@@ -20,7 +20,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 16, 2025
+.Dd July 17, 2025
.Dt DTRACE 1
.Os
.Sh NAME
@@ -1269,6 +1269,7 @@
.Xr cpp 1 ,
.Xr dwatch 1 ,
.Xr dtrace_audit 4 ,
+.Xr dtrace_dtmalloc 4 ,
.Xr dtrace_dtrace 4 ,
.Xr dtrace_fbt 4 ,
.Xr dtrace_io 4 ,
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -979,6 +979,7 @@
.if ${MK_CDDL} != "no"
_dtrace_provs= dtrace_audit.4 \
+ dtrace_dtmalloc.4 \
dtrace_dtrace.4 \
dtrace_fbt.4 \
dtrace_io.4 \
diff --git a/share/man/man4/dtrace_dtmalloc.4 b/share/man/man4/dtrace_dtmalloc.4
new file mode 100644
--- /dev/null
+++ b/share/man/man4/dtrace_dtmalloc.4
@@ -0,0 +1,103 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Mateusz Piotrowski <0mp@FreeBSD.org>
+.\"
+.Dd July 17, 2025
+.Dt DTRACE_DTMALLOC 4
+.Os
+.Sh NAME
+.Nm dtrace_dtmalloc
+.Nd a DTrace provider for tracing malloc(9) kernel memory allocations by type
+.Sh SYNOPSIS
+.Nm dtmalloc Ns Cm :: Ns Ar function Ns Cm :malloc
+.Nm dtmalloc Ns Cm :: Ns Ar function Ns Cm :free
+.Sh DESCRIPTION
+The
+.Nm dtmalloc
+provider allows for tracing
+memory allocations by type by intrumenting
+.Xr malloc 9
+and
+.Xr free 9
+kernel functions.
+.Pp
+The
+.Nm dtmalloc Ns Cm :: Ns Ar function Ns Cm :malloc
+probe fires upon a successful allocation.
+Its probe arguments are:
+.Bl -column -offset indent "malloc Probe Argument" "Definition"
+.It Sy malloc Probe Argument Ta Sy Definition
+.It Fa args[0] Ta Ft struct malloc_type *mtp
+.It Fa args[1] Ta Ft struct malloc_type_internal *mtip
+.It Fa args[2] Ta Ft struct malloc_type_stats *mtsp
+.It Fa args[3] Ta Ft unsigned long size
+.It Fa args[4] Ta Ft int zindx
+.El
+.Pp
+The
+.Nm dtmalloc Ns Cm :: Ns Ar function Ns Cm :free
+probe fires upon a free operation.
+Its probe arguments are:
+.Bl -column -offset indent "free Probe Argument" "Definition"
+.It Sy free Probe Argument Ta Sy Definition
+.It Fa args[0] Ta Ft struct malloc_type *mtp
+.It Fa args[1] Ta Ft struct malloc_type_internal *mtip
+.It Fa args[2] Ta Ft struct malloc_type_stats *mtsp
+.It Fa args[3] Ta Ft unsigned long size
+.It Fa args[4] Ta Always 0
+.El
+.Sh IMPLEMENTATION NOTES
+The
+.Ar function
+part of the probe description in the
+.Nm dtmalloc
+provider is the
+.Xr malloc 9
+type short description with all whitespace characters replaced
+with underscores.
+.Sh FILES
+.Bl -tag -width "<sys/malloc.h>"
+.It In sys/malloc.h
+The header where
+.Vt struct malloc_type
+is defined.
+.El
+.Sh EXAMPLES
+.Ss Example 1 : Counting Successful Memory Allocations by Type
+.Bd -literal -offset 2n
+# dtrace -n 'dtmalloc:::malloc {@[stringof args[0]->ks_shortdesc] = count()}'
+Password:
+dtrace: description 'dtmalloc:::malloc ' matched 480 probes
+^C
+ 80211node 1
+ CAM CCB 1
+ CAM periph 1
+ ioctlops 1
+ netlink 1
+ soname 4
+ sysctltmp 4
+ solaris 5
+ acpica 16
+ temp 36
+ lkpikmalloc 44
+ iov 100
+ selfd 648
+.Ed
+.Sh SEE ALSO
+.Xr dtrace 1 ,
+.Xr tracing 7 ,
+.Xr malloc 9
+.Sh AUTHORS
+.An -nosplit
+.Nm
+was written by
+.An John Birrell Aq Mt jb@FreeBSD.org .
+This manual page was written by
+.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org .
+.Sh CAVEATS
+The
+.Nm dtmalloc
+provider does not instrument
+.Xr UMA 9
+allocations.
diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9
--- a/share/man/man9/malloc.9
+++ b/share/man/man9/malloc.9
@@ -28,7 +28,7 @@
.\"
.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
.\"
-.Dd August 4, 2024
+.Dd July 17, 2025
.Dt MALLOC 9
.Os
.Sh NAME
@@ -394,6 +394,7 @@
Failing consistency checks will cause a panic or a system console
message.
.Sh SEE ALSO
+.Xr dtrace_dtmalloc 4 ,
.Xr numa 4 ,
.Xr vmstat 8 ,
.Xr contigmalloc 9 ,

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 8, 6:36 PM (13 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28484766
Default Alt Text
D51396.id158708.diff (4 KB)

Event Timeline