From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88C723DB32F for ; Tue, 9 Jun 2026 07:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780988879; cv=none; b=l2MF1e2/J6q2FA8OcczKnnYxwuQ+05+2fQz5cCN5tZXRMLXdctGuG4SWtjhwdkhRpfUpnBUB7k8gylPTyjfa90gy+C7ihqAfErh1LOOyg5uAJBBsd98buHDeXTGBRWOKDAzYzA9SwNF9YNyNtZtLqRaDPDQPS+mpGPFOBW84xyk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780988879; c=relaxed/simple; bh=gZ8M38yaPWQMUh5IQOrNx5lYfy4Orh9NGNPa8bKckok=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=b+a0FOVjWkQr8KDxLG9UIblU54jiWdCSDgubJJ64049UNIVo1FWqaZQTMYrVmsIIDa1us1dDBbYSpokBXnEK+TZfdurWeXeP29uOzEB9a06D6mWGRkWuRKK91cnyfWiMYfQRmu2DcZB9Br1SkFEYGb5f5C4ZxREzaVm1+/2v+/w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SVT3kX0K; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SVT3kX0K" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-137dd3a60e8so6666905c88.0 for ; Tue, 09 Jun 2026 00:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780988874; x=1781593674; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=pmjF7cpxWrbBKhUHXvgT7w2ieRaQjttZ0h7t+S6dB6I=; b=SVT3kX0Kwj3ReBSZdVgWPoJe65NIU7cHl/9PEmbYtdQLlLjbkvHNBrfbRw1GonPlh1 sOGQrUOlniEJlzTUDKEBcFp6BDCD6+kK/86Ynkx8Z4UVT2CEsEbqO3ieB6hriw24gJkn yYsFC5n6nFEVAWi5wT7231AwMOjjwErVoPPHo4ETFWHYv8Fpd1HWRCeBWXjkNiht/WFp VGwOBycVax24khZsDMXNIuh52inq1nC362Sxd4nMEc4bZPHaAomS7NAfJYOcQXyClUIc XA7lh0sFAtyl6K4Z3KMfSldM4irIc9kH4cID+3YWcLM3DVKTT2itkBUXFiwlWFKuUAan YqwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780988874; x=1781593674; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pmjF7cpxWrbBKhUHXvgT7w2ieRaQjttZ0h7t+S6dB6I=; b=rqL9rn6XAKYPY4F7HM3UL7EQRuHIdzCmuyFO8ZmuGuxCc1tptpp8slPrEn3o9+aCND /XtkEfrJSRbU0t6vY9ldgfvt8PrSHpWVRjL2ArBk+/Yf8pYQxY47Jp8dMjMI9vdo/GOH nOn1zMDMxAVfrMxkekZJs3S31pDGWMMKpy2QXqFwZMivWNfSw4ircQ5UXMT1deXGZLnU T4NeRiT94n8/O9ww359doZuDEKMHupe4/KL6P6FT/LaaAyAyOI9boxSqDI/+13Pv/8Fr etVjQ1zUOVIzRVDsJbXFCUrCj79WGLFWbhLmGm6J0PCoiX7hKe0bUm9Jbej4QdwSBEba b9sg== X-Forwarded-Encrypted: i=1; AFNElJ8H8QyeUBZfeYTWg1hhS0lkOI3iIX/K/hiTJ4GjplmnGxBkc3cvIFIGMDoLkhAXgJM4Lmu/n1aObb337o0=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1WzsvkdHZrqj9BuXkYB5Bn4DLAChwHSGi+M9qbfUbA3U3jk1Y RVvHZdcoWIMjy521qVSLrpwqgl4jLEybmCReGGkyGBAfoizgh8cwJnggSXMPEsh/bv/eqjyVkdo Xb8ik3JbomQ== X-Received: from dlbvv25.prod.google.com ([2002:a05:7022:5f19:b0:135:38fe:4472]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:62a6:b0:137:9399:fc59 with SMTP id a92af1059eb24-138066e0064mr8443142c88.21.1780988873423; Tue, 09 Jun 2026 00:07:53 -0700 (PDT) Date: Tue, 9 Jun 2026 00:07:32 -0700 In-Reply-To: <20260609070732.545416-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260609070732.545416-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.1064.gd145956f57-goog Message-ID: <20260609070732.545416-8-irogers@google.com> Subject: [PATCH v2 7/7] perf test: Add BPF JIT annotation test coverage for all disassemblers From: Ian Rogers To: Serhei Makarov , mark@klomp.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Nick Terrell , David Sterba , Nathan Chancellor , Tomas Glozar , Blake Jones , Dmitrii Dolgov <9erthalion6@gmail.com>, Alexandre Chartre , Costa Shulyupin , Yuzhuo Jing , Michael Jeanson , Leo Yan , Tianyou Li , Zecheng Li , Rong Bao , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Expand the annotate.sh shell test to verify BPF JIT disassembly. If the test is run with sufficient privileges (root/CAP_BPF) and captures system BPF programs, it will extract a JITted BPF program symbol from the perf report and run perf annotate on it. This validates the temporary ELF generation and disassembles it using each of the supported disassembler backends (objdump, llvm, capstone, and libasm). Assisted-by: Antigravity:Google Gemini 3.5-flash Signed-off-by: Ian Rogers --- tools/perf/tests/shell/annotate.sh | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh index 2c06d2670cb1..9719e592befd 100755 --- a/tools/perf/tests/shell/annotate.sh +++ b/tools/perf/tests/shell/annotate.sh @@ -163,5 +163,84 @@ then test_disassembler "libasm" "libasm" fi +test_bpf_disassembler() { + disassembler=$1 + feature=$2 + + if [ -n "${feature}" ] + then + if ! perf check feature "${feature}" > /dev/null 2>&1 + then + echo "Skip BPF JIT test for ${disassembler} (feature ${feature} not supported)" + return 0 + fi + fi + + echo "Test BPF JIT annotate with disassembler: ${disassembler}" + + if ! perf annotate --no-demangle -i "${perfdata}" --stdio "${bpf_sym}" \ + --disassembler "${disassembler}" 2> /dev/null > "${perfout}" + then + echo "BPF JIT annotate with ${disassembler} [Failed: perf annotate error]" + err=1 + return 0 + fi + + if ! grep -q "${disasm_regex}" "${perfout}" + then + echo "BPF JIT annotate with ${disassembler} [Failed: missing disasm output]" + err=1 + return 0 + fi + + echo "BPF JIT annotate with ${disassembler} [Success]" + return 0 +} + +test_bpf() { + echo "Test annotate with BPF JIT output" + + if ! perf check -q feature libbpf-strings ; then + echo "BPF annotation test [Skipped - libbpf-strings not supported]" + return 0 + fi + + bpftmp=$(mktemp -d /tmp/__perf_test.bpf.XXXXXX) + bpf_perfdata="${bpftmp}/perf.data" + + if ! perf record -a -e cycles -F 4000 -o "${bpf_perfdata}" -- sleep 1 2> /dev/null + then + echo "BPF annotation test [Skipped - perf record -a failed, probably no privileges]" + rm -rf "${bpftmp}" + return 0 + fi + + bpf_sym=$(perf report --stdio -i "${bpf_perfdata}" 2>/dev/null | \ + grep -E -o 'bpf_prog_[0-9a-f]{16}_[0-9A-Za-z_]*' | head -1) + + if [ -z "${bpf_sym}" ]; then + echo "BPF annotation test [Skipped - no JITted BPF symbols with samples found]" + rm -rf "${bpftmp}" + return 0 + fi + + # temporarily override perfdata so test_bpf_disassembler uses the right file + local old_perfdata="${perfdata}" + perfdata="${bpf_perfdata}" + + test_bpf_disassembler "objdump" "" + test_bpf_disassembler "llvm" "libLLVM" + test_bpf_disassembler "capstone" "libcapstone" + test_bpf_disassembler "libasm" "libasm" + + perfdata="${old_perfdata}" + rm -rf "${bpftmp}" +} + +if [ "${err}" -eq 0 ] +then + test_bpf +fi + cleanup exit $err -- 2.54.0.1064.gd145956f57-goog