Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2292614iof; Wed, 8 Jun 2022 01:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP+8KGsA8fZ/RHdNI5DRWvCK8th9Iy7DYCNBlr/mxEVif4m5yyGSGF6CGbbJIZOVzDTF3P X-Received: by 2002:a17:90b:3ec2:b0:1e8:9ca4:8d55 with SMTP id rm2-20020a17090b3ec200b001e89ca48d55mr9608772pjb.123.1654677496575; Wed, 08 Jun 2022 01:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654677496; cv=none; d=google.com; s=arc-20160816; b=00z7YLwzdyQx89QD+vyZEi+G/u6ucWRVy7oIWZezVW+VPfR8YWg+gV1PZs6WpZ1+7u ZUxyXaRqUH4SkIySPZyKJeFi/1qfA0zHygCNEnOSWUCgPl5DYucWIq4NkCQtwCwJXPt0 gEy+XslPxB6HDSkMFNuCWqAFXbkgj3idpOOpRPhg5rstRwZBj7zNVy3oiKXI9DNgnQOJ tiVpa9kxZAkH3XAYc3RHxuJQT1Olc5/KXKBpQhWppksSsryx6zXugw3SdHoYOEvcbf7b a5TU293v3hYqkkyAPO+HIJykPB59Su2PFQ1+3fPQeNJSVxPNty5IO12gwSVLdo/oibiB ZoPQ== 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=kXAdUp1KSvm2Vqi8DDpr4LKZ5zxiqStbeE7iyB4GDhM=; b=gZBqkfDSP1z8gHCMaVAc/Fjf1qX1TVGs3KAuO6qSSqGC+U3GtFDBDpmmy8yj8nrZe4 JejiJZ8oKAyz9nWuIDDyU1L237zGL6hwChdpngMqyPX5jxswXcXxkTN1R3/9jodHVC5W 4YFWk/SOWWkGhBKyDJVL7lRHw+vIz79R8o5mgU1xtAnL39u3WkNeIzeJGh/ftFsckHKw On7HMBaly6SogpCNQEIPQCp63iGBKnisey1ugSy3uVaMb35SoTOW+uJHBHI7hjFa85eM u7zBbDZ1ceop815Wr3IF5hiyxo7vh+u/kosfb7A8e8V3e3f980QIB+nMK1c/bxKAhC0Q ebnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bTmq5cb3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p11-20020a170902ebcb00b00163fbb1f1fasi10949856plg.252.2022.06.08.01.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:38:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bTmq5cb3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 348C4224138; Wed, 8 Jun 2022 01:02:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244043AbiFHHNT (ORCPT + 99 others); Wed, 8 Jun 2022 03:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343598AbiFHGLW (ORCPT ); Wed, 8 Jun 2022 02:11:22 -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 21DD2188E42; Tue, 7 Jun 2022 22:27:42 -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 6859BB823CE; Wed, 8 Jun 2022 05:27:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF184C34116; Wed, 8 Jun 2022 05:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654666055; bh=MlRI3FslLxCpadUQCkxKP9EyE+xCG5VhPqp7eO/RKxw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bTmq5cb3aiOFARjJfOSrWvmBbg4IqDeMYLAQcEwT3SvNyrlnsEdo+bJds7+Exmdp1 79OrZgnbP09WSyuTFdvTyLah6ugaMZ0kez+KabcbeZ8t+RmwASwCkX7odNddl6yr6R MpgZoZU5zCgBI4H6UxtnJnfjlqCDb50dNLRMK7iirwicyyRs17a4fFjr1M+htOawKO MHyg7HHPVKiM4wuNrSNYHTep0JDdxmzQJitkoMH17qYMBcYHwsm4aubrdp6Yy11mck fYzRn/OXDH5gklZfaHxdLnwzgwLdwqoLF7wfqldmpcxcfnkI+cdpcFrefdlWXanfjB hgTz8Dxc3vbcw== Date: Wed, 8 Jun 2022 08:25:38 +0300 From: Jarkko Sakkinen To: Guo Ren Cc: 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 , Masami Hiramatsu , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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/ BR, Jarkko