Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp421697lqr; Wed, 5 Jun 2024 09:43:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCFDL0HkxYzKEHrH2zTNHFe3H5JXaQXS8kSUdWWmUUkMPM5H8msMBJNIKj4CuxkalbWcgrUDEEI/eekb2dTRaqMfLsw+Wgcubzt468iQ== X-Google-Smtp-Source: AGHT+IEOolj09nxzdbxfmA6XU09NyNwJwxLDs3TZMAqW6IfhrOcxdp81anhna7TRmsEeiA1o/y6B X-Received: by 2002:a17:903:28cf:b0:1f4:9158:6b9 with SMTP id d9443c01a7336-1f6a5a6c7a8mr26005965ad.47.1717605792583; Wed, 05 Jun 2024 09:43:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717605792; cv=pass; d=google.com; s=arc-20160816; b=SLkheIIdRrU/QcoOasn23XTMBm/JZ/DEKfloN/quSK/b8oNBL5/jWxANcb22yz38Zk 3bxAvZxf6p/HIYiDdAdEkLwHi35GY4e2Z8AaAf6obji6eG98IdykiUV7xRHij6Qj2+T6 fy+M4f99RIbj1O2yggsxRkbAhNYfBk4wOUUk16V1AxxcfOFg5j8PdaY5ebww9tSM7lGW JcWv9JRSH6v5wtPLhYki5AOx6WANrmW2aiA816QPC7FJmd+aECteml+jzNZQlqXyncJ4 oZtTWWsrnblxDaVwW8KhLZ25EDOSPwzz9/sN93VahR/kzw+4Yb3jBevtmPbGmWtAKgXS 8pCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Uf1Le7+qoXUovnxU+G8c1hBksMjj4DWz0B1IPDGyA0c=; fh=cAGHlFxh+c8cDKLZf04MB0Ni7KgVV4kl+huAU0hc8CY=; b=eTyd/Rny4RHFUA8XCwTuoYJEt8qRKbTyAAU1Jseyp5TIe5nnYI0KKxpKY6fQ37+Gc/ qgIhJEiFrE55EOdig7r1rL3DKb0Ri7dUOIsUWQjfYWi825xlxHeVWGDC3q30A7mf0TAr TuPuqn50rWaQGgg/SC/4KxcTAQUIlwB9q3Zreh2V4zswSwtjQWlLEPXX9psbNGQAnJl8 b1Xq+3NpaLUOQpzslD6Mo+gELMZZYese7aROzx3zh+q2NKKGXDh6SBaQXDAGeBZHaMWN ZeTwQbQjX76hTq2zKl8Zz9EB1EZbujJjBJc9l3RB8VAGy6Sp8vtXOCiOXuF2Cd9Vs6Ff VMyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="eK/QLyg6"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-202926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f63b63c3b4si4619365ad.554.2024.06.05.09.43.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 09:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="eK/QLyg6"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-202926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 32E76286B38 for ; Wed, 5 Jun 2024 16:43:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F40D188CCA; Wed, 5 Jun 2024 16:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eK/QLyg6" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 D2DC42837A; Wed, 5 Jun 2024 16:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717605781; cv=none; b=TnuCBLdxCuKGLJwiPFp5h29wEPJ9TtTR8TxHD/KF2yWxRncfzb1SFbFE3yENFgMFMm3NdNUMTuv58Z/EoOfaadr3koSiB6MZlwyWA5295ftN3RRdyXMpeO0Ha/pY3LoZE57DEjR8/1zWW1PA7/yd1gvjio8zooGrib5iuRw5ybg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717605781; c=relaxed/simple; bh=n3WvltwLnclYvUXilHbYaDwJDs8ZnJvI1qdN4d0TDTw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=oFwWFzovHQ9XNCyMmmzjTUPCcLSmKW+SIz/4dlHZpSTUdC/geeDUQ6WhnzsDrg2p4D35vWIPrZfomPyo3J2QZBjMGPVczBmPwuDESJ3ZrgJjt5ZdAR6RLVjbQHJNp6f34QNkgJ1EnYOWMbMjrdFae8Ya+4wCsjbO05vgixaC5Gg= 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=eK/QLyg6; arc=none smtp.client-ip=209.85.210.171 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 Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-703ed15b273so156444b3a.1; Wed, 05 Jun 2024 09:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717605779; x=1718210579; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Uf1Le7+qoXUovnxU+G8c1hBksMjj4DWz0B1IPDGyA0c=; b=eK/QLyg6JunRNuj8dRiXMIp5kc1N/0gNWDSF4dudoQFl+gCCIFALZ+uRybrUFmL0Jz 9B5Z8EKHwogRYMI6ZljJXD7y/Ts/alArUZLL5BKjxEVBqsCHwgXP5gEJMDgfgkFbwBkV LTG/fftX6ZhgVA95OJ5HmmsgIy6vTMxbIBUpP9PlkcuH8DSJW48okgv8T2YdpcxU3NOJ um06wUfcGLsg+gQqQGzbEq/1Nn3RZH5LqxDYoNkzFMms8VOqJhV4p4aL1x8OgDPEVtBb 5aC8Bqnmj7nZrVuk79hqbD+nSlg3XZxDwBnnNTJdYeAqlhvSragTvdjRRRroGdeNcIP5 rC5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717605779; x=1718210579; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uf1Le7+qoXUovnxU+G8c1hBksMjj4DWz0B1IPDGyA0c=; b=qBCLnqqJqJVwN2mRP2ixeKE+JFDPfVqbEuocuJ9OXCa53k+ybWnNqg5g36CLlRg1ik 97JE8aRPVyJTPEPh08L7FJ3IpuPNmU6kuen9PoseEnclpjvHH4M+ayScJAO5KFWrPW/R yVU5RlTsoTIQExMWarbvwx9gkQpKGa8vZeYsfXq0irloUGjsP5V7tH9/3Cim13ON+nvj G208wptZARlx4mE/OOlgGHdFUAQYtC1YWBgLLLm2VuZfgip0B87KCE25w/cOqeeS6HoM GGRAqZP6VR3Up3pQ1+j9Lwv0c8AB9Xd/TzOfJkK0lLleSeMEMy6bdRA8Mji6FltBuNeX FSsQ== X-Forwarded-Encrypted: i=1; AJvYcCVLmGy5Kj4n013beXvMAV+oE2gO8UByr0zCXka3xyIURVWEi9j0jGt8euTOhzj32M3+QOYlRNQREpOwPepkuCG1l448+1nirMnag0sBlTWwEW3PDbBXQmE4ilhmSmX2CwBPOR/V5jbv+jo9/NHjT3IMHnI/EiojZ2M8PVa224v5x51Ajt0A94wHjvRlQ8Ln6cpyGQkfK166fPnmAYB7gq5nRiO8WS6CQ3J4pva82+G3kpIGCRyy0aHAgU+P X-Gm-Message-State: AOJu0Yx25Fepi1r6BR/m7YC0WVcynzFmaO+EVPOPi3sZdSd/8hrtnwj9 4IWECmNR0b+uHl+9KrdBDSXcpZ2V/UV36PGWrou7kZhhwbIT4Jfbo8dmNxm27oHe1IjrjYOotkS jdtlmV1FyUxpXfgzt7A23al2qjho= X-Received: by 2002:a17:90b:33ca:b0:2bf:ea42:d0c3 with SMTP id 98e67ed59e1d1-2c27db1652bmr2817571a91.16.1717605778997; Wed, 05 Jun 2024 09:42:58 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240523121149.575616-1-jolsa@kernel.org> In-Reply-To: From: Andrii Nakryiko Date: Wed, 5 Jun 2024 09:42:45 -0700 Message-ID: Subject: Re: [PATCHv7 bpf-next 0/9] uprobe: uretprobe speed up To: Steven Rostedt , Masami Hiramatsu Cc: Oleg Nesterov , Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski , "Edgecombe, Rick P" , Deepak Gupta , Linus Torvalds Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 31, 2024 at 10:52=E2=80=AFAM Andrii Nakryiko wrote: > > On Thu, May 23, 2024 at 5:11=E2=80=AFAM Jiri Olsa wrot= e: > > > > hi, > > as part of the effort on speeding up the uprobes [0] coming with > > return uprobe optimization by using syscall instead of the trap > > on the uretprobe trampoline. > > > > The speed up depends on instruction type that uprobe is installed > > and depends on specific HW type, please check patch 1 for details. > > > > Patches 1-8 are based on bpf-next/master, but patch 2 and 3 are > > apply-able on linux-trace.git tree probes/for-next branch. > > Patch 9 is based on man-pages master. > > > > v7 changes: > > - fixes in man page [Alejandro Colomar] > > - fixed patch #1 fixes tag [Oleg] > > > > Also available at: > > https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git > > uretprobe_syscall > > > > thanks, > > jirka > > > > > > Notes to check list items in Documentation/process/adding-syscalls.rst: > > > > - System Call Alternatives > > New syscall seems like the best way in here, because we need > > just to quickly enter kernel with no extra arguments processing, > > which we'd need to do if we decided to use another syscall. > > > > - Designing the API: Planning for Extension > > The uretprobe syscall is very specific and most likely won't be > > extended in the future. > > > > At the moment it does not take any arguments and even if it does > > in future, it's allowed to be called only from trampoline prepared > > by kernel, so there'll be no broken user. > > > > - Designing the API: Other Considerations > > N/A because uretprobe syscall does not return reference to kernel > > object. > > > > - Proposing the API > > Wiring up of the uretprobe system call is in separate change, > > selftests and man page changes are part of the patchset. > > > > - Generic System Call Implementation > > There's no CONFIG option for the new functionality because it > > keeps the same behaviour from the user POV. > > > > - x86 System Call Implementation > > It's 64-bit syscall only. > > > > - Compatibility System Calls (Generic) > > N/A uretprobe syscall has no arguments and is not supported > > for compat processes. > > > > - Compatibility System Calls (x86) > > N/A uretprobe syscall is not supported for compat processes. > > > > - System Calls Returning Elsewhere > > N/A. > > > > - Other Details > > N/A. > > > > - Testing > > Adding new bpf selftests and ran ltp on top of this change. > > > > - Man Page > > Attached. > > > > - Do not call System Calls in the Kernel > > N/A. > > > > > > [0] https://lore.kernel.org/bpf/ZeCXHKJ--iYYbmLj@krava/ > > --- > > Jiri Olsa (8): > > x86/shstk: Make return uprobe work with shadow stack > > uprobe: Wire up uretprobe system call > > uprobe: Add uretprobe syscall to speed up return probe > > selftests/x86: Add return uprobe shadow stack test > > selftests/bpf: Add uretprobe syscall test for regs integrity > > selftests/bpf: Add uretprobe syscall test for regs changes > > selftests/bpf: Add uretprobe syscall call from user space test > > selftests/bpf: Add uretprobe shadow stack test > > > > Masami, Steven, > > It seems like the series is ready to go in. Are you planning to take > the first 4 patches through your linux-trace tree? Another ping. It's been two weeks since Jiri posted the last revision that got no more feedback to be addressed and everyone seems to be happy with it. This is an important speed up improvement for uprobe infrastructure in general and for BPF ecosystem in particular. "Uprobes are slow" is one of the top complaints from production BPF users, and sys_uretprobe approach is significantly improving the situation for return uprobes (aka uretprobes), potentially enabling new use cases that previously could have been too expensive to trace in practice and reducing the overhead of the existing ones. I'd appreciate the engagement from linux-trace maintainers on this patch set. Given it's important for BPF and that a big part of the patch set is BPF-based selftests, we'd also be happy to route all this through the bpf-next tree (which would actually make logistics for us much easier, but that's not the main concern). But regardless of the tree, it would be nice to make a decision and go forward with it. Thank you! > > > arch/x86/entry/syscalls/syscall_64.tbl | 1 + > > arch/x86/include/asm/shstk.h | 4 + > > arch/x86/kernel/shstk.c | 16 ++++ > > arch/x86/kernel/uprobes.c | 124 ++++= ++++++++++++++++++++++++- > > include/linux/syscalls.h | 2 + > > include/linux/uprobes.h | 3 + > > include/uapi/asm-generic/unistd.h | 5 +- > > kernel/events/uprobes.c | 24 ++++= -- > > kernel/sys_ni.c | 2 + > > tools/include/linux/compiler.h | 4 + > > tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 123 ++++= ++++++++++++++++++++++++- > > tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c | 385 ++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++ > > tools/testing/selftests/bpf/progs/uprobe_syscall.c | 15 ++++ > > tools/testing/selftests/bpf/progs/uprobe_syscall_executed.c | 17 ++++ > > tools/testing/selftests/x86/test_shadow_stack.c | 145 ++++= ++++++++++++++++++++++++++++++ > > 15 files changed, 860 insertions(+), 10 deletions(-) > > create mode 100644 tools/testing/selftests/bpf/prog_tests/uprobe_sysca= ll.c > > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall.c > > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall_ex= ecuted.c > > > > Jiri Olsa (1): > > man2: Add uretprobe syscall page > > > > man/man2/uretprobe.2 | 56 ++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++ > > 1 file changed, 56 insertions(+) > > create mode 100644 man/man2/uretprobe.2