Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1946166lqz; Tue, 2 Apr 2024 02:33:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOdUwqrly1jPMBoRVsXiZftslUK+kYetlvkH9YK98BzLBceA7JJ+CLj9180yHuEpAYaom+chfwispXE3gauLlSMC9m9oEzUdnNCEib0g== X-Google-Smtp-Source: AGHT+IFLxLipmUq6d3MieQIWUNXyce9wj1jlmJOMOoK79X5dcvmeP9TbVnQhwHBJmI5tXpZhl0Ke X-Received: by 2002:a17:903:32cb:b0:1e0:b629:b009 with SMTP id i11-20020a17090332cb00b001e0b629b009mr13832944plr.20.1712050397426; Tue, 02 Apr 2024 02:33:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712050397; cv=pass; d=google.com; s=arc-20160816; b=FygRr6NUWN3cMu2A0NsQUZkjAHdsNx+IdibUolGUDB1Z7TDB0UcGpWIp+2C66F7Xep qJhShZ8gl4M/vaCdAsTrSkDxlJ8WAKGG4+uDhERJ27IXuJcun8rowEXfgtptH8SJGb4y lutyPiYpenynuL/FrIHWJvACwFTL3WnxXjC+Oqrg/E8O3UT4gBww8pk9BR6yvCcPAOyu XeX+AGPZIwfFDjHOq3lzTD6jcHX6WvYh56QuA/ULJV4ErZJA4asCutXiFf85RUSZ/1fN h1VZE8VcSC1dXuNOEel6orZC2nb2/muDPQYhEIwJ2XaXzR9UP2ANMf7UrNDS/AwjzuQI +FhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=BdQQaeDyAv4LR1lvE6dg6LYQ8OS0ExT7RZTMSHhVN68=; fh=WgAS3umXxbyQId9aPc2QKOeov9Gf2yKTsTTaOZ3LbMc=; b=jahAzubfq6iWJ28q34X0/ZlW/UBDEwx/AQqBxCx9rVGjP2sh42PbnbGymB686hv2pZ z1hCFIxg4PvkADfqHWC3cX1MZwnSvsVCRH4Kzw34TrkaKsjEvOH5jEsFnumAKXDFslhw 9sPK64QXDTBUTHR7t6Z9IHDZCf5vPlzfMDEboAerbrOKHDszDRqculwQzI/NDp9gvWuJ wgKRzgDVIw7rHM6gMrGFHi0fVUEx2I0y60kigi33vPCP7FMsnWrHEKhxVMYzhMD1t0L+ v1NbE0oWPbUFMMH/tGEORZoJvRDOPX0lF8m6pfeBvKulT2hs4fjtlbJRXhQ3jszTXB/2 nPpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KDoZzXj7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k7-20020a170902d58700b001e23cbf3299si7906656plh.84.2024.04.02.02.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 02:33:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KDoZzXj7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-127636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127636-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 1A7B6284D72 for ; Tue, 2 Apr 2024 09:33:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03A0058235; Tue, 2 Apr 2024 09:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KDoZzXj7" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 201814F217; Tue, 2 Apr 2024 09:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712050388; cv=none; b=rYhpowNBTmab74Yd+7X6AmSH+ggKcowDWJnpoJBguvjbjswY3XQgEi610cjokzZtykdX6CgYaZyP9qFZilNqdYzWTvM+ZjNVSnHFZjBjHaFoZT7u3aO/8iENQI3iDk3F77qmRgRzTMU7v+Mo10Zd/H5Miopt5i7ofxoVIKYOr2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712050388; c=relaxed/simple; bh=IgkvBtIf+p5gfrHO1hbAPX6VVhQCtHheKJSsq422Ohg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DvRzNtHJoePmtGL03ylLO6DAItCrNKmmzmThTemGFR+RLRD9oprJUAeErAEl65hhiXXFAW5jSBx72aIkaP8/RwaSbGCJNuCxB5P7QuE9o7wAAWTNSC9QeXRiZhRY6BME5iT3VDtLPX/qdxJ69NiLvWT/6R6k33dS2U/cGXn5fOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KDoZzXj7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B774C433C7; Tue, 2 Apr 2024 09:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712050387; bh=IgkvBtIf+p5gfrHO1hbAPX6VVhQCtHheKJSsq422Ohg=; h=From:To:Cc:Subject:Date:From; b=KDoZzXj7dTzuYm1CKMZamE/RUsZY+nMoJkM0O6MFosFfD3Au/4f2WJt0gzBdzNZiP uNRoJa4nYkkEG9PPWUU7YOeWyMNKGErfTl+WXuV4EvO3Xna4mw0Z2n07Pd6sZC4f0o hwlJNlTlDgmyhSkRzLBBLIbE2nxK3kDn30qRO1jwZ/Kjktkco+K/da6nxCTXV2Qxkl 7aR+cCU8BJ2RGSP11dhgKaEEiBmPe2C8o77WubOaNvNegTgwg0mfbr7VUyHl/vi9vf hPmDCGBPu84n2pCjdgt8WIjEk5jSkZZGqIXdpSuh2OIu33nVP0nyyP1qFTtXc8TU2f cSR997kVwZseg== From: Jiri Olsa To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org Subject: [PATCHv2 0/3] uprobe: uretprobe speed up Date: Tue, 2 Apr 2024 11:32:59 +0200 Message-ID: <20240402093302.2416467-1-jolsa@kernel.org> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. I added extra selftests to check on registers values before and after uretprobe to make sure the syscall saves all the needed regs and that uprobe consumer can still change registers. Patch 1 is based on: https://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git probes/for-next and patches 2,3 are based on bpf-next/master and can be taken separately through bpf-next tree without patch 1. v2 changes: - reposted to proper tracing mailing list [Masami] - renamed selftest trigger functions [Andrii] - kept bpf_testmod register call pattern [Andrii] - added acks [Andrii/Oleg] thanks, jirka [0] https://lore.kernel.org/bpf/ZeCXHKJ--iYYbmLj@krava/ --- Jiri Olsa (3): uprobe: Add uretprobe syscall to speed up return probe selftests/bpf: Add uretprobe syscall test for regs integrity selftests/bpf: Add uretprobe syscall test for regs changes arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/x86/kernel/uprobes.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/syscalls.h | 2 ++ include/linux/uprobes.h | 2 ++ include/uapi/asm-generic/unistd.h | 5 +++- kernel/events/uprobes.c | 18 +++++++++--- kernel/sys_ni.c | 2 ++ tools/include/linux/compiler.h | 4 +++ tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/uprobe_syscall.c | 15 ++++++++++ 11 files changed, 478 insertions(+), 6 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall.c