bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	x86@kernel.org
Subject: [PATCH bpf-next 0/3] uprobe: uretprobe speed up
Date: Wed, 27 Mar 2024 11:20:33 +0100	[thread overview]
Message-ID: <20240327102036.543283-1-jolsa@kernel.org> (raw)

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 bpf selftest to check on registers values before and
after uretprobe to make sure the syscall saves all the needed regs.

changes from RFC:
  - using __NR_uretprobe instead hardcoded syscall value [Andrii]
  - using __builtin_memcpy to copy registers [Andrii]
  - adding more comments
  - Oleg provided the code that enabled the syscall to take the
    sysret path, which made it lot faster [Oleg]
  - nocf_check attribute change was sent separatelly
  - added test for checking up changed registers in uprobe consumer

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   | 119 ++++++++++++++++++++++++++++++++++++++++++++++++-
 tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/uprobe_syscall.c      |  15 +++++++
 11 files changed, 475 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

             reply	other threads:[~2024-03-27 10:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 10:20 Jiri Olsa [this message]
2024-03-27 10:20 ` [PATCH bpf-next 1/3] uprobe: Add uretprobe syscall to speed up return probe Jiri Olsa
2024-03-27 11:45   ` Oleg Nesterov
2024-03-29 22:24   ` Andrii Nakryiko
2024-03-27 10:20 ` [PATCH bpf-next 2/3] selftests/bpf: Add uretprobe syscall test for regs integrity Jiri Olsa
2024-03-29 22:30   ` Andrii Nakryiko
2024-03-29 22:34     ` Andrii Nakryiko
2024-03-31 19:37     ` Jiri Olsa
2024-04-01  9:47       ` Masami Hiramatsu
2024-03-27 10:20 ` [PATCH bpf-next 3/3] selftests/bpf: Add uretprobe syscall test for regs changes Jiri Olsa
2024-03-29 22:34   ` Andrii Nakryiko
2024-03-31 19:32     ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240327102036.543283-1-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).