From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307656; b=q2zqh+8XBezJMO7we0DVKeZKYUkiyhAohO2FXZJMV2eIrLerkA062fKGTH6D21eJWRp1 aDaUZvNIKX36tPhf6jteIvHwsrYiX+QHPHglz4mlu1emlKPgQ8X20+N7hIWlwfWycTKEA Z7rv0psKKfc5kRZ2FdADTz5+0SZ4e3PjTDOmREpsa/raGh8rQb541c465o9wHbBedHu3U Ww4XUvUql69b44HSQkvOCyE8qtsRD8bgAHkOJN5w8AQcKv4i6yMDPjnLQl4pxaURs8kZW qNCzkAOH/N2f3tOH2cBx3/D8iw55t9tnidrRHcXhUVx6wB0H1hEJQqYYQpx8bb46MvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307656; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:X-Google-Original-From:Date:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=iVUmzG6J2/rficyQtYSwxVGwhUZz3/UKxzR+2T2WCTA=; b=qW+2UIEbEwMFzFuG17m5rCQ2cFSQCt8OxGR+NkBOyhGxYR66k4uit/4nekOUJMvEVCgt Rzu7jqS3lqlxEdtjvlHxARQFzzTdZrm5yUkTNJzzBaDtwtU2sPFOvnvzJKvdBNi5Xe4QB pu4TYsd8jIoYE1kZh3hndbAZqjMdtDLh4naU2jz0Ujq4I5mxVa8nbqTefO52r2VYlf2ow 3+hdgvESeuQwkviXJY+rk45JettsWhfpaHvIW/AgpuVVvI30s/fkU2wHvLQP1jPQCrNEm QDh0vGY5+lE5WOI+LnHqzUmw4MU4esgMtQwEBuYwqeGUzBn6BnXl05stMejQQyLZ7QQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="hN/YWP/2"; arc=none smtp.remote-ip=209.85.221.49 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93EA0606A337 for ; Thu, 3 Dec 2026 14:20:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 93EA0606A337 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.a=rsa-sha256 header.s=20260707 header.b=hN/YWP/2 Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4a357b1c649so8146662f8f.3 for ; Thu, 03 Dec 2026 06:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796307655; x=1796912455; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=iVUmzG6J2/rficyQtYSwxVGwhUZz3/UKxzR+2T2WCTA=; b=hN/YWP/2aP6TD4trG2ezi0HJiAY83OleXBAoq6oYipetlEiLzMbTN+t5BGBfIIFzr4 D07i/lwvBStMdREdTtHHlq2x5yzlIS5DfXFz6F+FKUJC+EH6TTWjh3IpBxDjndgIbTF2 3KTPBg8WhJFr2ZXTbFC3vvleslaqEHV9JSdOwOrmG2ocNNx44WwygJFZpBcNMyHAJ+J1 ZqdREjT+bhDgbMeKv8FvbDty8YCUZcgkYzFTjYdvrS4xYUomrIM3Ubyi9PxcUZ7jM2bW 9x/i9cnVckoWziQcDkkD21gP2ZAVOJXPiTw8eB5CmS0DJjvMXMNd8KJFwffRD2QVhcN3 l/gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796307655; x=1796912455; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iVUmzG6J2/rficyQtYSwxVGwhUZz3/UKxzR+2T2WCTA=; b=X4b5a9IuqPei1TNbaX/XOrbfwpvLgFpYJWhZM88MfEbdFf/t8XARys/6TkKXhFK5It wNiCYKTN5eiK3ES7oy5K+PHbQRgV8mucmw6kyFvkD993+u9wzzU66X9+zIGtECT0xKrJ nf11fznfBoGJPdPqe8JECQ9VhE9hS8FvQlM25uy9wUOTb/u42yJ8n1+XDSTpQkoM4gCG S3iy+dDcgKDLP/YJLmcxswCPSFBSm9iPg/r3dcCmWaZ4EWLikUk/0BNJIL9qGvXXdpoM bb176hgXA3DkB6MIMF6yuVpVIGRocXwF3v+xr8TzsHuIlPmdEeZ5NfQ115F2pnItqoxG 8x0Q== X-Forwarded-Encrypted: i=1; AL+hErHZAS5rg9uNyOx80XKCgGii7ADb0gIdig1gs0moUUfKkPNlloNDKM/qBJw+aXNqaJGgWkU6LbjGKP8424UcD7sFhqg=@vger.kernel.org X-Gm-Message-State: APuU4Z954048F6iE5dIeCEEBWo6ZxFWNFAbAMYGP3BNVdH9aptJny9Xe brmJd5Fs8rhSvr56OXLT+xiMUHq+hifFa4HrcElhrXVCRbSqR7sBoERq X-Gm-Gg: AZFdTZcaFv/EkwTZiAJvdcN4jJJ33hzr19PQZjl0l6SzhoULT4Mitf52j2iUsDciEid RIlNnqdjdCsr4RurKpHn2a1AttQQ+YDc+CBkoFacPPaxBPNhLwpyoz5eFhldHbOmVe5D2SxCobK XHvpQKe5TBoYf2Rvr6nu9FFUb/IbPiZPBHMZGdNTXBgxDp38lGBz5ygQeiJrW+oNL96tecfPbyO QdO+ByGp7GxE6RBjFhZ55GatkOWfV8V5UJq/x4ia27ZrnBwncVT+lLExYGnpYR8qpUYgIiYu2hI wpRxUzB/jv5bcEOgvb0s+xkAUAPzhwcDoLM2W24XbvL6uJ3D2f3i0YQrdI2XOhl2+QngCT4ppiq sgwAaafkNOky39DqsgNwDrWCMvkS1j8+4zXS7KL9BH5qxsbMn/tVmiZuMH1MkymqJyelFj8D2vd CVIFXOXfnKnAEbOMJXv/NcwEOp0LGSAix4L6pmVnM9EDsWcd0ytw2IFRjQKvBl8S/rxV080DI1L /kgcPB6PtdvRNwpG47lXoShsciGsw9nMlRTz8zz+xXQRZcDNxSB+4mhy3D6mqsRTz7PKbbSqwWZ X-Received: by 2002:a05:6000:4028:b0:4a6:bc53:246c with SMTP id ffacd0b85a97d-4abb3956374mr85794583f8f.42.1796307654747; Thu, 03 Dec 2026 06:20:54 -0800 (PST) Received: from krava ([2a02:8308:a00c:e200::25dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6bb989b3sm84106115f8f.51.2026.12.03.06.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 06:20:54 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Thu, 3 Dec 2026 15:20:51 +0100 To: Alexei Starovoitov Cc: Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu , bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , Quentin Monnet , Alan Maguire Subject: Re: [PATCH RFC bpf-next 00/31] bpf: Attach kprobe multi link to inlined functions Message-ID: References: <20261202123035.10335-1-jolsa@kernel.org> X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Dec 03, 2026 at 01:57:14AM +0000, Alexei Starovoitov wrote: > On Wed, Dec 02, 2026 at 04:30 AM Jiri Olsa wrote: > > This patchset adds BPF_F_KPROBE_MULTI_INLINE flag that attaches also > > the inlined instances of the functions in the syms array. The > > instances are resolved from inline BTF (CONFIG_DEBUG_INFO_BTF_INLINE) > > of vmlinux and modules and each gets its own kprobe. > > I like the idea. kprobes behind the kprobe multi link is the piece > that was missing. > But the lookup by name in the kernel is kinda heavy. > > In Alan's RFC thread I leaned towards the kernel doing the whole thing. > The reason: kprobe multi could not attach to arbitrary IPs. > Patch 7 shows that it can. That changes the trade off. > > Lets start with the mechanism only. > addrs[] takes any address that kprobes accept. > fprobe gets the ftrace locations. Every other address gets a kprobe. > Such addrs fail with -ENOENT in fprobe_init() today, so no need for > a flag. > User space reads vmlinux.inline from sysfs and passes the sites. ok, makes sense, more comments below > > libbpf works this way already. It resolves "tcp_*" in user space and > passes addrs. In this series wildcards can't use inline (patch 19). > To match fully inlined functions libbpf has to read vmlinux.inline > anyway. > > this series addrs[] > ----------------- ----------------------- ------------------------- > name -> sites kernel, exact names user space, wildcards too > subset of sites no yes > vmlinux.inline 2nd copy, ~10 Mbytes, mmap in user space > never freed > cookie per function per site > args bpf_get_func_arg() cookie -> arg spec, like > usdt.bpf.h > arch x86-64 any with kprobes > link info 5 new fields as is > fdinfo 2 new lines as is, %pS > bpftool new table, BTF lookup print sym+off > new flags 2 0 > > Your use case from Alan's v2 thread works too: trace foo() only where > it is inlined in bar(). User space picks the sites. > > Then there is no need for BTF parsing in the kernel, module_sect_addr(), > regs_get_dwarf_register(), inline_* in bpf_link_info, STRICT, etc. > Patches 2 and 3 stay. > > If tracers show that the lookup has to be in the kernel we add it > on top of addrs[]. uapi doesn't go the other way. initially I thought that doing the lookup in user space might be a security concern for shirudo, but it's probably just more work for the loader, not a security risk > > What the diff doesn't do: > It is all or none. imo that's the right default. > It doesn't say which address kprobes refuse. The link_create log can > name it. A flag to skip such addresses can come later. link info shows > what is attached. I think we need the skip flag. kprobes refuse some of the inlined sites (jump label, static call, bug table, NOKPROBE_SYMBOL, noinstr) and finding those in user space would need vmlinux and a copy of the kprobe checks, which seems too much I changed the bench test to print out the stats: inlined instances 20695 attached 19947 skipped, notrace function 563 skipped, refused by kprobes 185 it's the worst case, normal attach with just a few functions would hit much less, but it's still inconvenient, because user space has to retry the attach for each address the log names > It calls register_kprobes(). enable_kprobes() goes on top. ok > Two functions inlined at one address share one cookie. I think we can still allow same addresses having their own cookie, if we keep the cookie in the kprobe struct and pass it through the run context instead of looking it up by the address it's probably needed for the arg specs too, two inline functions on the same address would otherwise end up with the same spec thanks, jirka