Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2809167iof; Wed, 8 Jun 2022 12:28:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw5oT8Ip3XdBaRZ09bzUGlsnfHVTf4hYedpPNYPFXo6MfMAY2bQSmony3FPRUmf1cK1OKJ X-Received: by 2002:a17:907:3e8d:b0:6fe:d99b:90a with SMTP id hs13-20020a1709073e8d00b006fed99b090amr33035305ejc.416.1654716525890; Wed, 08 Jun 2022 12:28:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654716525; cv=none; d=google.com; s=arc-20160816; b=gUaGKpzTQo2XCS8R2hWDDVprDepvuaF4p+31BkP1pUFd/ZAEHousiLzDpm+LE4sWLC jBHZW5ryAvQdr4kUSGM2TBFKBLLeF8C8LoH7WgUF+KD8wAjFizloyl387j5xJ6XMooU2 rbSCfAb1bnijmjrATBosXDhJ98PNz5Cq68mVsI1DROU/XL+UmHz5BLQjjFUNzDqn1XMh VelSg+qkjFw3ViVSiGUCtySxFJkwd6iKcLT8jQgWwFnP9MbhRaH7xLPqzzCoHOoK4j5r h9x7JGb5XlY++uhbD7/m0kQ2zX5Zu+9oj+UTkwvYtf3qUYrL4bH1HBibOaqeCx/AlBh1 PieA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=n3L9BP0fbkbIdNGwhvKofZ2F7gP26P1rwV6XPmKNibE=; b=tGBKGKqpRJDVoK5DMS/sdSF1POuBWA/RtAXLyU0bE6206qJn0djkJr+fKrOpVYTbaZ nucnpyJSJw83ycUJT8YTZF8pKUF0nAXqnQTFHa97Vfl4eBaziF7keMy+sfeV9iLlEBsl 7yk2q5BPzjflCssZp4VDJC3UNbeQeRf4QEWEdlZ7oqNy3nW3YKovM468CIEp+hJPaxpw /kxJ4FXUJuBN9cKprDfKsNWz9DHhNNgtXuxHp2R3Ifcwr2cQwgbge0yJxeEYuLy3ENj9 BU+4xRafrrnRIOfn1trhPkEE3fIRt9rCrJI1S7eM52H7eRMMKWy2oFBo0kQOHmLH7QFy m1SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AjfkEOCz; 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 m18-20020a170906721200b0070db31e9a97si12871514ejk.483.2022.06.08.12.28.14; Wed, 08 Jun 2022 12:28:45 -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=AjfkEOCz; 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 S231371AbiFHSVM (ORCPT + 99 others); Wed, 8 Jun 2022 14:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbiFHSVJ (ORCPT ); Wed, 8 Jun 2022 14:21:09 -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 E469027B1B; Wed, 8 Jun 2022 11:21:07 -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 33034B829B7; Wed, 8 Jun 2022 18:21:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E486FC3411F; Wed, 8 Jun 2022 18:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654712464; bh=tnKw98gSFfcp7IeTy3/rsQTZtNfF844s9r6khIEQFqc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=AjfkEOCzQP1CUyGGvfTXmQ9ZKl+/KJiiiqEluKILCz+SF7T69KldMwO9VvWqOXn+K Ac4pvQmkG6rb+LITafg7e9uYbUCEcwRPuA2sAoqEXeOCssOJH8rcTzXS+mgUEaElSP savwPKa5u5tdOIzR/8SvEsIRL24yMm/4CpEQ8cN/8vd4l28GIda7o8OmCU39onhTpG OKXeNnT+Gnlb8OFrlSBe1RoCBhw/UOXFSI69i2MtmOVHERKeguuBgZLehjWi0AjZMu yTA5S+a+DC26gzzjUNSMFWaaS9pkOlzhJp5bzD3vqq1Qrj/aHYIVhXPhu5SPG5cVcR R+sAUtT73/35g== Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-3135519f95fso47888357b3.6; Wed, 08 Jun 2022 11:21:04 -0700 (PDT) X-Gm-Message-State: AOAM530q/o97wVPb9b63cVzGTH3vKNCQhgfrC5pQUmFzv1SMqc+CgzXd 5ndNI/1JO9aKPkb9iUeKz3c6WD8mlzP54UsZ/iE= X-Received: by 2002:a0d:eb4d:0:b0:30c:9849:27a1 with SMTP id u74-20020a0deb4d000000b0030c984927a1mr37988780ywe.472.1654712463961; Wed, 08 Jun 2022 11:21:03 -0700 (PDT) MIME-Version: 1.0 References: <20220608000014.3054333-1-jarkko@profian.com> <20220608232115.ccd4399f4a1d133e9b65c2a9@kernel.org> In-Reply-To: From: Song Liu Date: Wed, 8 Jun 2022 11:20:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kprobes: Enable tracing for mololithic kernel images To: Masami Hiramatsu Cc: Jarkko Sakkinen , 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 , 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?Q?Andr=C3=A9_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 Content-Type: text/plain; charset="UTF-8" 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 8, 2022 at 9:12 AM Song Liu wrote: > > On Wed, Jun 8, 2022 at 7:21 AM 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. > > 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). Git history showed me 7a0e27b2a0ce mm: remove vmalloc_exec I guess we are somehow going back in time... Song > > Thanks, > Song > > > > > Acked-by: Masami Hiramatsu (Google) > > for kprobe side. > > > > Thank you, > > > > -- > > Masami Hiramatsu (Google)