Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp114186lqm; Mon, 10 Jun 2024 14:47:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXITH1j4EE+1mlemEjX/nvAHoN4BUwsnTIH/4ZodOaiDJWJq3WCyPL6CMn7eeCXi/pAIAqKrxos4IbEI1omduQMULJ2ZKFv5QW1FlRqA== X-Google-Smtp-Source: AGHT+IGwTWRflzKK6R71j7y2NuORVNDJmk1x4q3ArA3eRv+bAcbeWoGufvWQohy/e3Mvq7WXrbkv X-Received: by 2002:a05:6512:33c9:b0:52c:944f:1f5a with SMTP id 2adb3069b0e04-52c944f2490mr61931e87.27.1718056021699; Mon, 10 Jun 2024 14:47:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718056021; cv=pass; d=google.com; s=arc-20160816; b=FVdZLskoNIt+AamG2Kj6GvhLowMfCkiSrehCA6SCB/+jogKqGY7Q1kRp8xpJIW9RT9 WDuC477er9bY6MTxxG6seV2gREoBzhwsC2ig/kkX+aqVtutaUzz5A43Xe1WD8VXtje30 Uachn8rTYzuiwZ3QPvLl0bdImaYMWJE77G1L8d56sMZd0rLoMuMpxP4Al5JcyRBJl3vY lBwCL/1ztctbAvRs9AKx1r68qHi+ocFK7EamFWPZSNbikOhfDxBep1kfHuhyrMmHzpDt APHgLeKJzT0Ye+GTcCIQq9YZLeR3CpSmf8IQPsaTBG3euWzcSFFmYaqyqGENOVyieQ5n 7phQ== 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=kF3YHfTO3nEDKUO+tr+xlmgvNpfjWK3ak0NSZSLh9Fk=; fh=8lJvCMqlgvPFV/4iL7XxaKPeczjuU0BTiprQj99cTLQ=; b=TGxVI15BP0/TCEdKUEJkuZ165ndiQft5HSVYAGJ9CCuPgF69ax7dKLmgvTBJopefV/ xcByBFEjazJEi/VdKP1EB9rYj8M1QOWyydfXYN9rRmWkkDlKZ7fJwYehHRkz8G4LYVET I5VYPj1/9bUV/TD+CRG/kX9iX5fh7d1uhIDwKzdlhjCNNZt34PLp69mWBqtRRppF3w+v A66FLDifVavI+ZS20nGh7TTCjDoV0Y6RshupytrL0rMQd2rHnVIocCdOf6uFtT8qiwsn bteWwQKHkKLSTHhrjXHlzcic9VCsWjef0ElrdLCE+8O58mCh/VYtKbBO3wd8AWEyTS5k gsCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WBcfXOCN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208940-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. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f0fc37406si225954966b.721.2024.06.10.14.47.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 14:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WBcfXOCN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208940-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 4172D1F2287B for ; Mon, 10 Jun 2024 21:47:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BF8212F5B6; Mon, 10 Jun 2024 21:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WBcfXOCN" 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 8265D6AB6; Mon, 10 Jun 2024 21:46:49 +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=1718056009; cv=none; b=tNSGxUWQG81EUWqxlOtzAX48vh8/BmAtCG7ERX4SNj+jfgAZu0TtbuHmq8qPnA/N1JBc1WWi/8m7a8IM3TKE0gyss9ojTOj5+ICsnnNCwwQMXCuYePSr9kb604YcYoTfom2k1NhyR+B+tDyOJFKSRlJdm6sG4+gdIJekCvp8JkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718056009; c=relaxed/simple; bh=7OBszLOSVa3SJfz0oOSikJ/3PkDA/j9tpVJwjUuZJ0A=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=rh3L+XGkEB2suvyMvj1f+1IvbVkCxx+tMmAi4tcNBQgjj+LRymqR6UlcNcok2kSAp9zDANQFr7NE3oipOAsFcyelbpCwQViWil+ByWGTQSTNCY5qOvBNX+s2HxFYvqePiVHIvDQL00LNvu/Vwz8QDCYNPDDZQOoo3JbSz2E0Wp8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WBcfXOCN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4D7AC2BBFC; Mon, 10 Jun 2024 21:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718056009; bh=7OBszLOSVa3SJfz0oOSikJ/3PkDA/j9tpVJwjUuZJ0A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WBcfXOCNRjJNH0sAOgsdbMUHjfuTr2hvUI7/L/gqO6jMxMuMeDGQqnSUI+HvIRiOL t1rmbSCDelYJKxDpXwfxqkDipUaJJzm4XJorWD75OYdnbfjCP0Vi+ygdzINAs83dLs ObMnZ57MaxLTp2iX9CgyKAXpsUuEBiHuNVdtz6q3/zuEkmLe/WA/MRh+I0jzaqXxNE WSp5X74zRBORhkVL/x8Qqha2lLuOnoKLd3E+KRlzeYIgsnpJAo5NS+jeftgs6mnsga os8Vwy7HqZRb4Ffi2bbams5WeVi0OHEbHW/SCUcr7AwG2LSpEnGFVp9Ufizt5RiZN5 d0BbvfQZvlvbw== Date: Tue, 11 Jun 2024 06:46:41 +0900 From: Masami Hiramatsu (Google) To: Andrii Nakryiko Cc: Steven Rostedt , 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 Subject: Re: [PATCHv7 bpf-next 0/9] uprobe: uretprobe speed up Message-Id: <20240611064641.9021829459211782902e4fb2@kernel.org> In-Reply-To: References: <20240523121149.575616-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=UTF-8 Content-Transfer-Encoding: 8bit On Wed, 5 Jun 2024 09:42:45 -0700 Andrii Nakryiko wrote: > On Fri, May 31, 2024 at 10:52 AM Andrii Nakryiko > wrote: > > > > On Thu, May 23, 2024 at 5:11 AM 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-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. Sorry about late reply. I agree that this is OK to go, since no other comments. Let me pick this up to probes/for-next branch. > > 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. I think it would be better to include those patches together in linux-tree. Can you review and ack to the last patch ? ([9/9]) Thank you, > > 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_syscall.c > > > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall.c > > > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall_executed.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 -- Masami Hiramatsu (Google)