From nobody Fri Mar 11 10:07:59 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 68AC51A121B4; Fri, 11 Mar 2022 10:08:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KFM7g74WQz4kMc; Fri, 11 Mar 2022 10:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646993280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yqaBoKR1oTujkcyhZcn4iT+Jsx8wjnvM7uBKrBSbUL8=; b=d/5zsUyEJW70eiZZNJn4DqhSwzxIKXUs+4zPKqY9d9+A07GFJK411wRAutzpWDJh5kH5zf /oS1t8reMlN6MTChnHTIKN9QzNL94Q06+Y1wdxidj7qNANr4iCMOCPnhKtacgjLNfAfrCe Dw2I/mGIZ0+30/ykdwnDpVSMQ7Yif5ydyGtzAuGlcflCKKtMTKJnPfwBM4/KVPalUqrSKR xFYCWmJnXsuaYzXZ1SBlurzOXWW9w5xZSATKmlXYhhgWZ2eJG3UfJJ2G798vzjEbO7t7sC RfFnsXfjhteetopIiMctxJs7lVD7pdzDp/4YashObmblch7S1BXlBs2r4h65vw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C8D4B172D9; Fri, 11 Mar 2022 10:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22BA7xFd061413; Fri, 11 Mar 2022 10:07:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22BA7xEd061412; Fri, 11 Mar 2022 10:07:59 GMT (envelope-from git) Date: Fri, 11 Mar 2022 10:07:59 GMT Message-Id: <202203111007.22BA7xEd061412@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: b85d0d603c57 - stable/13 - tslog.4: Document TSLOG List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b85d0d603c57b3a9e94a4342874012ec4e34b9c4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646993280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yqaBoKR1oTujkcyhZcn4iT+Jsx8wjnvM7uBKrBSbUL8=; b=TJwBHztKmN+tMX9qm7H4SLCJipEDaHUMKJvxMzC+jBbcbtw770Ui0K3qJGKB6i/UXIV2va dpPosmmCJURIKIcjML3MCKHxmy54KvVMXo9T43q6HBDiazZ9mtHDhVIsw3Y5S811XndfgU sjB92eVw65WHlIzV284Tlupn4z7xAmJxIRcT48/J0iAMJzmZKxACqSCJ2Uw4DkNkiL7dhq g4uEv3NjDwxDWpSeEF2uaxQ15ApSt0N54/ZyZkUpQFFsQ0koku7GYf29dtSja2BqZW+S5m CgZflUiwA2diIR8+XKLc2l0ZrOC7QZIWTTfFRRc5IbZQhelh9CkmKdnjB9MR/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646993280; a=rsa-sha256; cv=none; b=hllBISZ7JNAZI6ZfqKEIQEt2yMouYhFOoKmM5CwtaaUtxl5b8IwrjaJoegRDPjml6h1Fy3 1QFSSzh4gfnSwb9rUX1BZLJG/z26pd6D8GXVp5E+PwGuD6aq/gjq3S+DLt2yvbtOlC8J0E dhHUpiiMRoc9KJKep/X51LcGLeSqdPRoRQ90YE0zXhF7kuRajFeb4tZqBBhh+ywqnRMc5P ruxC83R3haOVlrmd5Yz663FNsT5pXYybj6pcUDZzb/81nSRIf9OhDgl1Hng+h8ZfqMbEfE ac4Vs9s+rIjCYCSCsQM4Y5og+b2pSelU2naN4NCIn63EsDqNuznJObCEmxnj6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=b85d0d603c57b3a9e94a4342874012ec4e34b9c4 commit b85d0d603c57b3a9e94a4342874012ec4e34b9c4 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2022-03-04 19:33:22 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2022-03-11 10:05:48 +0000 tslog.4: Document TSLOG Based on commit messages and Colin Percival's presentation from BSDCan 2018 [1]. [1]: https://papers.freebsd.org/2018/bsdcan/percival-Profiling_the_FreeBSD_kernel_boot.files/percival-Profiling_the_FreeBSD_kernel_boot.pdf Reviewed by: cperciva, debdrup MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D34430 (cherry picked from commit 5675bb582985654b172a4c1dd191e2b3bb8e78bb) --- share/man/man4/Makefile | 1 + share/man/man4/tslog.4 | 135 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index fbbf9f03304c..0df6c064d57c 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -562,6 +562,7 @@ MAN= aac.4 \ ti.4 \ timecounters.4 \ ${_tpm.4} \ + tslog.4 \ tty.4 \ tun.4 \ twa.4 \ diff --git a/share/man/man4/tslog.4 b/share/man/man4/tslog.4 new file mode 100644 index 000000000000..7d36898a6533 --- /dev/null +++ b/share/man/man4/tslog.4 @@ -0,0 +1,135 @@ +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2022 Mateusz Piotrowski <0mp@FreeBSD.org> +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd March 4, 2022 +.Dt TSLOG 4 +.Os +.Sh NAME +.Nm tslog +.Nd Boot-time event tracing facility +.Sh SYNOPSIS +To compile this boot-time event tracing facility into the kernel, +place the following line in the kernel configuration file: +.Bd -ragged -offset indent +.Cd "option TSLOG" +.Ed +.Sh DESCRIPTION +.Nm +is a boot-time event tracing facility. +Its purpose is to ease diagnosing and reducing the overall +.Fx +boot time by generating detailed timing information. +.Pp +.Nm +is able to trace the boot loader, kernel initialization, and userland processes. +.Pp +In userland, it records the following details for each process ID: +.Bl -dash +.It +The timestamp of the +.Xr fork 2 +which creates the given process ID and the parent process ID. +.It +The path passed to +.Xr execve 2 , +if any. +.It +The first path resolved by +.Xr namei 9 , +if any. +.It +The timestamp of the +.Xr exit 3 +which terminates the process. +.El +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 8 +variables are available: +.Bl -tag -width indent +.It Va debug.tslog +Dump the +.Nm +buffer of recorded loader and kernel event timestamps. +.It Va debug.tslog_user +Dump the +.Nm +buffer +of recorded userland event timestamps. +.El +.Sh FLAMEGRAPHS +The +.Nm +buffer dumps +can be used to generate flamegraphs of the +.Fx +boot process for visual analysis. +See +.Lk https://github.com/cperciva/freebsd-boot-profiling +for more information. +.Sh SEE ALSO +.Xr dtrace 1 , +.Xr boottrace 4 , +.Xr ktr 4 +.Sh HISTORY +.Nm +first appeared in +.Fx 12.0 . +Support for tracing boot loaders and userland process +was added in +.Fx 14.0 . +.Ss TSLOG vs. Boottrace +.Nm +is oriented towards system developers while +.Xr boottrace 4 +is meant to be easy to use by system administrators. +Both faciliities provide an overview of timing and resource usage of the boot +process. +.Ss TSLOG vs. DTrace +.Xr dtrace 1 +is not always the right tool for profiling early kernel initialization. +The reason is it requires some kernel subroutines +which are not yet available early in the boot process, e.g.: +traps, memory allocation, or thread schedulling. +.Nm +depends on fewer kernel subroutines than +.Xr dtrace 1 +and because of that can trace early kernel initialization. +.Ss TSLOG vs. KTR +.Xr ktr 4 +has a couple of limitations which prevent it from +being able to run at the start of the boot process. +In contrast, +.Nm +is designed for logging timestamped events for boot +profiling. +.Sh AUTHORS +.An -nosplit +.Nm +was written by +.An Colin Percival Aq Mt cperciva@FreeBSD.org . +.Pp +This manual page was written by +.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org .