From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAC7547D93B for ; Wed, 17 Jun 2026 15:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781708963; cv=none; b=ATgGfpPs+ihjWA+LNeibL3yBHnbDSTXsdiTGFoEJpR8kBGxqHLCCcwnLF9Hky8RWF7Q6ZWszZFnMUZly+3j7PDkuZiXu6FRv+n3h35LBEhNL+VW50y3BiIA5pznNocxuDBrMFy1XRdy+sHq8ZfouM5URYQslinr53/WlGbuE6AA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781708963; c=relaxed/simple; bh=fVhOrP/gRUiafcqVYicEBTC9Gtxfxkak1Kn9fx+YDCU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=APbiA1EdFgiKiF+2DcWX/lFAn9+h67R+bXFEHl9QjrdxegHp+Mm6vvbvyyRD55+ubNrbRVBuYDmY1EZKRil7M/mgjmjdw/n9UvSUUScWcFdXOEdTeD7Wx5ExIZAXlt/Qx4XBEcxo27APT9Y3EY601dVa/FrHzlOGZJxbSO58zJg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aUAAEJKW; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=mbxiFd9U; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aUAAEJKW"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="mbxiFd9U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781708959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ANjNnpra5aS+d58YG+e3BMxI1QsylXKLCiU+yz4SsfE=; b=aUAAEJKWS/hse6eclVSlececYJQwiSLFbpVzPSi2fnYrvTxSg6jfObeZo9vZLNGyNtRIIg d4mOjNhXhxc/CIoiMzz7q3kuya/7dwm9PBohVxrTqcEWZ32RXgeC+VWg/vhpF9FyLlwslb q/Ey/tVFJ+t92heE4MCrt5y6DZNXY2s= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-xUipauwJMwGmXfpmS_4-bA-1; Wed, 17 Jun 2026 11:09:18 -0400 X-MC-Unique: xUipauwJMwGmXfpmS_4-bA-1 X-Mimecast-MFC-AGG-ID: xUipauwJMwGmXfpmS_4-bA_1781708957 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490a767c7dcso38265615e9.2 for ; Wed, 17 Jun 2026 08:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781708957; x=1782313757; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=ANjNnpra5aS+d58YG+e3BMxI1QsylXKLCiU+yz4SsfE=; b=mbxiFd9U9/GIbW3TfdUb45esMlcU0ya389VaVeJui5jJ3GBT9r+jAY+ckcp3KaCh+7 nZDkwqD07HtWok3CF+Q0qqHAjHXx12gUoTN86VukC738t6K+hFziqY7iKBxpmMTltN8r /Onh0av9Eds2EQ7YLiFxhMrXo91Fr9gYOFuJLRgUzyhrMRv/7ot/LlOqdWowKXGsalJi KkUfWJSYif5WBQCBKxfcQKGFpAOuOCWs2ubajLVixVxuQkyQyoJtWw4BZ97OTnBAZ5zY mPg38+JXo6jbuZ/EnoaHvy67X6BHIlnudpQn012VmYsvy3RV9nOe22k2imlrpfyERq0y D6ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781708957; x=1782313757; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ANjNnpra5aS+d58YG+e3BMxI1QsylXKLCiU+yz4SsfE=; b=n4x4E7rroZGrYHQFHutbqDaeOagu+EX/51dl8mYZZ00uSufm+yDobqNEZERgT/wzkR qcnsJMpOBhIxNxLhjiRtH6pXhI8xFxGLQwXpU4utFgoRjLWvtIJmq5PKZUgInIgxfcxB zRb2JQgpya8et6MebOrnyol6dIMocrtKK/EGyft40w9zCz/haP+9Bve56zJkiffwSpO4 lvPE2ynYc3DOBe1105TpCK7N+8YLxg4ID2r8vQw3M1BrXB8Bhdu0JoFTvcKHLgWnURKs 9Khm1S4wefyIN8c6C4AKCOGMB6W2GvjRIQKdNvGxB+hCA5Er8dJytMZKdnHwT2Ay0YVg yw5A== X-Forwarded-Encrypted: i=1; AFNElJ/y3smd8t+rFRf4hzzJAMLErU9Sv2gH3rXcI7MNHvVHxXZG2P6Nm6B0P5BLdfkzXVK1a8M/gO3GsCb0jZ4=@vger.kernel.org X-Gm-Message-State: AOJu0YwLteOw1Vy9E+/CABiGYOVA7OdAHhDGO6oC/9zd5lNNsTUPWsa/ /caoOwF03NbenXpYqikTocuTDuwCWgxMn9IS3/b4Ut6p0Qb+PGtu67Zgc7teDRa9LtEUrzgbBcQ bUg6dWtcJaKlkdTi61t1VSINC8EkgkWFt539g3zimtLEmuJi5Xuo7Nl6l8/v/UMq4sA== X-Gm-Gg: Acq92OHAqNzANKLFP+OQQjfcNcSusVkAyW7NZVD5qducknKB1cbaK9xXe60j+0Vf8PA Qk3hzCun0JMLeTb9KI1KAWH08y5nCCANbh/GCHRwKYrF6BNLeNHnp+Irr7EYW6NuXAJWQnsp/hh tSk78a0uf/s6JCovpo25T/IWDXB6d6LppWvJHrpxvc1Y/wFDX2YkI1aTkq1LqeFKBOZSnMBSjd/ yD1UJB5k1XoJ5hyCqmJMDMncN07FHMVSycPDpqWLUaG4Berq/2OSA9Aqgv9Ywo/9yan4CIHnOKu ocOmCpH5mW0GpQCl3zKo8xnd9STnfP353qrxIDkOhKJaeopUe/TJq/N124ZiT9AnHvphdsvpif2 tWJIEiWGpj+G2twI= X-Received: by 2002:a05:600c:e557:20b0:492:1e36:85dc with SMTP id 5b1f17b1804b1-492333e2b9dmr55603545e9.36.1781708957133; Wed, 17 Jun 2026 08:09:17 -0700 (PDT) X-Received: by 2002:a05:600c:e557:20b0:492:1e36:85dc with SMTP id 5b1f17b1804b1-492333e2b9dmr55602935e9.36.1781708956476; Wed, 17 Jun 2026 08:09:16 -0700 (PDT) Received: from [192.168.1.167] ([185.168.96.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49230a8ebe3sm135692145e9.11.2026.06.17.08.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 08:09:16 -0700 (PDT) Message-ID: <8c95a2665af5224f5eeb28d029aad5656529c7d4.camel@redhat.com> Subject: Re: [PATCH v3 9/9] selftests/verification: add tlob selftests From: Gabriele Monaco To: wen.yang@linux.dev Cc: Steven Rostedt , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 17 Jun 2026 17:09:15 +0200 In-Reply-To: <4aeb668c8446a9f6366d92e218df386bef7bc965.1780847473.git.wen.yang@linux.dev> References: <4aeb668c8446a9f6366d92e218df386bef7bc965.1780847473.git.wen.yang@linux.dev> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-1.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2026-06-08 at 00:13 +0800, wen.yang@linux.dev wrote: > From: Wen Yang >=20 > Add selftest coverage for the tlob uprobe monitoring interface under > tools/testing/selftests/verification/. >=20 > test.d/tlob/ contains both the helper sources (tlob_target, tlob_sym) > and the seven test scripts so the test suite is self-contained. > tlob_target provides busy-spin, sleep, and preempt workloads; > tlob_sym > resolves ELF symbol offsets for uprobe registration. >=20 > Seven test scripts exercise uprobe binding management, budget > violation > detection, and per-state time accounting (running_ns, waiting_ns, > sleeping_ns). >=20 > Signed-off-by: Wen Yang Tests look fine and coverage is good, thanks! Minor comments follow. > --- > =C2=A0.../testing/selftests/verification/.gitignore |=C2=A0=C2=A0 2 + > =C2=A0tools/testing/selftests/verification/Makefile |=C2=A0 19 +- > =C2=A0.../verification/test.d/tlob/Makefile=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 20 ++ > =C2=A0.../verification/test.d/tlob/test.d/functions |=C2=A0=C2=A0 1 + > =C2=A0.../verification/test.d/tlob/tlob_sym.c=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 | 189 > ++++++++++++++++++ > =C2=A0.../verification/test.d/tlob/tlob_target.c=C2=A0=C2=A0=C2=A0 | 138 = +++++++++++++ > =C2=A0.../verification/test.d/tlob/uprobe_bind.tc=C2=A0=C2=A0 |=C2=A0 37 = ++++ > =C2=A0.../test.d/tlob/uprobe_detail_running.tc=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0 51 +++++ > =C2=A0.../test.d/tlob/uprobe_detail_sleeping.tc=C2=A0=C2=A0=C2=A0=C2=A0 |= =C2=A0 50 +++++ > =C2=A0.../test.d/tlob/uprobe_detail_waiting.tc=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0 66 ++++++ Not sure if this would work, but just to lower the maintenance burden, couldn't we put these 3 in the same test case? You could define a bash function and pass "running", "sleeping" or "waiting" and whether to launch = the hog to that. Only waiting uses a taskset and a slightly different ordering, but wouldn't they all work fine like that? ... > a/tools/testing/selftests/verification/test.d/tlob/tlob_sym.c > b/tools/testing/selftests/verification/test.d/tlob/tlob_sym.c > new file mode 100644 > index 000000000000..1b7ba1c6d95b > --- /dev/null > +++ b/tools/testing/selftests/verification/test.d/tlob/tlob_sym.c > @@ -0,0 +1,189 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * tlob_sym.c - ELF symbol-to-file-offset utility for tlob selftests > + * > + * Usage: tlob_sym sym_offset > + * > + *=C2=A0=C2=A0 Prints the ELF file offset of in to std= out. > + * > + * Exit: 0 =3D found, 1 =3D error / not found. > + */ I wonder if instead of maintaining a pure C solution we couldn't live with something like: sym_offset() { # target symbol readelf -W -S -s $1 | awk -v symbol=3D"$2" ' { gsub(/\[ /, "[") } # normalise section markers $1 ~ /^\[[0-9]+\]$/ { sections[$1]=3D"0x"$4; offsets[$1]=3D"0x"$5 } $1 ~ /^[0-9]+:$/ && $NF =3D=3D symbol { addr=3D"0x"$2; sec=3D"["$7"]"= } END { printf "printf \"0x%%x\\n\" $((%s - %s + %s))\n", addr, section= s[sec], offsets[sec] } ' | sh } ... > diff --git > a/tools/testing/selftests/verification/test.d/tlob/tlob_target.c > b/tools/testing/selftests/verification/test.d/tlob/tlob_target.c > new file mode 100644 > index 000000000000..0fdbc575d71d > --- /dev/null > +++ b/tools/testing/selftests/verification/test.d/tlob/tlob_target.c > @@ -0,0 +1,138 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * tlob_target.c - uprobe target binary for tlob selftests. > + * > + * Provides three start/stop probe pairs, each designed to exercise > a > + * different dominant component of the detail_env_tlob ns breakdown: > + * > + *=C2=A0=C2=A0 tlob_busy_work=C2=A0=C2=A0=C2=A0 / tlob_busy_work_done=C2= =A0=C2=A0=C2=A0 - busy-spin: > running_ns dominates > + *=C2=A0=C2=A0 tlob_sleep_work=C2=A0=C2=A0 / tlob_sleep_work_done=C2=A0= =C2=A0 - nanosleep: > sleeping_ns dominates > + *=C2=A0=C2=A0 tlob_preempt_work / tlob_preempt_work_done - busy-spin: > waiting_ns dominates > + *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (needs an R= T In short tlob_preempt_work is the same as tlob_busy_work, isn't it? Do we n= eed them both? Cannot you just have a hog in the test and keep using the same function? ... > + > + do { > + if (strcmp(mode, "sleep") =3D=3D 0) > + tlob_sleep_work(200); > + else if (strcmp(mode, "preempt") =3D=3D 0) > + tlob_preempt_work(200); > + else > + tlob_busy_work(200 * 1000000UL); The only difference I see is that you multiply by 1000000UL here for busy a= nd in the function for preempt. Cannot we make them all consistent (call with 200 and do the math inside)? > diff --git > a/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc > b/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc > new file mode 100644 > index 000000000000..1ac3db6ca7bb > --- /dev/null > +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc > @@ -0,0 +1,37 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0-or-later > +# description: Test tlob monitor uprobe binding (visible in monitor > file, removable, duplicate rejected) > +# requires: tlob:monitor > + > +RV_BINDIR=3D"${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" > +UPROBE_TARGET=3D"${RV_BINDIR}/tlob_target" > +TLOB_SYM=3D"${RV_BINDIR}/tlob_sym" > +[ -x "$UPROBE_TARGET" ] || exit_unsupported > +[ -x "$TLOB_SYM" ]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 || exit_unsupported If those aren't ready, the build system didn't work, I don't think we need = to check here, it's just a clear error. > +TLOB_MONITOR=3Dmonitors/tlob/monitor > + > +busy_offset=3D$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_busy_work > 2>/dev/null) > +stop_offset=3D$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" > tlob_busy_work_done 2>/dev/null) > +[ -n "$busy_offset" ] || exit_unsupported > +[ -n "$stop_offset" ] || exit_unsupported Kind of the same here, the rest of the test should probably fail (EINVAL in= the monitor or whatever). The script will print everything with set -x and it should be clear what was missing. > +command -v chrt=C2=A0=C2=A0=C2=A0 > /dev/null || exit_unsupported > +command -v taskset > /dev/null || exit_unsupported Not sure how common it is not to have those, but this is exactly what the :program under requires: is for (see rv_wwnr_printk with stress-ng). Thanks, Gabriele