Thread (37 messages) 37 messages, 11 authors, 2022-06-15

Re: [PATCH] kprobes: Enable tracing for mololithic kernel images

From: Jarkko Sakkinen <jarkko@kernel.org>
Date: 2022-06-09 13:01:29
Also in: linux-mips, linux-modules, linux-riscv, linux-s390, lkml, sparclinux

oy@kernel.org>, Jarkko Sakkinen [off-list ref], Sami Tolvanen [off-list ref], "Naveen N. Rao" [off-list ref], Marco Elver [off-list ref], Kees Cook [off-list ref], Steven Rostedt [off-list ref], Nathan Chancellor [off-list ref], "Russell King \(Oracle\)" [off-list ref], Mark Brown [off-list ref], Borislav Petkov [off-list ref], Alexander Egorenkov [off-list ref], Thomas Bogendoerfer [off-list ref], Parisc List [off-list ref], Nathaniel McCallum [off-list ref], Dmitry Torokhov [off-list ref], "David S. Miller" [off-list ref], "Kirill A. Shutemov" [off-list ref], Tobias Huschle [off-list ref], "Peter Zijlstra \(Intel\)" [off-list ref], "H. Peter Anvin" [off-list ref], sparclinux [off-list ref], Tiezhu Yang [off-list ref], Miroslav Benes [off-list ref], Chen Zhongjin <chenzhongjin@hu
 awei.com>, Ard Biesheuvel [off-list ref], the arch/x86 maintainers [off-list ref], Russell King [off-list ref], linux-riscv [off-list ref], Ingo Molnar [off-list ref], Aaron Tomlin [off-list ref], Albert Ou [off-list ref], Heiko Carstens [off-list ref], Liao Chang [off-list ref], Paul Walmsley [off-list ref], Josh Poimboeuf [off-list ref], Thomas Richter [off-list ref], "open list:BROADCOM NVRAM DRIVER" [off-list ref], Changbin Du [off-list ref], Palmer Dabbelt [off-list ref], linuxppc-dev [off-list ref], linux-modules@vger.kernel.org
Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org
Sender: "Linuxppc-dev" [off-list ref]

On Wed, Jun 08, 2022 at 11:21:15PM +0900, Masami Hiramatsu wrote:
Hi Jarkko,

On Wed, 8 Jun 2022 08:25:38 +0300
Jarkko Sakkinen [off-list ref] wrote:
quoted
On Wed, Jun 08, 2022 at 10:35:42AM +0800, Guo Ren wrote:
quoted
.

On Wed, Jun 8, 2022 at 8:02 AM Jarkko Sakkinen [off-list ref] wrote:
quoted
Tracing with kprobes while running a monolithic kernel is currently
impossible because CONFIG_KPROBES is dependent of CONFIG_MODULES.  This
dependency is a result of kprobes code using the module allocator for the
trampoline code.

Detaching kprobes from modules helps to squeeze down the user space,
e.g. when developing new core kernel features, while still having all
the nice tracing capabilities.

For kernel/ and arch/*, move module_alloc() and module_memfree() to
module_alloc.c, and compile as part of vmlinux when either CONFIG_MODULES
or CONFIG_KPROBES is enabled.  In addition, flag kernel module specific
code with CONFIG_MODULES.

As the result, kprobes can be used with a monolithic kernel.
It's strange when MODULES is n, but vmlinux still obtains module_alloc.

Maybe we need a kprobe_alloc, right?
Perhaps not the best name but at least it documents the fact that
they use the same allocator.

Few years ago I carved up something "half-way there" for kprobes,
and I used the name text_alloc() [*].

[*] https://lore.kernel.org/all/20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com/ (local) 
Yeah, I remember that. Thank you for updating your patch!
I think the idea (split module_alloc() from CONFIG_MODULE) is good to me.
If module support maintainers think this name is not good, you may be
able to rename it as text_alloc() and make the module_alloc() as a
wrapper of it.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
for kprobe side.
Thanks a lot! 

If I split that code into its own patch with no code changes,
can I attach this to the patch? I.e. most likely I'll split
arch's into their own patches.
Thank you,

-- 
Masami Hiramatsu (Google) [off-list ref]
BR, Jarkko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help