From nobody Tue Feb 22 00:17:23 2022 X-Original-To: dev-commits-src-main@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 1746119DF327; Tue, 22 Feb 2022 00:17:24 +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 4K2fr34DM4z3Lqw; Tue, 22 Feb 2022 00:17:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645489043; 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=lIcZEN2PY4Nx5kDYrU6LCICPaTIa9DNKWQY/l8j/I1Q=; b=VgOewTiVXivKa6R/0Wd+xAEUUQeyfIu7gS8gpagxjK59UXFHP8r4qHXbigbovJ5QyX7Qx5 mmvkFX3rvf1NuulK/vPiNQzUCVU6YLnVxU0N12rGj1RpOwoXrv4NzKFvyOkMbprdtMaKCK WOohILkG3wkXP4CL0MHxiX28VMGLdFSq8GDz1QmTn29S3IV8pWNBgkGgh8m9qEFH2SezfI CMMciQfXb0Z38627A7Xh3LomtKSFNPOlH+I/liKhbCfC4w3QkzTq1RWASscoLm2K82I5xP UzlKBRqXo8zwIBJnahpxI6cBoELHAlnk6I+XCPBwGPM8oK5hI2mRjuM+SKD7bA== 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 3080419DE7; Tue, 22 Feb 2022 00:17:23 +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 21M0HNmp041261; Tue, 22 Feb 2022 00:17:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21M0HNXC041260; Tue, 22 Feb 2022 00:17:23 GMT (envelope-from git) Date: Tue, 22 Feb 2022 00:17:23 GMT Message-Id: <202202220017.21M0HNXC041260@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 318d0db5fe8a - main - rc.subr: boottrace annotations List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 318d0db5fe8a25321321d27dfcbe42d36996876c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645489043; 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=lIcZEN2PY4Nx5kDYrU6LCICPaTIa9DNKWQY/l8j/I1Q=; b=xTqNG3oi74c9uAg2ZInte0ojOVJj4/ju8JaNfXpYGICXJb3h+mwKFv5WoUhKiwZf0qfeUT SFud14aS6vK7UlF8Ti/DVNM1Er1eYT7rx42X3I3NQZrvj7hNKgXjfxNP4DtSgyv1forBft T2vnSN6VnhVjX50Ocas8CKS28yr2lFTDoAynRgg4TrjL84qeVAM7ALvHCg/JakW6ZxLNBT AXRIM0laLtmAEg6wUOSUFEJNWU7d/vkwOtVhbAkdB0LKQGgchxpm6jSyiAczl3j+V9/IhH GN01U5CmoFjxQ/p7FY3qNT6E67mlrNKE7ldOkMZVwzhd7CpsQAubNJJ0U8YYag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645489043; a=rsa-sha256; cv=none; b=l2dui9AKQUA0DBlvaaSFCFom1hdrmhkgPBO6ks+CZcq6NSjrvm63hZwmCYZYCWqjN0l/jV fu2DTprswiMAA3G2tLYYYN3hI9GbGnxeHIZtN9bEL3y+5D0sjO7YV2TQEoM7D2TR6g6t3V 31OGztzruZ6HIRtManymr4DOnqSQiJI9bc07uGSSQht0gCHSwhmFhPhSHh0xzRQ9m2kPi3 VXJ6UViGlWospEM1YHcPibM3aAyOoSn3oAG/CYWnnw9oiAfpq9yZVakNdZbk2nR+jWnyhR ZY12WSp6cIY4jo0+Dq0zXez4+lLQkk8jcUFPD+R70ERi0uuycwF/ZQaJ6HcVig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=318d0db5fe8a25321321d27dfcbe42d36996876c commit 318d0db5fe8a25321321d27dfcbe42d36996876c Author: Mitchell Horne AuthorDate: 2021-01-17 22:56:59 +0000 Commit: Mitchell Horne CommitDate: 2022-02-22 00:16:12 +0000 rc.subr: boottrace annotations When enabled, have the framework use the boottrace(8) utility to execute each rc script, generating trace entries for the entire suite of scripts. Reviewed by: 0mp (slightly earlier version) Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D31930 --- libexec/rc/rc.subr | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 7144c3cbfce9..76f878c11e29 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -1411,7 +1411,9 @@ run_rc_script() ;; *) # run in subshell if [ -x $_file ]; then - if [ -n "$rc_fast_and_loose" ]; then + if [ -n "$rc_boottrace" ]; then + boottrace_fn "$_file" "$_arg" + elif [ -n "$rc_fast_and_loose" ]; then set $_arg; . $_file else ( trap "echo Script $_file interrupted >&2 ; kill -QUIT $$" 3 @@ -1424,6 +1426,26 @@ run_rc_script() esac } +boottrace_fn() +{ + local _file _arg + _file=$1 + _arg=$2 + + if [ -n "$rc_fast_and_loose" ]; then + boottrace_sysctl "$_file start" + set $_arg; . $_file + boottrace_sysctl "$_file done" + else + $boottrace_cmd "$_file" "$_arg" + fi +} + +boottrace_sysctl() +{ + ${SYSCTL} kern.boottrace.boottrace="$1" +} + # # load_rc_config [service] # Source in the configuration file(s) for a given service. @@ -2195,3 +2217,8 @@ _echoonce() if kenv -q rc.debug > /dev/null ; then rc_debug=YES fi + +boottrace_cmd=`command -v boottrace` +if [ -n "$boottrace_cmd" ] && [ "`${SYSCTL_N} -q kern.boottrace.enabled`" = "1" ]; then + rc_boottrace=YES +fi