Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2340377lqt; Mon, 22 Apr 2024 08:10:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+jpPfgj4LD9jzfnUn5RrC9bYRye99WYRcaHxWRmmXyT38ApF2ai5+sfIpJKVUmKQ7FYXTYU4EYbJtE+N+QFdBNq1gohzDvC37t6qOxg== X-Google-Smtp-Source: AGHT+IENTY94YDrgmj0BaSz4NQ9elh7sVb84MgCqA2O/xzo0mvyFj/7wqIkEHef21j0qJ6S157/r X-Received: by 2002:ac2:5f46:0:b0:518:8c8c:db4c with SMTP id 6-20020ac25f46000000b005188c8cdb4cmr5326530lfz.13.1713798599814; Mon, 22 Apr 2024 08:09:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713798599; cv=pass; d=google.com; s=arc-20160816; b=Dz7GowPAGXZPVzowGLrnRbkdjnmRoVIlza+LouozD+ZhdBXyqDV20qCIqWiYkmR4M3 POID1PH4/WbNvwh15mj2ictPxwFhi4i1c/4h5lIYzCl+X/92p7qMU68KXsSg7Gf7B6z1 cUSYOEybv13QtO/UMtD92Yq4JF4fTpYYtpDGkf8wgFMMdLjHlvs6dUx434liONZoNKEa ofliAN7kqNNObMvcuHC+liylP5Cju4PEbX/1EN+rQuEd4f7O8KF/ZG05R18sCzu87VXE wY3np3EeC62c5jTg+VS8mHJv2nY2tBRNtgQgbvJ8RJB/abnTEkL4/LMOTwkQo8G/OyXX StBQ== 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:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Dtdn6Fav/4Ury9TQm6Uv0NnMR/vVEgu13J4QF6gFZtA=; fh=jgDiti4SZVvxbx81AM9Hn4RXq+MwnWuieVFnNwjeieY=; b=0ci6FJoLAvhUNA8ylUISo0TsDVL3tlPc0J9TvW85VRumJgCLaH+Tt8hOqcB7FDtgaU V9cpspU16VMOJOEPQWEnT3ttcvlHxxLZsaCT8iZTZizOqr+MPSCrxGwU5LHbXTnUS3Cu caahkLHVZs7QQYzz6h9Uk9yjmIf/+71MMgqq+DXXfBBb425MWI4yiyzz6vV2wVPHztya vYktdKvZbtYIWVPrTjbyhEeY+Fpm7seOHsaAKN9R/6CvBJz/DcSPiH48Qlq1qunLM+Bn VV+WxkNu7Tu2joTcaPKdE55DUlAO+QA2MtSui7NIs6n/2HhfAmu5EG9s3jK9qrU32JWB 8QrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fllOCsPj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hv16-20020a17090760d000b00a55b06b2b00si2033774ejc.679.2024.04.22.08.09.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 08:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fllOCsPj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153607-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5EE8D1F226CC for ; Mon, 22 Apr 2024 15:09:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9359A146015; Mon, 22 Apr 2024 15:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fllOCsPj" 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 89B2F15250F; Mon, 22 Apr 2024 15:09:50 +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=1713798590; cv=none; b=l9vs4VMba266LMJBGGgdsYTgLZgLvNeXqRHznCMmTfmXDhweIHc3pvJAckzcVJhn4gXOdKMzk9dZ1Cj23BGz6OZn0puDpIYCTh9vfC9evcSCRlegs9p7Co3xibryGexqjojLlkUf6LSVVj8EmHUjGMV9GPwyea6nA2VZ6EyqA0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713798590; c=relaxed/simple; bh=dD+RaCJlFAvcn/MSlipnM9iqz2i1DunU7FHyskt1hFw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=Fyev5rE+Vf9EpFFmmXoG1F2eRmNPbDF9muKqlWjCykIy7qYJ3Os4uVUP7NscZShq/FuDTP/ceNrU95Au0BPhcldIY+Q1t8iQEMVIQV9Q4nodGiAY2mTcJuzqRUlVtg7Ntv9FftX/1lEOQA0xQe8urDsq1JoArBE++rulhdN2DKM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fllOCsPj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04CB0C113CC; Mon, 22 Apr 2024 15:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713798590; bh=dD+RaCJlFAvcn/MSlipnM9iqz2i1DunU7FHyskt1hFw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fllOCsPjlq5CBY03FDusf6h5mfLNopP+yd2Q32x3xjIWfF7OldDHBM3nTftFfgmQ5 Hy1iejIsX7Cotw4BPlMqsolhcxmfkcGJaC6EZzuNDabRPisdTRcf7ykNNkefccpiZg PTLuRqDzGTBJGapvQp5t5Dnop9VEl+FkIMnul1fkBa0bN5aAzz5qd/PvdecP/9VCQA QIiir5gLkO6n4ux1St+D5N2ZQoNfWI1e4nJoB0gn10z3hhOE590dpRJ9x8nepZ8PW2 4KZjMFU2C0dVy1tMXbOW2xJp6UXfubdlGXtMgBjV7r2bK3F8Y2ezp7lD06ieIgIdN4 ExQvHsQBFxWMA== Date: Tue, 23 Apr 2024 00:09:43 +0900 From: Masami Hiramatsu (Google) To: Jiri Olsa Cc: Steven Rostedt , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@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 Subject: Re: [PATCHv3 bpf-next 0/7] uprobe: uretprobe speed up Message-Id: <20240423000943.478ccf1e735a63c6c1b4c66b@kernel.org> In-Reply-To: <20240421194206.1010934-1-jolsa@kernel.org> References: <20240421194206.1010934-1-jolsa@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi Jiri, On Sun, 21 Apr 2024 21:41:59 +0200 Jiri Olsa wrote: > 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-6 are based on bpf-next/master, but path 1 and 2 are > apply-able on linux-trace.git tree probes/for-next branch. > Patch 7 is based on man-pages master. Thanks for updated! I reviewed the series and just except for the manpage, it looks good to me. Reviewed-by: Masami Hiramatsu (Google) for the series. If Linux API maintainers are OK, I can pick this in probes/for-next. (BTW, who will pick the manpage patch?) Thank you, > > v3 changes: > - added source ip check if the uretprobe syscall is called from > trampoline and sending SIGILL to process if it's not > - keep x86 compat process to use standard breakpoint > - split syscall wiring into separate change > - ran ltp and syzkaller locally, no issues found [Masami] > - building uprobe_compat binary in selftests which breaks > CI atm because of missing 32-bit delve packages, I will > need to fix that in separate changes once this is acked > - added man page change > - there were several changes so I removed acks [Oleg Andrii] > > 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, becase 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 si 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 (6): > uprobe: Wire up uretprobe system call > 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 > selftests/bpf: Add uretprobe syscall call from user space test > selftests/bpf: Add uretprobe compat test > > arch/x86/entry/syscalls/syscall_64.tbl | 1 + > arch/x86/kernel/uprobes.c | 115 ++++++++++++++++++++++++++++++ > 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/.gitignore | 1 + > tools/testing/selftests/bpf/Makefile | 6 +- > tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 123 +++++++++++++++++++++++++++++++- > tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c | 362 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > tools/testing/selftests/bpf/progs/uprobe_syscall.c | 15 ++++ > tools/testing/selftests/bpf/progs/uprobe_syscall_call.c | 15 ++++ > tools/testing/selftests/bpf/progs/uprobe_syscall_compat.c | 13 ++++ > 15 files changed, 681 insertions(+), 10 deletions(-) > create mode 100644 tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall.c > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall_call.c > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall_compat.c > > > Jiri Olsa (1): > man2: Add uretprobe syscall page > > man2/uretprobe.2 | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > create mode 100644 man2/uretprobe.2 -- Masami Hiramatsu (Google)