Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2576672iof; Wed, 8 Jun 2022 07:49:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdE5uD7ntceKrKBpUsWMXLTXOTWSs79HfxXFcA4sCOAOjyg533V6in/+RKWQAJ49Z+jKfE X-Received: by 2002:a17:902:b18d:b0:167:86f2:88c7 with SMTP id s13-20020a170902b18d00b0016786f288c7mr13232212plr.103.1654699772024; Wed, 08 Jun 2022 07:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654699772; cv=none; d=google.com; s=arc-20160816; b=qmbCJ1M0SZLCIQi2y2Z857Cvg/BDxoGGnfXAdjoXiP2TnTeNayenmBEXLbnsJwPWqv isu9PaiuCiukKJb1no4/Uk9TToqtMdxw4PPZmX5RKGGexJ8pTIm8sZouXT3XZLucHEDf JZBeRq0XtQxFemB69UYQHT6qq5aoP+joAsgEPdCUoIA3fRfhaOoN0mAoFWkkR5OI5frA 3l2ntUFC+YwMcNrsOfDLzxyU2qvjoN1icbq6cvHE7v2i1fzt0LbVwbrOVSfZ4sWWwddT OfTkmdR4359TfiHEAnbZ9JiY53x484K0zkjWzIuktWCWo5hkEzwtTB052PdQXv6/HdKa aBaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=vicylcJXUsV9rdXL/RueIjggnILeUhyQI/UPRw9um9k=; b=jZ/5dqaBXZgyRiOrSfyAOXfzLlLKkjduyb5XZhQt/CuSLiKWNn90Py4FyFVYYn3Iee B2WE9xHspYIwd0iM4Ah8ZP4okMIouEkZFc48ZLJfKmJuZOBt6J5XdDUUrVrU4xWoBdp/ E+4TqCQBKrkUthWO+R+AS1tMAODYNmBX6n/rVdnkwpN8i96zREVr4q+pEy6vz/fLQ1rA /oWqswkx6G2H/sRNr19VqB76kd6RsQI+kkgYnfpazxY+EQmRjDnL2i6wPk1Fkx60sge7 t54/B/B1Wt1ZmIRY9fZ+vo6PI2Njrecu8R/wAo70FoTAUY4AvwkIJ4bK4cf8XsCUCEbU J07A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f+5uNDkm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id f136-20020a62388e000000b0051bd0d2dcaasi16632405pfa.109.2022.06.08.07.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:49:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f+5uNDkm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 5C143229B77; Wed, 8 Jun 2022 07:22:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241225AbiFHOVu (ORCPT + 99 others); Wed, 8 Jun 2022 10:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241191AbiFHOVr (ORCPT ); Wed, 8 Jun 2022 10:21:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93DA3D1D5; Wed, 8 Jun 2022 07:21:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CFA7661B49; Wed, 8 Jun 2022 14:21:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33A51C34116; Wed, 8 Jun 2022 14:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654698097; bh=1qpAEjSAq5djkkmLyIM6rUzEBFpBwb5S8o8YQ4yPKWA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=f+5uNDkmztVja1h70Kf8HEKtlvbSFHPe7GufnVlMvMkA7EPZj1hNREAoLZkLn4yMZ 6bQ50bNMEBhe4ElBm12ffDV3hbaNZWOfcPkkH6bD1GJ7qTD49z3ahsgnNBTvpURWx5 rrvu5QDBi4lRbKEy6EZew4PC7oAb8cDKq8Fbm+3bojZb/vbBuJ9tfwqhpbvZdjxTl3 y+uNV/KGl545f2ZW+p6SVfNeUdQ8cwc6SLEJ01DZ+ERUPHKg87AJa/IPMGV7vQAvac xZpWEpxQFIZUDnAYuJHwAFDjwTFYVd/DGOvZKjhTQTx1jhQ+TBRkABL3RxqqFRF6Ed MNrXttwyxlWig== Date: Wed, 8 Jun 2022 23:21:15 +0900 From: Masami Hiramatsu (Google) To: Jarkko Sakkinen 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 , 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 , =?UTF-8?B?QW5kcsOp?= 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: <20220608232115.ccd4399f4a1d133e9b65c2a9@kernel.org> In-Reply-To: References: <20220608000014.3054333-1-jarkko@profian.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, NICE_REPLY_A,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 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. Thank you, -- Masami Hiramatsu (Google)