From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 D491D364E9E for ; Tue, 9 Jun 2026 05:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780982308; cv=none; b=K/q8NZuh76nT+4cO7jrDq8eQE/l8BH4D8c5kxUxJxUBGGD0oUHaKek3PM6TSvz2YMVd+a7pa6t0GAsKgUrXTl+LlHZcl1ZpSDoVTQe/xAK0shp+lvHWrGJiSqr70A1A0ZemhzqyYi00Uw7OdiLP1CId0GcHlO0djPECFKPivmMw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780982308; c=relaxed/simple; bh=qvz4oeLDy+YWznYpNNUEyf6DwxyVkylxfaL4HrqO2Lo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=sSwZyhR0fa+BFFokvMGydLqRiuDUB18a9opK+Y8ZHdg9sEJg5dTbo+Cy4dt3HYl4b3ZxPKarJIHSLWfrT1zOnTob3gsM9l/y8w7LX4eE4dc6V4bFPCNB9RZE2AA3k4jY5sDEDS0GsBCRp6cryLgy4DYxHoPvNB36MDyAv2ZuxF0= 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=HcNW6t8t; arc=none smtp.client-ip=74.125.82.202 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="HcNW6t8t" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-304d8613efbso5108943eec.1 for ; Mon, 08 Jun 2026 22:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780982304; x=1781587104; 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=gIXHmPDGDS7Qgr8fkgDEhnMYUYxH1NQb9jxl9ja86zM=; b=HcNW6t8tWJW5zxBRTqT4XDLGAd9v62tUg8PTFi9TwdxiWM1KDbYmdNxHOKUrNBfwrO 8qz71TTPuYTx/gUuHUr3r98NEo6lWARwfz0AOVKL7Ac1f6L01k6eKTdw9H1DkZjxHd+8 rbwDXcpadWZ2VJix/2RyuG5HHtlx9F4K8uBHAStaBTP19EB8aW77xzz4DCMqjXUjIfXq pFPsglS1fa44aqy7zCHHl4Bc4LQ9LSX9/PW3w2aZBLIwOFFG3ZohpFvqnWc9qrqYIH4B abmP+08J3h+6sPmHKcSlxFMrhndnaH9KX1TiNKjSFqfeRuIcqELqYAcqfvZ0ih7cKCua KT4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780982304; x=1781587104; 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=gIXHmPDGDS7Qgr8fkgDEhnMYUYxH1NQb9jxl9ja86zM=; b=fK30OVZHlF3BP5Ujgxh1N6cQVNwZW6aI0L5H+sTilqFIvkng7V84e6Q7H8LX2G6KXz F7LqrL6jsoC4pAi3NgoMbmk45wrwF+VO9N+aJ6G9RsRw+cyp6nbC/XBXnLaWgGdUvAEt JcE26hX4swQxvhryqnEgmdGNwkj0QUJHEaDaZRvW4gFEp4LZ3yDoiFF/I9pKioie59X+ 1RVXuWWWdLcw9toNwSrULH61RZxlcZrObXZBhW8dBjp7sn6I1Ksu7txDVlHJ3l87x3ej kXfxL0Tcabb4CTXmKFM/PxQui4rjkh9gMXk2Xzen6jDNB9LDgNMjvYdDLZf7qAegcSzO xKIw== X-Forwarded-Encrypted: i=1; AFNElJ/GGdJOZrTC7wIqR8nnpkPcUZyQXVhJ/3H496imPVSziW/S3jFGc+IZ/jp6DcWRkv/wE/MSSaNsQYPrH1w=@vger.kernel.org X-Gm-Message-State: AOJu0YyRFtioFPJoxp9Dy59JD/gzrJ8BwbQ7MqXWdvRhYVJetefkkcka W7qTjmEUkjboXdEFOn+W7l+lk/TAIDfLtQCIn43Y6fO4xGj5E18He9vWqf2fc6NKFJYopbXUaaZ ebetKriHOcg== X-Received: from dycso24.prod.google.com ([2002:a05:693c:3618:b0:304:e89d:c06b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:4347:b0:304:bce9:25fa with SMTP id 5a478bee46e88-3077b3305c5mr10548935eec.4.1780982303685; Mon, 08 Jun 2026 22:18:23 -0700 (PDT) Date: Mon, 8 Jun 2026 22:17:59 -0700 In-Reply-To: <20260609051759.405027-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: <20260609051759.405027-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.1064.gd145956f57-goog Message-ID: <20260609051759.405027-8-irogers@google.com> Subject: [PATCH v1 7/7] perf test: Add BPF JIT annotation test coverage for all disassemblers From: Ian Rogers To: 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 | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tools/perf/tests/shell/annotate.sh b/tools/perf/tests/shell/annotate.sh index d3bafa7e3db5..d8c710470c52 100755 --- a/tools/perf/tests/shell/annotate.sh +++ b/tools/perf/tests/shell/annotate.sh @@ -165,5 +165,74 @@ 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 1 + fi + + if ! grep -q "${disasm_regex}" "${perfout}" + then + echo "BPF JIT annotate with ${disassembler} [Failed: missing disasm output]" + err=1 + return 1 + 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 + + rm -f "${perfdata}" + + if ! perf record -a -e cycles -F 4000 -o "${perfdata}" -- sleep 1 2> /dev/null + then + echo "BPF annotation test [Skipped - perf record -a failed, probably no privileges]" + return 0 + fi + + bpf_sym=$(perf report --stdio -i "${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]" + return 0 + fi + + test_bpf_disassembler "objdump" "" + test_bpf_disassembler "llvm" "libLLVM" + test_bpf_disassembler "capstone" "libcapstone" + test_bpf_disassembler "libasm" "libasm" +} + +if [ "${err}" -eq 0 ] +then + test_bpf +fi + cleanup exit $err -- 2.54.0.1064.gd145956f57-goog