[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250310170320.GC26382@redhat.com>
Date: Mon, 10 Mar 2025 18:03:21 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-arm-kernel@...ts.infradead.org,
linux-trace-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>,
Russell King <linux@...linux.org.uk>,
Masami Hiramatsu <mhiramat@...nel.org>,
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>,
Tong Tiangen <tongtiangen@...wei.com>
Subject: Re: [PATCH -next v1 3/3] kernel/events/uprobes:
uprobe_write_opcode() rewrite
On 03/04, David Hildenbrand wrote:
>
> uprobe_write_opcode() does some pretty low-level things that really, it
> shouldn't be doing:
Agreed. Thanks again for doing this.
David, as I said, I can't review. I don't understand this mm/folio magic
with or without your changes.
However. With your changes the code looks "better" and more understandable
to me. So I'd vote for your patches even if I can't ack them.
But I'd like to ask some stupid (no, really) questions.
__uprobe_write_opcode() does:
/* We're done if we don't find an anonymous folio when unregistering. */
if (!folio_test_anon(folio))
return is_register ? -EFAULT : 0;
Yes, but we do not expect !folio_test_anon() if register == true, right?
See also below.
/* Verify that the page content is still as expected. */
if (verify_opcode(fw->page, opcode_vaddr, &opcode) <= 0) {
set_pte_at(vma->vm_mm, vaddr, fw->ptep, fw->pte);
return -EAGAIN;
}
The caller, uprobe_write_opcode(), has already called verify_opcode(),
why do we need to re-check?
But whatever reason we have. Can we change uprobe_write_opcode() to
"delay" put_page() and instead of
/* Walk the page tables again, to perform the actual update. */
folio = folio_walk_start(&fw, vma, vaddr, 0);
if (folio) {
ret = __uprobe_write_opcode(vma, &fw, folio, opcode_vaddr,
opcode);
folio_walk_end(&fw, vma);
} else {
ret = -EAGAIN;
}
do something like
/* Walk the page tables again, to perform the actual update. */
ret = -EAGAIN;
folio = folio_walk_start(&fw, vma, vaddr, 0);
if (folio) {
if (fw.page == page) {
WARN_ON(is_register && !folio_test_anon(folio));
ret = __uprobe_write_opcode(vma, &fw, folio, opcode_vaddr,
opcode);
}
folio_walk_end(&fw, vma);
}
?
Once again, I am not trying to review. I am trying to understand the
basics of your code.
Thanks,
Oleg.
Powered by blists - more mailing lists