public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Kyle Huey <me@kylehuey.com>
Cc: Kyle Huey <khuey@kylehuey.com>,
	linux-kernel@vger.kernel.org,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Marco Elver <elver@google.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Robert O'Callahan <robert@ocallahan.org>,
	bpf@vger.kernel.org
Subject: Re: [RESEND PATCH v5 0/4] Combine perf and bpf for fast eval of hw breakpoint conditions]
Date: Wed, 10 Apr 2024 06:37:56 +0200	[thread overview]
Message-ID: <ZhYXpNu0c/rcjf0r@gmail.com> (raw)
In-Reply-To: <20240214173950.18570-1-khuey@kylehuey.com>


* Kyle Huey <me@kylehuey.com> wrote:

> Peter, Ingo, could you take a look at this?
> 
> ----
> 
> 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 or sending the perf event's 
> SIGTRAP. This patch set redesigns __perf_overflow_handler() and 
> bpf_overflow_handler() so that the former invokes the latter directly 
> when appropriate rather than through the generic overflow handler 
> machinery, passes the return code of the BPF program back to 
> __perf_overflow_handler() to allow it to decide whether to execute the 
> regular overflow handler, reorders bpf_overflow_handler() and the side 
> effects of perf event overflow, changes __perf_overflow_handler() to 
> suppress those side effects if the BPF program returns zero, and adds a 
> selftest.

I suppose this optimization makes sense.

Patch quality still needs to be improved though - see my review comments.

Thanks,

	Ingo

      parent reply	other threads:[~2024-04-10  4:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 17:39 [RESEND PATCH v5 0/4] Combine perf and bpf for fast eval of hw breakpoint conditions] Kyle Huey
2024-02-14 17:39 ` [RESEND PATCH v5 1/4] perf/bpf: Call bpf handler directly, not through overflow machinery Kyle Huey
2024-02-16  0:11   ` Andrii Nakryiko
2024-04-10  4:31   ` Ingo Molnar
2024-04-11 12:11     ` Kyle Huey
2024-04-12  1:47       ` Kyle Huey
2024-02-14 17:39 ` [RESEND PATCH v5 2/4] perf/bpf: Remove unneeded uses_default_overflow_handler Kyle Huey
2024-02-16  0:12   ` Andrii Nakryiko
2024-04-10  4:35   ` Ingo Molnar
2024-02-14 17:39 ` [RESEND PATCH v5 3/4] perf/bpf: Allow a bpf program to suppress all sample side effects Kyle Huey
2024-02-16  0:13   ` Andrii Nakryiko
2024-02-16  1:59     ` Kyle Huey
2024-02-14 17:39 ` [RESEND PATCH v5 4/4] selftest/bpf: Test a perf bpf program that suppresses " Kyle Huey
2024-02-16  0:24 ` [RESEND PATCH v5 0/4] Combine perf and bpf for fast eval of hw breakpoint conditions] Andrii Nakryiko
2024-04-10  4:37 ` Ingo Molnar [this message]

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=ZhYXpNu0c/rcjf0r@gmail.com \
    --to=mingo@kernel.org \
    --cc=acme@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=elver@google.com \
    --cc=jolsa@kernel.org \
    --cc=khuey@kylehuey.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kylehuey.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=robert@ocallahan.org \
    --cc=yonghong.song@linux.dev \
    /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