[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW6iUieQvA6KqzSLgtxmjkVSWCuVwNA338DATb_myHxo7w@mail.gmail.com>
Date: Wed, 8 Jun 2022 09:12:34 -0700
From: Song Liu <song@...nel.org>
To: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Jarkko Sakkinen <jarkko@...nel.org>, Guo Ren <guoren@...nel.org>,
Jarkko Sakkinen <jarkko@...fian.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Nathaniel McCallum <nathaniel@...fian.com>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
"James E.J. Bottomley" <James.Bottomley@...senpartnership.com>,
Helge Deller <deller@....de>,
Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
"David S. Miller" <davem@...emloft.net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"the arch/x86 maintainers" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"Naveen N. Rao" <naveen.n.rao@...ux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@...el.com>,
Luis Chamberlain <mcgrof@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Kees Cook <keescook@...omium.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Nathan Chancellor <nathan@...nel.org>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Mark Rutland <mark.rutland@....com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Marco Elver <elver@...gle.com>,
Dan Li <ashimida@...ux.alibaba.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Ard Biesheuvel <ardb@...nel.org>,
"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Linus Walleij <linus.walleij@...aro.org>,
Chen Zhongjin <chenzhongjin@...wei.com>,
Nicolas Pitre <nico@...xnic.net>,
Mark Brown <broonie@...nel.org>,
Luis Machado <luis.machado@...aro.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Joey Gouly <joey.gouly@....com>,
Masahiro Yamada <masahiroy@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrey Konovalov <andreyknvl@...il.com>,
Kefeng Wang <wangkefeng.wang@...wei.com>,
Atsushi Nemoto <anemo@....ocn.ne.jp>,
Guenter Roeck <linux@...ck-us.net>,
Dave Anglin <dave.anglin@...l.net>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Alexei Starovoitov <ast@...nel.org>,
Nicholas Piggin <npiggin@...il.com>,
Daniel Axtens <dja@...ens.net>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
Jordan Niethe <jniethe5@...il.com>,
Anup Patel <anup@...infault.org>,
Atish Patra <atishp@...shpatra.org>,
Changbin Du <changbin.du@...el.com>,
Heiko Stuebner <heiko@...ech.de>,
Liao Chang <liaochang1@...wei.com>,
Philipp Tomsich <philipp.tomsich@...ll.eu>,
Wu Caize <zepan@...eed.com>,
Emil Renner Berthing <kernel@...il.dk>,
Alexander Egorenkov <egorenar@...ux.ibm.com>,
Thomas Richter <tmricht@...ux.ibm.com>,
Tobias Huschle <huschle@...ux.ibm.com>,
Ilya Leoshkevich <iii@...ux.ibm.com>,
Tom Lendacky <thomas.lendacky@....com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Michael Roth <michael.roth@....com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Javier Martinez Canillas <javierm@...hat.com>,
Miroslav Benes <mbenes@...e.cz>,
André Almeida <andrealmeid@...lia.com>,
Tiezhu Yang <yangtiezhu@...ngson.cn>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Aaron Tomlin <atomlin@...hat.com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
"open list:BROADCOM NVRAM DRIVER" <linux-mips@...r.kernel.org>,
Parisc List <linux-parisc@...r.kernel.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
linux-riscv <linux-riscv@...ts.infradead.org>,
linux-s390 <linux-s390@...r.kernel.org>,
sparclinux <sparclinux@...r.kernel.org>,
linux-modules@...r.kernel.org
Subject: Re: [PATCH] kprobes: Enable tracing for mololithic kernel images
On Wed, Jun 8, 2022 at 7:21 AM Masami Hiramatsu <mhiramat@...nel.org> wrote:
>
> Hi Jarkko,
>
> On Wed, 8 Jun 2022 08:25:38 +0300
> Jarkko Sakkinen <jarkko@...nel.org> 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 <jarkko@...fian.com> 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.
IIUC, most users of module_alloc() use it to allocate memory for text, except
that module code uses it for both text and data. Therefore, I guess calling it
text_alloc() is not 100% accurate until we change the module code (to use
a different API to allocate memory for data).
Thanks,
Song
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
> for kprobe side.
>
> Thank you,
>
> --
> Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists