From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 B4D8E233958 for ; Tue, 30 Jun 2026 22:07:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782857262; cv=none; b=gV9nU206kDUFGcX0JJ88emtXwPbmMIa6GMBIIZ5330gZnC17AG62dyjVg1kvqeZkuhqpRpVUIrAWx4LCrEcDYHD4nGM5KkYCi5LsjpLqmEvfAHSszlfylDegYeqNOvESwUVmF5qUkMnAHFYjwik7Q710heuJD0krAUjhSuonk74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782857262; c=relaxed/simple; bh=w5OExVs13bravhrIoFw1hWFhF4Ny7Vq6OyG6/eP4y4A=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=hcPEDH+I42lS/f8icUrC2w7/G3j87CGzpUgJYKcu9DEzftYK4kYilnT2h8MdADB8sZyMHlmOlGpMOAjYgdMbTP1t26P5LU9gq/Qs+njtAGdn8kcQEQY7kVWxK4Cjof0L/sNPTtdjYPv8ATxnMytxiKuq9esBc50sKL3yfJToxBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Gf6ojdi0; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gf6ojdi0" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-7e6b5737bb2so17923a34.1 for ; Tue, 30 Jun 2026 15:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782857261; x=1783462061; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=V3JOUSD04HW8Lb07ylAFIaXu2WfSDfMlOMu/+z8QnRw=; b=Gf6ojdi0ts1hiRsKzLF7VBTfYzzTr8zFvhAuQa99x6QsQDTmAkjGwUzRgAy0h2KdTU ZeJLZ4qQ2aXAIzzQxRdV0Jp5N9IaiNZ1tDWsPrSCYfYrfUwnGQIGyYGs9YRxdP5wGNmh Mi1t8wqJYKv4R4L00TLyeJtDvOricQXY1KvVeXAPpL+4YcxXQ1BaYrpJFTff8FWDzk7N cmobdDiJhx4eeoUVaSdTBVsGzo/cBnAtk4wbcFsnI4zpm7CCB45xxUrDityOK8egmGVE cEHrhy23B/aaCFIUT2WtlhvjxVR/73a8OzH7LSBkSTLtHBm6KOEE/j8DpbrOh9/q1AcZ k6Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782857261; x=1783462061; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=V3JOUSD04HW8Lb07ylAFIaXu2WfSDfMlOMu/+z8QnRw=; b=QFX3zBOT0PeN6k1FuqjenauuwU9RHPvgXvkuxSV6O3+/TeNbkxMiyl2s6RjRncJDdy TUunPwJrgAxhdqku6gu6liyz6fVkFGIGpHAX/k7UXDYQHo/T9pRaADaY3y1aIojZPfwl y8N8xdndu8D61U5C9No2N93YmMEswcMPipqmv5eWJHA4+2oGAJfNONWnI+F3sGWM0qFe dX2e/9/5ot0Ey2n8vGyviNBNP9BUOdRXWBf2TWFiL+oFfxZpUxhllo4CJ994ezDA5xoT a8rZZgNdpIf29EM6CJaQ6B54/9JTKOrv3tI9xMIfkzDi8ua0B6P2BbDviO0AJ4X2ouMi D/Qw== X-Forwarded-Encrypted: i=1; AFNElJ9QJu4VY0v4h94RAxfqj4DgWg4Mm8Mz/05QTbbT2l2/H0b3qKyE5LZf4MYAhZFfeL07A2thaA1DPE84CwE=@vger.kernel.org X-Gm-Message-State: AOJu0YxJ/uXolo2HGRCwfpgZhqengGexGdxjtkjXoqhykhlDP+woZSrd ldYnWJztxkNE9D+oTZ+L6LumK6XXG3Etqn2JDOtoM+yWaQJDp/QHMOEB X-Gm-Gg: AfdE7cklzMhPrCKJfdr/YXBbhEOHsYX3sb7zVJRH+gKTQTisOWCxkHfFjYy28mjN50b V5wretq8SDKHroS8JjOpjqjp6DL+F/lLhh0Ns/EScZXVL7w3ZB/9meF/0aB3FhOurXcJBuluTbl 0iPTjMh4C3mA/7xkebDK5WLJCvecQaKTxp+yCmjCbKjVLYi1Q4NPhe/VTFleFP83rdoLGHlxpUH jbv8Tc9FxK7UjQSCCIJ+vyzx4DzHtvYS5jC9Bq+paJw6fvOErY43Oc3jt15B0g/xg++AOahkJxc pQV20yWEMxW+cKP3KOxWa1TgKdSFWc0WghvK3pl7XCE0hera9ctTRzBE4mSE6WI0dy4o5xwWuld xGM/Xi+6DUXXlGi4b5nLyWpytdfa+rrN7iDB5e7oV3a62Kjn8dB5+Q/dWVA/1SV5Q5OZkZ5Opd9 8oVA9h0vlNbqTSCbQ4zLUjj1y+c4ZxCzQ55jOOlt4hcJheODF6c0jTT9MQZU9JHQwtmbRg2ZUKn VcDSA== X-Received: by 2002:a05:6830:6d0f:b0:7e9:b4d0:df75 with SMTP id 46e09a7af769-7e9ec7bf3b3mr4563949a34.29.1782857260458; Tue, 30 Jun 2026 15:07:40 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:a::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7e9ebf89176sm3428179a34.1.2026.06.30.15.07.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jun 2026 15:07:39 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 30 Jun 2026 15:07:39 -0700 Message-Id: To: "Xu Kuohai" , , Cc: "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Yonghong Song" , "Jiri Olsa" , "KP Singh" , "Anton Protopopov" , "Amery Hung" , "Eyal Birger" , "Rong Tao" Subject: Re: [RFC PATCH bpf-next 00/12] bpf: Introduce static-defined tracing probe for BPF From: "Alexei Starovoitov" X-Mailer: aerc References: In-Reply-To: On Sat Jun 27, 2026 at 3:51 PM PDT, Xu Kuohai wrote: > From: Xu Kuohai > > This series introduces static-defined tracing probes for BPF programs. > BPF SDT (static-defined tracing) works similarly to USDT. User defines > probes in the BPF source code. The probes are built into NOP instructions > in the ELF. At runtime, when an observer is attached, the NOP instruction > is patched to a CALL instruction to the observer prog trampoline. > > Unlike USDT, BPF SDT requires explicit macros to generate the function > prototype BTF for each probe. This allows the verifier to validate the > probe sites against the declared types, and observer programs can be > attached similarly to normal tracing programs using the function prototyp= e > information. > > A probe with two arguments in the target program can be declared and defi= ned > like: > > BPF_SDT_DECLARE2(my_trace, int, int); > > SEC("xdp") > int xdp_prog(struct xdp_md *ctx) > { > int len =3D ctx->data_end - ctx->data; > int ret =3D XDP_DROP; > ... > BPF_SDT_PROBE2(my_trace, len, ret); > ... > } > > An observer would be like: > > SEC("bpf_sdt") > int BPF_PROG(observer_prog, int len, int ret) > { > bpf_printk("len=3D%d ret=3D%d\n", len, ret); > return 0; > } > > The target program and probe site for the observer program should be set > at load time via bpf_program__set_attach_target() manually, since program > names are not unique and program IDs are allocated at runtime - there is > no static way to identify the target program. > > For BPF_SDT_DECLARE2(my_trace, int, int) and BPF_SDT_PROBE2(my_trace, len= , ret) > macros, the compiler produces: > > [code section, e.g. xdp] > goto +0 // NOP, patched to CALL at attach time > > [.bpf_sdt_notes section] > ___sdt_jt_my_trace: // symbol marking this entry's boundary > .quad 0b // 8 bytes: offset of the NOP in the code > // section (resolved by the linker via > // R_BPF_64_ABS64 relocation) > r1 =3D %[arg1_reg] // 8 bytes per argument: BPF move insn > // whose src_reg field encodes the BPF > // register holding each probe argument > r2 =3D %[arg2_reg] > > .... > > [.BTF section] > FUNC_PROTO (int, int) -> void // from BPF_SDT_DECLARE2 stub > DECL_TAG "bpf_sdt:my_trace:2" // keyed by name + nargs Interesting idea and encoding scheme, but I don't think we need it. I'd rather see static_branch/jmp work that Anton started to be completed. That would be more generic and folks that need SDT-like observability inside bpf progs can instead guard their debug code with static_branches. SDT equivalent would be static branch plus a call to nop function which can be freplaced.