From nobody Mon Jul 08 15:43:14 2024 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 4WHpLB2vxqz5PyTj; Mon, 08 Jul 2024 15:43:14 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WHpLB1cBkz42xy; Mon, 8 Jul 2024 15:43:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720453394; 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=bWMo75QBBQt7UcqI1MJAfDfq8bctCAHfp9nG7kuEnfE=; b=jR1/7+dX8MM6jF6Xf4IG5ubCs+7hQXHHzTt3J1vJJ34SmFkdFGyTAv9h3Tb1E8SusriO7v vXPGCAbxknyHJax6dBrbtc7H/dur2ylqYT8389eI+fVx/ybNuMA2KYlX2Lqm2BFQ2Bl1i+ w7ZUv/9BU38HaeD1rdYyMwy+lPueYzz5K9g49ayICuZOlmItpfH2qU7vtNBquWYYhhl8ax oJbSMc2X9DKOcrFcJCF5nQgxNz852cWHYIUW/4pD6pc7B011zmE/nJJWGAN/pwDE9Rq6CK yybM/mHkKjxOhkTiM++2BXto6FMEmH4wFTopPOglsgAgvesnn0kKM+gmqMav1A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720453394; a=rsa-sha256; cv=none; b=IRKVEkYIQjjSqOM1JcEfDCgHxAwppuDSSEtcwm0hld1ziMy5CvbbtdfP8iI1LKVGf4uMoD 3catQIg43sRPrrJp/AKi5fIS09A9LMK0Xp9KaERNEHM2PmI5Knk7qaxw9pS3t82wcfDsPS BUtAxWuHBIHRT9udmlNlzAH96sCuzJuMCQX28ol5N1YDJV7dRHyUfE1f1/7O1P+qXEtwN/ eupk286xVButxSUIoC3bqnWMuNJQgBID4qfGkjqd9bISxEmY1VCnweNI3CQ8vLozsWfO3r F4TcvZlsOKjeUvLnl09KYUT+tsgKZv2aS8ZHXc38ryobxolXzm9bQGOjWErw4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720453394; 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=bWMo75QBBQt7UcqI1MJAfDfq8bctCAHfp9nG7kuEnfE=; b=Wkltbw55XzYkO8pNtJLuv37LLvxd7HAN1yE4jwhDz21yvuDkmT6p+uRMkI9r0Kwcz3Z4/R 0vgWk9uR8EMuInVb23raN171NfsSnuUEGgsoQkGMRNiOIrwWOz3b2awtr2qz3bgPpCbvIk SE2utNMFmdC2+K9yQmY9H8T+yekV9wWZ6qufyOE0YPmo3e7XbQcM3Yptea/qFuMsDI9M7O zmrn26BI2Eh93JVaqdR5JJAD2t1DqrumMneoEKzFHbPtnE1eioys9jXcSuEJ7vfQHoUNll l5v8JV2MKnz3dJZZYDg+K87Yj0Y5Z8tQCpo5fY6ohArbEkPjD6DuYFD8ay+Oog== 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 4WHpLB1CT0zx58; Mon, 8 Jul 2024 15:43:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 468FhE0q032155; Mon, 8 Jul 2024 15:43:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 468FhEIo032152; Mon, 8 Jul 2024 15:43:14 GMT (envelope-from git) Date: Mon, 8 Jul 2024 15:43:14 GMT Message-Id: <202407081543.468FhEIo032152@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 85f7c98d85e4 - main - sdt: Fix aframe handling after commit ddf0ed09bd8f 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 85f7c98d85e4523943f40d0fa74581e5dd774f7b Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=85f7c98d85e4523943f40d0fa74581e5dd774f7b commit 85f7c98d85e4523943f40d0fa74581e5dd774f7b Author: Mark Johnston AuthorDate: 2024-07-08 15:40:24 +0000 Commit: Mark Johnston CommitDate: 2024-07-08 15:40:24 +0000 sdt: Fix aframe handling after commit ddf0ed09bd8f DTrace probes have an "aframes" attribute, used when unwinding the stack from dtrace_probe(). It counts the number of leading frames to skip when returning a stack trace, thus is used to hide internal functions. Commit ddf0ed09bd8f set the aframes value for SDT probes to 0, which was correct for an earlier iteration of the patch, but now doesn't take sdt_probe()/sdt_probe6() into account. Fix the aframes definition for SDT probes. Also try to improve lockstat(1) output by adding an additional aframe for lockstat probes, which otherwise show internal mtx(9), rwlock(9), etc. functions as the probe "caller". This is not quite correct as the number of frames to skip may differ depending on the lock type and kernel configuration (see e.g., the MUTEX_NOINLINE kernel option), but this is not a new problem. Reported by: mjg Fixes: ddf0ed09bd8f ("sdt: Implement SDT probes using hot-patching") --- sys/cddl/dev/sdt/sdt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/cddl/dev/sdt/sdt.c b/sys/cddl/dev/sdt/sdt.c index 461f454186a3..88ceb390876b 100644 --- a/sys/cddl/dev/sdt/sdt.c +++ b/sys/cddl/dev/sdt/sdt.c @@ -144,6 +144,7 @@ sdt_create_probe(struct sdt_probe *probe) const char *from; char *to; size_t len; + int aframes; if (probe->version != (int)sizeof(*probe)) { printf("ignoring probe %p, version %u expected %u\n", @@ -190,7 +191,17 @@ sdt_create_probe(struct sdt_probe *probe) if (dtrace_probe_lookup(prov->id, mod, func, name) != DTRACE_IDNONE) return; - (void)dtrace_probe_create(prov->id, mod, func, name, 0, probe); + aframes = 1; /* unwind past sdt_probe() */ + if (strcmp(prov->name, "lockstat") == 0) { + /* + * Locking primitives instrumented by lockstat automatically + * disable inlining. Step forward an extra frame so that DTrace + * variables like "caller" provide the function trying to + * acquire or release the lock rather than an internal function. + */ + aframes++; + } + (void)dtrace_probe_create(prov->id, mod, func, name, aframes, probe); } /*