From: Marco Elver <elver@google.com>
To: Marco Elver <elver@google.com>
Cc: peterz@infradead.org, alexander.shishkin@linux.intel.com,
acme@kernel.org, mingo@redhat.com, jolsa@redhat.com,
mark.rutland@arm.com, namhyung@kernel.org, tglx@linutronix.de,
glider@google.com, viro@zeniv.linux.org.uk, arnd@arndb.de,
christian@brauner.io, dvyukov@google.com, jannh@google.com,
axboe@kernel.dk, mascasa@google.com, pcc@google.com,
irogers@google.com, oleg@redhat.com, kasan-dev@googlegroups.com,
linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, x86@kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v4 00/10] Add support for synchronous signals on perf events
Date: Tue, 11 Jun 2024 11:18:57 +0200 [thread overview]
Message-ID: <ZmgWgcf3x-vQYCon@elver.google.com> (raw)
In-Reply-To: <20210408103605.1676875-1-elver@google.com>
On Thu, Apr 08, 2021 at 12:35PM +0200, Marco Elver wrote:
[...]
> Motivation and Example Uses
> ---------------------------
>
> 1. Our immediate motivation is low-overhead sampling-based race
> detection for user space [1]. By using perf_event_open() at
> process initialization, we can create hardware
> breakpoint/watchpoint events that are propagated automatically
> to all threads in a process. As far as we are aware, today no
> existing kernel facility (such as ptrace) allows us to set up
> process-wide watchpoints with minimal overheads (that are
> comparable to mprotect() of whole pages).
>
> 2. Other low-overhead error detectors that rely on detecting
> accesses to certain memory locations or code, process-wide and
> also only in a specific set of subtasks or threads.
>
> [1] https://llvm.org/devmtg/2020-09/slides/Morehouse-GWP-Tsan.pdf
>
> Other ideas for use-cases we found interesting, but should only
> illustrate the range of potential to further motivate the utility (we're
> sure there are more):
>
> 3. Code hot patching without full stop-the-world. Specifically, by
> setting a code breakpoint to entry to the patched routine, then
> send signals to threads and check that they are not in the
> routine, but without stopping them further. If any of the
> threads will enter the routine, it will receive SIGTRAP and
> pause.
>
> 4. Safepoints without mprotect(). Some Java implementations use
> "load from a known memory location" as a safepoint. When threads
> need to be stopped, the page containing the location is
> mprotect()ed and threads get a signal. This could be replaced with
> a watchpoint, which does not require a whole page nor DTLB
> shootdowns.
>
> 5. Threads receiving signals on performance events to
> throttle/unthrottle themselves.
>
> 6. Tracking data flow globally.
For future reference:
I often wonder what happened to some new kernel feature, and how people
are using it. I'm guessing there must be other users of "synchronous
signals on perf events" somewhere by now (?), but the reason the whole
thing started was because points #1 and #2 above.
Now 3 years later we were able to open source a framework that does #1
and #2 and more: https://github.com/google/gwpsan - "A framework for
low-overhead sampling-based dynamic binary instrumentation, designed for
implementing various bug detectors (also called "sanitizers") suitable
for production uses. GWPSan does not modify the executed code, but
instead performs dynamic analysis from signal handlers."
Documentation is sparse, it's still in development, and probably has
numerous sharp corners right now...
That being said, the code demonstrates how low-overhead "process-wide
synchronous event handling" thanks to perf events can be used to
implement crazier things outside the realm of performance profiling.
Thanks!
-- Marco
prev parent reply other threads:[~2024-06-11 9:19 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 10:35 [PATCH v4 00/10] Add support for synchronous signals on perf events Marco Elver
2021-04-08 10:35 ` [PATCH v4 01/10] perf: Rework perf_event_exit_event() Marco Elver
2021-04-16 15:01 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2021-04-08 10:35 ` [PATCH v4 02/10] perf: Apply PERF_EVENT_IOC_MODIFY_ATTRIBUTES to children Marco Elver
2021-04-16 15:01 ` [tip: perf/core] " tip-bot2 for Marco Elver
2021-04-08 10:35 ` [PATCH v4 03/10] perf: Support only inheriting events if cloned with CLONE_THREAD Marco Elver
2021-04-08 10:35 ` [PATCH v4 04/10] perf: Add support for event removal on exec Marco Elver
2021-04-16 15:01 ` [tip: perf/core] " tip-bot2 for Marco Elver
2021-04-08 10:36 ` [PATCH v4 05/10] signal: Introduce TRAP_PERF si_code and si_perf to siginfo Marco Elver
2021-04-16 15:01 ` [tip: perf/core] " tip-bot2 for Marco Elver
2021-04-20 21:26 ` [PATCH v4 05/10] " Marek Szyprowski
2021-04-20 22:42 ` Marco Elver
2021-04-21 6:21 ` Marek Szyprowski
2021-04-21 7:35 ` Marek Szyprowski
2021-04-21 8:11 ` Marco Elver
2021-04-21 9:35 ` Marek Szyprowski
2021-04-21 10:57 ` Marek Szyprowski
2021-04-21 11:03 ` Marco Elver
2021-04-21 13:19 ` Marek Szyprowski
2021-04-21 15:11 ` Marco Elver
2021-04-21 16:27 ` Marco Elver
2021-04-21 18:23 ` Marco Elver
2021-04-22 6:12 ` Marek Szyprowski
2021-04-22 6:47 ` Marco Elver
2021-04-22 8:16 ` Jon Hunter
2021-04-26 7:35 ` Alexander Egorenkov
2021-04-21 15:07 ` Jon Hunter
2021-04-08 10:36 ` [PATCH v4 06/10] perf: Add support for SIGTRAP on perf events Marco Elver
2021-04-08 10:36 ` [PATCH v4 07/10] selftests/perf_events: Add kselftest for process-wide sigtrap handling Marco Elver
2021-04-16 15:01 ` [tip: perf/core] " tip-bot2 for Marco Elver
2021-04-08 10:36 ` [PATCH v4 08/10] selftests/perf_events: Add kselftest for remove_on_exec Marco Elver
2021-04-16 15:01 ` [tip: perf/core] " tip-bot2 for Marco Elver
2021-04-08 10:36 ` [PATCH v4 09/10] tools headers uapi: Sync tools/include/uapi/linux/perf_event.h Marco Elver
2021-04-08 10:36 ` [PATCH v4 10/10] perf test: Add basic stress test for sigtrap handling Marco Elver
2021-04-14 8:37 ` [PATCH v4 00/10] Add support for synchronous signals on perf events Peter Zijlstra
2024-06-11 9:18 ` Marco Elver [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=ZmgWgcf3x-vQYCon@elver.google.com \
--to=elver@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=christian@brauner.io \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=irogers@google.com \
--cc=jannh@google.com \
--cc=jolsa@redhat.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mascasa@google.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=pcc@google.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox