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

- From: Masami Hiramatsu (Google) \<mhiramat@kernel.org\>
- Date: 2022-06-08 14:21:52 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2022/06/1812196
- Thread: https://ratatoskr.run/linux-mips/2022/06/1811301/t.md

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

Hi Jarkko,

On Wed, 8 Jun 2022 08:25:38 +0300
Jarkko Sakkinen [ref] wrote:

> On Wed, Jun 08, 2022 at 10:35:42AM +0800, Guo Ren wrote:
> > .
> > 
> > On Wed, Jun 8, 2022 at 8:02 AM Jarkko Sakkinen [ref] wrote:
> > >
> > > 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/ 

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.

Thank you,

-- 
Masami Hiramatsu (Google) [ref]
```
