From nobody Tue Apr 12 21:52:57 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 0E0B01AF94B8; Tue, 12 Apr 2022 21:52:58 +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 4KdKGK3zmnz4gJj; Tue, 12 Apr 2022 21:52:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649800377; 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=Jn3s5UPST854SPdBaMmsuRe5zZMKq1Az+9xAVVM7hmA=; b=RYwrCxTaJyIhAZe5OSudkZVIchY+oT44/pAR9BxUybwep0lnASEX2Tv3qwMagikn2VpkHo 8t653n3N8YJcft0iBESpdDS4z89pTuSjaYU/Smeddrrxr1pdPtH24Racdo5xupTWLvHM7E zZVKR1D0DIUvNFn/KAabQ/3LgOAOtbRO1NAaUDpw1bjpJ9SZltlohCRgVy8wIn/unGxDeg IktgbHb1njuOrFhq4WZyVkz+e5VUisxn779mBWRpyAgrJy5niB7EWo9Aje8MV0ILWgfJhf PqT/QB9/GaGm1TRukHjYyRhlpGs+A1wxYW6GPJVggeYRqtLSXIQv+3PCjE7beQ== 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 41D441F63C; Tue, 12 Apr 2022 21:52:57 +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 23CLqvMd034277; Tue, 12 Apr 2022 21:52:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23CLqvGD034276; Tue, 12 Apr 2022 21:52:57 GMT (envelope-from git) Date: Tue, 12 Apr 2022 21:52:57 GMT Message-Id: <202204122152.23CLqvGD034276@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4eb43c2c46ed - main - KTR: Add CTR() and TR() macros which accept a variable number of arguments. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4eb43c2c46ed0c9332e29a4b77a8961e6b9e3fa4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649800377; 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=Jn3s5UPST854SPdBaMmsuRe5zZMKq1Az+9xAVVM7hmA=; b=Og8Gh6R0+f4vwm7J12aoMbdWSxPlfcg4fNtWvcJoiRsX5rLRLSnRzvEwCmOdvXzV1a1N1J bnfV09UOIcgIfuDg/Fjwv4iQcJ9GmRHrn0Pg4wbxhkDMsqAqmHzmeJEmDZh81Tj5nDJ9+V PLlkvulfm+dxNH3RwGsJPu7Mtn0TdFDk9Vi19Lq9+FvXRJr5frZA1L0y2H+IxXfSqlfhVT qO0VDV/8mOmrg9kxNwczL0eTXalTk7darBA5bJ2QyfeY2hS1X2MlIagiAAEEWOuVarkS92 q9dgC+1wRFai+7mwjKXzWi8Inf9SMH9Ke92NMG/aa/dglw1cLSa68UmIYDvSsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649800377; a=rsa-sha256; cv=none; b=CyF9uySPTv0FvLxqddpYhFb9Maw7t7jN1R8JVCWhR1Rio6H8t6UNacj5lWIFGWfVsBZfsN 7i7WdsRWcrD7Av5NqBCjdhsSefp/FfyXD4eISk+29FsMvrbVFh/mQ6A7ohO46Nwk9OLYBH RWpBrEZj1ih7ABeJnce0akPdUu8Q5GE5ytN8KZKm1HbUiNLWrTgilPh33QWtNbzWJST5Ti Vr1Uzm861nCbhyiio9qo+s98wtAbTiUmuG+IxvGelYnl/3N76g+EfOsyVfbjjq98eoiMAP xM9GWzHOhgLPfKn9ZG4wMvQIOsIko3E8dp7t0sUuFAhUk1wYyD0F6XCUjzlWfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4eb43c2c46ed0c9332e29a4b77a8961e6b9e3fa4 commit 4eb43c2c46ed0c9332e29a4b77a8961e6b9e3fa4 Author: John Baldwin AuthorDate: 2022-04-12 21:51:59 +0000 Commit: John Baldwin CommitDate: 2022-04-12 21:52:25 +0000 KTR: Add CTR() and TR() macros which accept a variable number of arguments. These can be used in place of the CTRn() macros which require n to match the number of optional arguments. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D34852 --- share/man/man9/ktr.9 | 17 ++++++++++++++--- sys/sys/ktr.h | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/share/man/man9/ktr.9 b/share/man/man9/ktr.9 index c7f4138b855c..cfe9cacf8611 100644 --- a/share/man/man9/ktr.9 +++ b/share/man/man9/ktr.9 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 26, 2021 +.Dd April 12, 2022 .Dt KTR 9 .Os .Sh NAME @@ -39,6 +39,8 @@ .Vt "extern int ktr_verbose" ; .Vt "extern struct ktr_entry ktr_buf[]" ; .Ft void +.Fn CTR "u_int mask" "char *format" "..." +.Ft void .Fn CTR0 "u_int mask" "char *format" .Ft void .Fn CTR1 "u_int mask" "char *format" "arg1" @@ -64,6 +66,8 @@ or .Xr ktrdump 8 . .Pp Events are created and logged in the kernel via the +.Dv CTR +and .Dv CTR Ns Ar x macros. The first parameter is a mask of event types @@ -81,7 +85,7 @@ argument is a style format string used to build the text of the event log message. Following the .Fa format -string are zero to five arguments referenced by +string are zero to six arguments referenced by .Fa format . Each event is logged with a file name and source line number of the originating CTR call, and a timestamp in addition to the log message. @@ -91,7 +95,9 @@ and formatting is done at the dump time. Do not use pointers to the objects with limited lifetime, for instance, strings, because the pointer may become invalid when buffer is printed. .Pp -Note that the different macros differ only in the number of arguments each +The +.Dv CTR Ns Ar x +macros differ only in the number of arguments each one takes, as indicated by its name. .Pp The @@ -143,6 +149,11 @@ The KTR kernel tracing facility first appeared in .Bsx 3.0 and was imported into .Fx 5.0 . +.Pp +The +.Fn CTR +macro accepting a variable number of arguments first appeared in +.Fx 14.0 . .Sh BUGS Currently there is one global buffer shared among all CPUs. It might be profitable at some point in time to use per-CPU buffers instead diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index dc06be9fa9cb..396ad21cffc7 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -107,6 +107,13 @@ void ktr_tracepoint(uint64_t mask, const char *file, int line, #define TR5(d, p1, p2, p3, p4, p5) CTR5(KTR_GEN, d, p1, p2, p3, p4, p5) #define TR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6) +#define _KTR_MACRO(m, format, _1, _2, _3, _4, _5, _6, NAME, ...) \ + NAME +#define CTR(...) \ + _KTR_MACRO(__VA_ARGS__, CTR6, CTR5, CTR4, CTR3, CTR2, CTR1, \ + CTR0)(__VA_ARGS__) +#define TR(...) CTR(KTR_GEN, __VA_ARGS__) + /* * The event macros implement KTR graphic plotting facilities provided * by src/tools/sched/schedgraph.py. Three generic types of events are