Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp454528iol; Thu, 9 Jun 2022 07:10:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBHvD6xU4tcC/jgxkmn7xLooD3vkMwc/0wd4E5DUX3xk8XRp4iust+KpXru4SKTkFWRMXz X-Received: by 2002:a17:907:60cc:b0:6f4:ffba:489 with SMTP id hv12-20020a17090760cc00b006f4ffba0489mr36664167ejc.666.1654783830751; Thu, 09 Jun 2022 07:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654783830; cv=none; d=google.com; s=arc-20160816; b=tz98AxijklLDTg76H16JcfYxLbOWQzy/H7sYUjX/XXoKBqQaKcZ2BNHorFOp8RBAOa rbf9K6zapYQar7rk/2tduW3id8qIWSRsiiu1FpLmkC8SsQ28yKYbVMmsQOqBHoJ+iMHY QuRJLsRqLIU2qsfpkTQ8Pq2uy1Lf4tttz3a2BJ7EnM3keo/eleL4HzcpRLbbz9va1ZtK OVvlClbCaffx4QQ5SCEHLE2eXTR8UdhZFuSuUqwjgIaXBR67u6tCmn6ovMuHvdhHg5rz vf73jbkZdgkln87yS15LBzg14WsNYmbHG3n1Fwg7D8zepO8Yul8suYIpWNCdMeAEUcBy CbwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=D7rtcVAvM6W3MJwGnOUzvHpi9hNGegku+VllXhbuo5g=; b=OknhbFdUeP7COEGcIoj2mP7/GIgRKZCPtc7ImRsDb0ntLCyJYQlG9y7Nw8BTIcC9oG quKrX7MrHsH3pFJbeQt4R4MXkUbJiAeDFd+SO90IdC6LdjZRdd4qELdpMQU+r3ZaGJOb 3Hp1iB364e4mDgQhVJqvPB1+xtOKKrhuQl2rsWJ1+FAcBrN0h/sBUcf9Xk36cJQSwJUd I+fOQS4eKJMeE7shW0zampyoR9D/eenk0hkmjqSJTa6avWcTFN7NUpjCsWKY3gHyVl1j 05a0ml7FS8ACjaM6ZfcRoOXQFHWh7/7sZV+06gM+HL5dDjiUc+6KAuTicOxMKePbfgFc p5LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yp0wIfJ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a05640226cc00b00431106c55e0si19096530edd.391.2022.06.09.07.09.58; Thu, 09 Jun 2022 07:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yp0wIfJ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343607AbiFINB1 (ORCPT + 99 others); Thu, 9 Jun 2022 09:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235299AbiFINBZ (ORCPT ); Thu, 9 Jun 2022 09:01:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4385214034; Thu, 9 Jun 2022 06:01:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F2F12B82DCF; Thu, 9 Jun 2022 13:01:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35A61C3411B; Thu, 9 Jun 2022 13:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654779681; bh=FvUt2ehWrqdQW2QLw7Br1YJED8DEBVOfYLIpk/PUE0s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yp0wIfJ4/JflDt0m9NlO9ksLM46Vv9ce5rybSgcXPVJ6Jj7BdlbOJl59jp2HqTqpF E+UVhjTgtuU8TgUydKwGo/U2YyqAKSpAt7mZyMe6bfQsmktqBluZJsL38fBywJWTNE fHoDrw0E6Fu8C8O7gGxx4TeDWVZsFb7MObc92wfD+aLzeTgUiqsqPEEQC+FrMd1Yau yotXueILhW/mDMCOq3z4PU/xXhIObpSfYWE3U/aRkHWUqC50t18irzmZbUxKle2kTe D22bdNspu7AMcSAIvdw4x8ymJgRCFY5xNI4BubO86cD2ypXJwELhigyWNJBC0lpfjq 3/f218LQb6+RQ== Date: Thu, 9 Jun 2022 15:59:22 +0300 From: Jarkko Sakkinen To: Masami Hiramatsu Cc: Guo Ren , Jarkko Sakkinen , Linux Kernel Mailing List , Nathaniel McCallum , Russell King , Catalin Marinas , Will Deacon , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "David S. Miller" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , the arch/x86 maintainers , "H. Peter Anvin" , "Naveen N. Rao" , Anil S Keshavamurthy , Luis Chamberlain , Steven Rostedt , Kees Cook , "Peter Zijlstra (Intel)" , Nathan Chancellor , Josh Poimboeuf , Mark Rutland , "Eric W. Biederman" , Marco Elver , Dan Li , Sami Tolvanen , Song Liu , Ard Biesheuvel , "Russell King (Oracle)" , Nick Desaulniers , Linus Walleij , Chen Zhongjin , Nicolas Pitre , Mark Brown , Luis Machado , Geert Uytterhoeven , Joey Gouly , Masahiro Yamada , Andrew Morton , Andrey Konovalov , Kefeng Wang , Atsushi Nemoto , Guenter Roeck , Dave Anglin , Christophe Leroy , Alexei Starovoitov , Nicholas Piggin , Daniel Axtens , "Aneesh Kumar K.V" , Jordan Niethe , Anup Patel , Atish Patra , Changbin Du , Heiko Stuebner , Liao Chang , Philipp Tomsich , Wu Caize , Emil Renner Berthing , Alexander Egorenkov , Thomas Richter , Tobias Huschle , Ilya Leoshkevich , Tom Lendacky , Daniel Bristot de Oliveira , Michael Roth , "Kirill A. Shutemov" , Javier Martinez Canillas , Miroslav Benes , =?iso-8859-1?Q?Andr=E9?= Almeida , Tiezhu Yang , Dmitry Torokhov , Aaron Tomlin , Linux ARM , "open list:BROADCOM NVRAM DRIVER" , Parisc List , linuxppc-dev , linux-riscv , linux-s390 , sparclinux , linux-modules@vger.kernel.org Subject: Re: [PATCH] kprobes: Enable tracing for mololithic kernel images Message-ID: References: <20220608000014.3054333-1-jarkko@profian.com> <20220608232115.ccd4399f4a1d133e9b65c2a9@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220608232115.ccd4399f4a1d133e9b65c2a9@kernel.org> X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 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) > 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) BR, Jarkko