[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240604122548.359952-1-david@redhat.com>
Date: Tue, 4 Jun 2024 14:25:45 +0200
From: David Hildenbrand <david@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: linux-mm@...ck.org,
linux-arm-kernel@...ts.infradead.org,
linux-perf-users@...r.kernel.org,
David Hildenbrand <david@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Guillaume Morin <guillaume@...infr.org>,
Russell King <linux@...linux.org.uk>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>
Subject: [PATCH RFC 0/3] kernel/events/uprobes: uprobe_write_opcode() rewrite
Against mm/mm-unstable.
There is interest in supporting uprobes on hugetlb pages [1]. Having
uprobe_write_opcode() implement COW-breaking itself is really far from
optimal, and having to add hugetlb COW-breaking to implement hugetlb
support really does sound wrong.
Further, I think the current code doesn't really handle some things
properly (see patch #3) when replacing/zapping pages.
Let's rewrite it, to leave COW-breaking to the fault handler, and handle
registration/unregistration by temporarily unmapping the anonymous page,
modifying it, and mapping it again. We still have to implement
zapping of anonymous pages ourselves, unfortunately.
Note that we now won't have to allocate another anonymous folio when
unregistering (which will be beneficial for hugetlb as well), we can simply
modify the already-mapped one from the registration (if any). When
registering a uprobe, we'll first trigger a write fault to break COW to
then modify the already-mapped page.
Briefly sanity tested with perf:
[root@...alhost ~]# perf probe -x /usr/bin/bash -a main
...
[root@...alhost ~]# perf record -e probe_bash:main -aR sleep 10 &
[1] 2196
[root@...alhost ~]# bash
[root@...alhost ~]# exit
exit
[root@...alhost ~]# bash
[root@...alhost ~]# exit
exit
[root@...alhost ~]# [ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.287 MB perf.data (8 samples) ]
...
[root@...alhost ~]# perf report --stdio
# To display the perf.data header info, please use --header/--header-only optio>
#
#
# Total Lost Samples: 0
#
# Samples: 8 of event 'probe_bash:main'
# Event count (approx.): 8
#
# Overhead Command Shared Object Symbol
# ........ ........... ............. ........
#
75.00% grepconf.sh bash [.] main
25.00% bash bash [.] main
...
Are there any uprobe tests / benchmarks that are worth running?
[1] https://lkml.kernel.org/r/ZiK50qob9yl5e0Xz@bender.morinfr.org
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Guillaume Morin <guillaume@...infr.org>
Cc: Russell King <linux@...linux.org.uk>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: "Liang, Kan" <kan.liang@...ux.intel.com>
David Hildenbrand (3):
kernel/events/uprobes: pass VMA instead of MM to install_breakpoint()
kernel/events/uprobes: pass VMA to set_swbp(), set_orig_insn() and
uprobe_write_opcode()
kernel/events/uprobes: uprobe_write_opcode() rewrite
arch/arm/probes/uprobes/core.c | 4 +-
include/linux/uprobes.h | 6 +-
kernel/events/uprobes.c | 387 +++++++++++++++++++--------------
3 files changed, 223 insertions(+), 174 deletions(-)
base-commit: 065d3634d60843b8e338d405b844cc7f2e5e1c66
--
2.45.1
Powered by blists - more mailing lists