Go to file
Andrii Nakryiko 04d939a2ab libbpf: detect broken PID filtering logic for multi-uprobe
Libbpf is automatically (and transparently to user) detecting
multi-uprobe support in the kernel, and, if supported, uses
multi-uprobes to improve USDT attachment speed.

USDTs can be attached system-wide or for the specific process by PID. In
the latter case, we rely on correct kernel logic of not triggering USDT
for unrelated processes.

As such, on older kernels that do support multi-uprobes, but still have
broken PID filtering logic, we need to fall back to singular uprobes.

Unfortunately, whether user is using PID filtering or not is known at
the attachment time, which happens after relevant BPF programs were
loaded into the kernel. Also unfortunately, we need to make a call
whether to use multi-uprobes or singular uprobe for SEC("usdt") programs
during BPF object load time, at which point we have no information about
possible PID filtering.

The distinction between single and multi-uprobes is small, but important
for the kernel. Multi-uprobes get BPF_TRACE_UPROBE_MULTI attach type,
and kernel internally substitiute different implementation of some of
BPF helpers (e.g., bpf_get_attach_cookie()) depending on whether uprobe
is multi or singular. So, multi-uprobes and singular uprobes cannot be
intermixed.

All the above implies that we have to make an early and conservative
call about the use of multi-uprobes. And so this patch modifies libbpf's
existing feature detector for multi-uprobe support to also check correct
PID filtering. If PID filtering is not yet fixed, we fall back to
singular uprobes for USDTs.

This extension to feature detection is simple thanks to kernel's -EINVAL
addition for pid < 0.

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240521163401.3005045-4-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2024-05-25 10:46:02 -07:00
arch Probes updates for v6.10: 2024-05-17 18:29:30 -07:00
block SCSI misc on 20240514 2024-05-14 18:25:53 -07:00
certs This update includes the following changes: 2023-11-02 16:15:30 -10:00
crypto Hi, 2024-05-15 09:22:34 -07:00
Documentation Including fix from Andrii for the issue mentioned in our net-next PR, 2024-05-17 18:57:14 -07:00
drivers Revert "r8169: don't try to disable interrupts if NAPI is, scheduled already" 2024-05-21 11:18:55 +02:00
fs tracing cleanups for v6.10: 2024-05-17 18:34:27 -07:00
include tracing ring buffer updates for v6.10: 2024-05-17 18:40:37 -07:00
init Bootconfig updates for v6.10: 2024-05-17 18:23:55 -07:00
io_uring for-6.10/io_uring-20240511 2024-05-13 12:48:06 -07:00
ipc sysctl changes for v6.10-rc1 2024-05-17 17:31:24 -07:00
kernel bpf: remove unnecessary rcu_read_{lock,unlock}() in multi-uprobe attach logic 2024-05-25 10:46:02 -07:00
lib Probes updates for v6.10: 2024-05-17 18:29:30 -07:00
LICENSES LICENSES: Add the copyleft-next-0.3.1 license 2022-11-08 15:44:01 +01:00
mm ARM: 2024-05-15 14:46:43 -07:00
net openvswitch: Set the skbuff pkt_type for proper pmtud support. 2024-05-21 15:34:04 +02:00
rust Timers and timekeeping updates: 2024-05-14 09:27:40 -07:00
samples Networking changes for 6.10. 2024-05-14 19:42:24 -07:00
scripts Modules changes for v6.10-rc1 2024-05-15 14:05:08 -07:00
security integrity-v6.10 2024-05-15 08:43:02 -07:00
sound ALSA: hda/realtek: Drop doubly quirk entry for 103c:8a2e 2024-05-13 12:54:46 +02:00
tools libbpf: detect broken PID filtering logic for multi-uprobe 2024-05-25 10:46:02 -07:00
usr Kbuild updates for v6.8 2024-01-18 17:57:07 -08:00
virt KVM x86 misc changes for 6.10: 2024-05-12 03:18:44 -04:00
.clang-format clang-format: Update with v6.7-rc4's for_each macro list 2023-12-08 23:54:38 +01:00
.cocciconfig
.editorconfig Add .editorconfig file for basic formatting 2023-12-28 16:22:47 +09:00
.get_maintainer.ignore Add Jeff Kirsher to .get_maintainer.ignore 2024-03-08 11:36:54 +00:00
.gitattributes .gitattributes: set diff driver for Rust source code files 2023-05-31 17:48:25 +02:00
.gitignore kbuild: create a list of all built DTB files 2024-02-19 18:20:39 +09:00
.mailmap Another not-too-busy cycle for documentation, including: 2024-05-13 10:51:53 -07:00
.rustfmt.toml rust: add .rustfmt.toml 2022-09-28 09:02:20 +02:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS MAINTAINERS: Drop Gustavo Pimentel as PCI DWC Maintainer 2024-03-27 13:41:02 -05:00
Kbuild Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS MAINTAINERS: Add myself as reviewer of ARM64 BPF JIT 2024-05-21 11:00:30 -07:00
Makefile Linux 6.9 2024-05-12 14:12:29 -07:00
README README: Fix spelling 2024-03-18 03:36:32 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.