All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyle Huey <me@kylehuey.com>
To: Kyle Huey <khuey@kylehuey.com>, linux-kernel@vger.kernel.org
Cc: Robert O'Callahan <robert@ocallahan.org>, bpf@vger.kernel.org
Subject: [PATCH 0/2] Combine perf and bpf for fast eval of hw breakpoint conditions
Date: Mon,  4 Dec 2023 12:14:04 -0800	[thread overview]
Message-ID: <20231204201406.341074-1-khuey@kylehuey.com> (raw)

rr, a userspace record and replay debugger[0], replays asynchronous events
such as signals and context switches by essentially[1] setting a breakpoint
at the address where the asynchronous event was delivered during recording
with a condition that the program state matches the state when the event
was delivered.

Currently, rr uses software breakpoints that trap (via ptrace) to the
supervisor, and evaluates the condition from the supervisor. If the
asynchronous event is delivered in a tight loop (thus requiring the
breakpoint condition to be repeatedly evaluated) the overhead can be
immense. A patch to rr that uses hardware breakpoints via perf events with
an attached bpf program to reject breakpoint hits where the condition is
not satisfied reduces rr's replay overhead by 94% on a pathological (but a
real customer-provided, not contrived) rr trace.

The only obstacle to this approach is that while the kernel allows a bpf
program to suppress sample output when a perf event overflows it does not
suppress signalling the perf event fd. This appears to be a simple
oversight in the code. This patch set fixes that oversight and adds a
selftest.

[0] https://rr-project.org/
[1] Various optimizations exist to skip as much as execution as possible
before setting a breakpoint, and to determine a set of program state that
is practical to check and verify.



             reply	other threads:[~2023-12-04 20:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 20:14 Kyle Huey [this message]
2023-12-04 20:14 ` [PATCH 1/2] perf/bpf: Allow a bpf program to suppress I/O signals Kyle Huey
2023-12-04 22:18   ` Andrii Nakryiko
2023-12-05 11:16     ` Jiri Olsa
2023-12-05 18:07       ` Namhyung Kim
2023-12-05 18:16         ` Marco Elver
2023-12-05 18:23           ` Kyle Huey
2023-12-05 18:26           ` Namhyung Kim
2023-12-05 19:19         ` Kyle Huey
2023-12-04 20:14 ` [PATCH 2/2] selftest/bpf: Test returning zero from a perf bpf program suppresses SIGIO Kyle Huey
2023-12-04 22:14   ` Andrii Nakryiko
2023-12-05 18:21     ` Kyle Huey
2023-12-05 11:17   ` Jiri Olsa
2023-12-05 16:54   ` Yonghong Song
2023-12-05 17:52     ` Kyle Huey

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=20231204201406.341074-1-khuey@kylehuey.com \
    --to=me@kylehuey.com \
    --cc=bpf@vger.kernel.org \
    --cc=khuey@kylehuey.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robert@ocallahan.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.